猫草大作战优化-抽奖赠送好友道具
This commit is contained in:
parent
61f065747e
commit
58c36d9180
@ -34,10 +34,10 @@ func GetGameNum(Id int) int {
|
||||
return gamedata.GetIntValue(data, "PassNum")
|
||||
}
|
||||
|
||||
func GetJackpotItem(Mul int) (int, []*item.Item, int) {
|
||||
func GetJackpotItem(Mul int) (int, []*item.Item, int, int) {
|
||||
data, err := gamedata.GetData(CATNIP_JACKPOT_CFG_NAME)
|
||||
if err != nil {
|
||||
return 0, nil, 0
|
||||
return 0, nil, 0, 0
|
||||
}
|
||||
JackpotType := GetJackpotType(Mul)
|
||||
r := make(map[int]int)
|
||||
@ -48,13 +48,13 @@ func GetJackpotItem(Mul int) (int, []*item.Item, int) {
|
||||
}
|
||||
Id := GoUtil.RandMap(r)
|
||||
if Id == 0 {
|
||||
return 0, nil, 0
|
||||
return 0, nil, 0, 0
|
||||
}
|
||||
itemData, err := gamedata.GetDataByIntKey(CATNIP_JACKPOT_CFG_NAME, Id)
|
||||
if err != nil {
|
||||
return 0, nil, 0
|
||||
return 0, nil, 0, 0
|
||||
}
|
||||
return Id, gamedata.GetItemList(itemData, "Items"), gamedata.GetIntValue(itemData, "Growth")
|
||||
return Id, gamedata.GetItemList(itemData, "Items"), gamedata.GetIntValue(itemData, "Growth"), gamedata.GetIntValue(itemData, "FriendItems")
|
||||
}
|
||||
|
||||
func GetJackpotType(Mul int) int {
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
mergeCluster "server/cluster"
|
||||
"server/conf"
|
||||
cardCfg "server/conf/card"
|
||||
catnipCfg "server/conf/catnip"
|
||||
chargeCfg "server/conf/charge"
|
||||
decorateCfg "server/conf/decorate"
|
||||
itemCfg "server/conf/item"
|
||||
@ -333,7 +334,7 @@ func handle(p *Player, m *msg.Msg) error {
|
||||
}
|
||||
CatnipMod.BeInvited(int(m.From), m.SendT)
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
FriendMod.AddReplyInfo(m.From, friend.REPLY_TYPE_CATNIP, fmt.Sprintf("%d", CatnipMsg.GameId), m.End)
|
||||
FriendMod.AddReplyInfo(m.From, friend.REPLY_TYPE_CATNIP, fmt.Sprintf("%d", CatnipMsg.GameId), m.End, nil)
|
||||
case msg.HANDLE_TYPE_CATNIP_AGREE: // 同意好友参与猫咪游戏
|
||||
CatnipMod := p.PlayMod.getCatnipMod()
|
||||
CatnipMsgInfo := m.Extra.(CatnipMsg)
|
||||
@ -366,11 +367,16 @@ func handle(p *Player, m *msg.Msg) error {
|
||||
return nil
|
||||
}
|
||||
CatnipMod.GrowthByUid(m.From, CatnipGrowthInfo.Growth)
|
||||
if CatnipGrowthInfo.FriendItems > 0 {
|
||||
Items := catnipCfg.GetItemCost(ActivityId, CatnipGrowthInfo.FriendItems)
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
FriendMod.AddReplyInfo(m.From, friend.REPLY_TYPE_CATNIP_ITEMS, "", m.End, Items)
|
||||
}
|
||||
p.CatnipBackData()
|
||||
case msg.HANDLE_TYPE_FRIEND_GREETING_REPLY:
|
||||
FriendMod := p.PlayMod.getFriendMod()
|
||||
if v, ok := m.Extra.(friend.ReplyInfo); ok {
|
||||
FriendMod.AddReplyInfo(v.Uid, v.Type, v.Param, GoUtil.Now()+24*3600)
|
||||
FriendMod.AddReplyInfo(v.Uid, v.Type, v.Param, GoUtil.Now()+24*3600, nil)
|
||||
FriendLogBackData(p)
|
||||
}
|
||||
case msg.HANDLE_TYPE_FRIEND_SPONSOER:
|
||||
|
||||
@ -6,7 +6,7 @@ import (
|
||||
"server/game/mod/msg"
|
||||
)
|
||||
|
||||
func (p *Player) CatnipGrowthMsg(To, Id, Growth int) error {
|
||||
func (p *Player) CatnipGrowthMsg(To, Id, Growth, FriendItems int) error {
|
||||
ActivityId := GetActivityId(p, activity.ACT_TYPE_CATNIP)
|
||||
FriendMgrSend(&msg.Msg{
|
||||
From: int(p.M_DwUin),
|
||||
@ -14,9 +14,10 @@ func (p *Player) CatnipGrowthMsg(To, Id, Growth int) error {
|
||||
Type: msg.HANDLE_TYPE_CATNIP_GROWTH,
|
||||
SendT: GoUtil.Now(),
|
||||
Extra: CatnipMsg{
|
||||
ActivityId: ActivityId,
|
||||
GameId: Id,
|
||||
Growth: Growth,
|
||||
ActivityId: ActivityId,
|
||||
GameId: Id,
|
||||
Growth: Growth,
|
||||
FriendItems: FriendItems,
|
||||
},
|
||||
})
|
||||
return nil
|
||||
|
||||
@ -1921,7 +1921,7 @@ func ReqAgreeFriend(player *Player, buf []byte) error {
|
||||
}
|
||||
FriendMgrSend(m)
|
||||
FriendMod.AddFriend(Uid)
|
||||
FriendMod.AddReplyInfo(Uid, friend.REPLY_TYPE_GREETING, "", GoUtil.Now()+24*3600)
|
||||
FriendMod.AddReplyInfo(Uid, friend.REPLY_TYPE_GREETING, "", GoUtil.Now()+24*3600, nil)
|
||||
player.PushClientRes(&msg.ResAgreeFriend{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
Uid: req.Uid,
|
||||
@ -4992,8 +4992,8 @@ func ReqAddNpc(player *Player, buf []byte) error {
|
||||
player.TeLog("add_npc", map[string]interface{}{
|
||||
"NpcId": int(req.NpcId),
|
||||
})
|
||||
FriendMod.AddReplyInfo(int(req.NpcId), friend.REPLY_TYPE_GREETING, "", GoUtil.Now()+24*3600)
|
||||
FriendMod.AddReplyInfo(int(req.NpcId), friend.REPLY_TYPE_GREETING_Get, "", GoUtil.Now()+24*3600)
|
||||
FriendMod.AddReplyInfo(int(req.NpcId), friend.REPLY_TYPE_GREETING, "", GoUtil.Now()+24*3600, nil)
|
||||
FriendMod.AddReplyInfo(int(req.NpcId), friend.REPLY_TYPE_GREETING_Get, "", GoUtil.Now()+24*3600, nil)
|
||||
player.AddLog(int(req.NpcId), friend.LOG_TYPE_FRIEND_BECOME_NPC, GoUtil.String(req.NpcId), GoUtil.Now())
|
||||
player.PushClientRes(&msg.ResAddNpc{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
@ -5460,7 +5460,7 @@ func ReqCatnipPlay(player *Player, buf []byte) error {
|
||||
return err
|
||||
}
|
||||
CatnipMod := player.PlayMod.getCatnipMod()
|
||||
Id, Growth, PartnerId, Items, ItemCost, err := CatnipMod.Play(int(req.Id))
|
||||
Id, Growth, PartnerId, Items, ItemCost, FriendItems, err := CatnipMod.Play(int(req.Id))
|
||||
if err != nil {
|
||||
player.SendErrClienRes(&msg.ResCatnipPlay{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
@ -5490,7 +5490,7 @@ func ReqCatnipPlay(player *Player, buf []byte) error {
|
||||
"get_award": Items,
|
||||
})
|
||||
if Growth > 0 {
|
||||
player.CatnipGrowthMsg(PartnerId, int(req.Id), Growth)
|
||||
player.CatnipGrowthMsg(PartnerId, int(req.Id), Growth, FriendItems*CatnipMod.Mul)
|
||||
}
|
||||
player.CatnipBackData()
|
||||
player.PlayMod.save()
|
||||
|
||||
@ -86,9 +86,10 @@ type GameResult struct {
|
||||
}
|
||||
|
||||
type CatnipMsg struct {
|
||||
ActivityId int
|
||||
GameId int
|
||||
Growth int // 增长值
|
||||
ActivityId int
|
||||
GameId int
|
||||
Growth int // 增长值
|
||||
FriendItems int // 赠送好友的道具数量
|
||||
}
|
||||
|
||||
type CatnipLock struct {
|
||||
|
||||
@ -165,18 +165,18 @@ func (c *CatnipMod) Refuse(Id, Uid int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *CatnipMod) Play(Id int) (int, int, int, []*item.Item, []*item.Item, error) {
|
||||
func (c *CatnipMod) Play(Id int) (int, int, int, []*item.Item, []*item.Item, int, error) {
|
||||
GameInfo, ok := c.Game[Id]
|
||||
if !ok {
|
||||
return 0, 0, 0, nil, nil, fmt.Errorf("game with ID %d does not exist", Id)
|
||||
return 0, 0, 0, nil, nil, 0, fmt.Errorf("game with ID %d does not exist", Id)
|
||||
}
|
||||
Id, Items, Growth := catnipCfg.GetJackpotItem(c.Mul)
|
||||
Id, Items, Growth, FriendItems := catnipCfg.GetJackpotItem(c.Mul)
|
||||
if Growth > 0 {
|
||||
c.Growth(Id, Growth)
|
||||
}
|
||||
ItemCost := catnipCfg.GetItemCost(c.Id, c.Mul)
|
||||
GameInfo.Progress += Growth
|
||||
return Id, Growth, GameInfo.Partner, Items, ItemCost, nil
|
||||
return Id, Growth, GameInfo.Partner, Items, ItemCost, FriendItems, nil
|
||||
}
|
||||
|
||||
func (c *CatnipMod) Reward(Id, Progress int) ([]*item.Item, *CatnipGame, error) {
|
||||
|
||||
@ -35,6 +35,7 @@ type ReplyInfo struct {
|
||||
AddTime int64
|
||||
ReplyTime int64
|
||||
EndTime int64
|
||||
Items []*item.Item
|
||||
}
|
||||
|
||||
type ActLogInfo struct {
|
||||
@ -69,7 +70,8 @@ type ApplyInfo struct {
|
||||
const (
|
||||
REPLY_TYPE_GREETING = 1 // 问候
|
||||
REPLY_TYPE_GREETING_Get = 2 // 收到问候
|
||||
REPLY_TYPE_CATNIP = 3 // 猫薄荷
|
||||
REPLY_TYPE_CATNIP = 3 // 猫薄荷加好友
|
||||
REPLY_TYPE_CATNIP_ITEMS = 4 // 收到猫薄荷好友道具
|
||||
)
|
||||
|
||||
// 24小时内与玩家进行过以下互动的用户,若被选中参加本次宠物宝藏,在其头像旁添加礼物盒
|
||||
@ -500,9 +502,8 @@ func (f *FriendMod) GetActLogLast() *ActLogInfo {
|
||||
return f.ActivityLog[len(f.ActivityLog)-1]
|
||||
}
|
||||
|
||||
func (f *FriendMod) AddReplyInfo(Uid int, Type int, Param string, EndTime int64) {
|
||||
func (f *FriendMod) AddReplyInfo(Uid int, Type int, Param string, EndTime int64, Items []*item.Item) {
|
||||
f.AutoId++
|
||||
|
||||
f.ReplyList = append(f.ReplyList, &ReplyInfo{
|
||||
Id: f.AutoId,
|
||||
Uid: Uid,
|
||||
@ -511,6 +512,7 @@ func (f *FriendMod) AddReplyInfo(Uid int, Type int, Param string, EndTime int64)
|
||||
Status: 0,
|
||||
AddTime: GoUtil.Now(),
|
||||
EndTime: EndTime,
|
||||
Items: Items,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user