From 58c36d91800e2174014c51ba17dcac7024a6a967 Mon Sep 17 00:00:00 2001 From: hahwu <31872165+hahwu@users.noreply.github.com> Date: Mon, 8 Dec 2025 10:49:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8C=AB=E8=8D=89=E5=A4=A7=E4=BD=9C=E6=88=98?= =?UTF-8?q?=E4=BC=98=E5=8C=96-=E6=8A=BD=E5=A5=96=E8=B5=A0=E9=80=81?= =?UTF-8?q?=E5=A5=BD=E5=8F=8B=E9=81=93=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/conf/catnip/CatnipCfg.go | 10 +++++----- src/server/game/PlayerFunc.go | 10 ++++++++-- src/server/game/PlayerMsg.go | 9 +++++---- src/server/game/RegisterNetworkFunc.go | 10 +++++----- src/server/game/Type.go | 7 ++++--- src/server/game/mod/catnip/Catnip.go | 8 ++++---- src/server/game/mod/friend/Friend.go | 8 +++++--- 7 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/server/conf/catnip/CatnipCfg.go b/src/server/conf/catnip/CatnipCfg.go index 7d44a585..fe242583 100644 --- a/src/server/conf/catnip/CatnipCfg.go +++ b/src/server/conf/catnip/CatnipCfg.go @@ -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 { diff --git a/src/server/game/PlayerFunc.go b/src/server/game/PlayerFunc.go index 9d8ff545..97a8137a 100644 --- a/src/server/game/PlayerFunc.go +++ b/src/server/game/PlayerFunc.go @@ -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: diff --git a/src/server/game/PlayerMsg.go b/src/server/game/PlayerMsg.go index b0e7ddb7..3d56bf66 100644 --- a/src/server/game/PlayerMsg.go +++ b/src/server/game/PlayerMsg.go @@ -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 diff --git a/src/server/game/RegisterNetworkFunc.go b/src/server/game/RegisterNetworkFunc.go index 777c601c..74d9ea7d 100644 --- a/src/server/game/RegisterNetworkFunc.go +++ b/src/server/game/RegisterNetworkFunc.go @@ -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() diff --git a/src/server/game/Type.go b/src/server/game/Type.go index 9ff8994d..4bece5e7 100644 --- a/src/server/game/Type.go +++ b/src/server/game/Type.go @@ -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 { diff --git a/src/server/game/mod/catnip/Catnip.go b/src/server/game/mod/catnip/Catnip.go index 36247e6f..cd619640 100644 --- a/src/server/game/mod/catnip/Catnip.go +++ b/src/server/game/mod/catnip/Catnip.go @@ -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) { diff --git a/src/server/game/mod/friend/Friend.go b/src/server/game/mod/friend/Friend.go index 88297eda..3623036d 100644 --- a/src/server/game/mod/friend/Friend.go +++ b/src/server/game/mod/friend/Friend.go @@ -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, }) }