From 259814ab90db9c611b29fb538ee9eee3e3b877dc Mon Sep 17 00:00:00 2001 From: hahwu <31872165+hahwu@users.noreply.github.com> Date: Fri, 5 Dec 2025 19:39:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8C=AB=E8=8D=89=E5=A4=A7=E4=BD=9C=E6=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/GoUtil/sliceUtil.go | 6 + src/server/game/ActivityFunc.go | 70 ++++++--- src/server/game/Gm.go | 5 + src/server/game/PlayerFunc.go | 18 +-- src/server/game/RegisterNetworkFunc.go | 60 ++++--- src/server/game/VarMgr.go | 20 ++- src/server/game/mod/catnip/Catnip.go | 156 ++++++++++--------- src/server/game/mod/guessColor/guessColor.go | 6 +- src/server/msg/Gameapi.pb.go | 137 ++++++++-------- 9 files changed, 255 insertions(+), 223 deletions(-) diff --git a/src/server/GoUtil/sliceUtil.go b/src/server/GoUtil/sliceUtil.go index 194db286..72cd199f 100644 --- a/src/server/GoUtil/sliceUtil.go +++ b/src/server/GoUtil/sliceUtil.go @@ -9,6 +9,12 @@ import ( "strings" ) +func IntSlice(d interface{}) []int { + if d == nil { + return []int{} + } + return d.([]int) +} func IntToInt32(d []int) []int32 { r := make([]int32, 0, len(d)) for _, d := range d { diff --git a/src/server/game/ActivityFunc.go b/src/server/game/ActivityFunc.go index a23348f3..847ceb04 100644 --- a/src/server/game/ActivityFunc.go +++ b/src/server/game/ActivityFunc.go @@ -1,6 +1,7 @@ package game import ( + "fmt" "server/GoUtil" activityCfg "server/conf/activity" catnipCfg "server/conf/catnip" @@ -314,6 +315,7 @@ func (p *Player) CatnipBackData() { if CatnipMod == nil { return } + FriendMod := p.PlayMod.getFriendMod() GameList := make([]*msg.CatnipGame, 0) for _, v := range CatnipMod.Game { GameInfo := &msg.CatnipGame{ @@ -329,32 +331,56 @@ func (p *Player) CatnipBackData() { GameInfo.Partner = PlayerData } } - InviteList := make([]*msg.CatnipInvite, 0) - for _, iv := range v.InviteList { - InviteList = append(InviteList, &msg.CatnipInvite{ - Uid: int64(iv.InviteId), - Time: int64(iv.Time), - }) - } - GameInfo.InviteList = InviteList - BeInvitedList := make([]*msg.CatnipInvite, 0) - for _, iv := range v.BeInvitedList { - BeInvitedList = append(BeInvitedList, &msg.CatnipInvite{ - Uid: int64(iv.InviteId), - Time: int64(iv.Time), - }) - } - GameInfo.BeInviteList = BeInvitedList + GameList = append(GameList, GameInfo) } + tmpData := make(map[int]*msg.CatnipInvite) + InviteList := make([]*msg.CatnipInvite, 0) + for Uid, Info := range CatnipMod.InviteList { + tmpData[Uid] = &msg.CatnipInvite{ + Uid: int64(Uid), + Time: Info.Time, + Type: 1, + } + } + for Uid, Info := range CatnipMod.BeInvitedList { + tmpData[Uid] = &msg.CatnipInvite{ + Uid: int64(Uid), + Time: Info.Time, + Type: 2, + } + } + + for Uid := range FriendMod.NewFriendList { + key := fmt.Sprintf("catnip_partner_%d", Uid) + Var := G_GameLogicPtr.VarMgr.GetExpireVar(key) + if len(Var.D.([]int)) >= 4 { + tmpData[Uid] = &msg.CatnipInvite{ + Uid: int64(Uid), + Type: 3, + } + continue + } + if _, ok := tmpData[Uid]; !ok { + tmpData[Uid] = &msg.CatnipInvite{ + Uid: int64(Uid), + Type: 0, + } + } + } + for _, v := range tmpData { + InviteList = append(InviteList, v) + } + Template := catnipCfg.GetTemplateId(CatnipMod.Id) res := &msg.ResCatnip{ - Id: int32(CatnipMod.Id), - EndTime: int32(ActivityInfo.EndT), - Status: int32(Status), - Template: int32(Template), - GameList: GameList, - Multiply: int32(CatnipMod.Mul), + Id: int32(CatnipMod.Id), + EndTime: int32(ActivityInfo.EndT), + Status: int32(Status), + Template: int32(Template), + GameList: GameList, + Multiply: int32(CatnipMod.Mul), + FriendList: InviteList, } p.PushClientRes(res) } diff --git a/src/server/game/Gm.go b/src/server/game/Gm.go index 2e8cd6d7..b4b90495 100644 --- a/src/server/game/Gm.go +++ b/src/server/game/Gm.go @@ -286,6 +286,11 @@ func ReqGmCommand_(player *Player, Command string) error { ActivityInfo := GetActivityInfo(player, activity.ACT_TYPE_MINING) MiningMod.ZeroUpdate(ActivityInfo.Id) MiningBackData(player) + case "catnipReload": + CatnipMod := player.PlayMod.getCatnipMod() + CatnipMod.ZeroUpdate(-1) + ActivityInfo := GetActivityInfo(player, activity.ACT_TYPE_CATNIP) + CatnipMod.ZeroUpdate(ActivityInfo.Id) case "guessColorReload": GuessColorMod := player.PlayMod.getGuessColorMod() GuessColorMod.ZeroUpdate(-1) diff --git a/src/server/game/PlayerFunc.go b/src/server/game/PlayerFunc.go index 6146cf17..00257ab1 100644 --- a/src/server/game/PlayerFunc.go +++ b/src/server/game/PlayerFunc.go @@ -331,7 +331,7 @@ func handle(p *Player, m *msg.Msg) error { if ActivityId != CatnipMsg.ActivityId { // 活动ID不匹配 return nil } - CatnipMod.BeInvited(CatnipMsg.GameId, int(m.From), m.SendT) + 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) case msg.HANDLE_TYPE_CATNIP_AGREE: // 同意好友参与猫咪游戏 @@ -341,19 +341,7 @@ func handle(p *Player, m *msg.Msg) error { if ActivityId != CatnipMsgInfo.ActivityId { // 活动ID不匹配 return nil } - UserList, _ := CatnipMod.Agree(CatnipMsgInfo.GameId, int(m.From)) - for _, v := range UserList { - FriendMgrSend(&msg.Msg{ - From: int(p.M_DwUin), - To: int(v), - Type: msg.HANDLE_TYPE_CATNIP_AGREE, - Extra: CatnipMsg{ - ActivityId: ActivityId, - GameId: int(CatnipMsgInfo.GameId), - }, - SendT: GoUtil.Now(), - }) - } + CatnipMod.BeAgree(CatnipMsgInfo.GameId, int(m.From)) case msg.HANDLE_TYPE_CATNIP_AGREE_DEL: // 同意好友参与猫咪游戏后删除邀请 CatnipMod := p.PlayMod.getCatnipMod() CatnipMsg := m.Extra.(CatnipMsg) @@ -473,7 +461,7 @@ func SyncFriendMsg(p *Player) { return } sort.Slice(ml, func(i, j int) bool { - return ml[i].SendT < ml[j].SendT + return ml[i].Id < ml[j].Id }) maxId := int64(0) for _, v := range ml { diff --git a/src/server/game/RegisterNetworkFunc.go b/src/server/game/RegisterNetworkFunc.go index 9908c87b..777c601c 100644 --- a/src/server/game/RegisterNetworkFunc.go +++ b/src/server/game/RegisterNetworkFunc.go @@ -3553,7 +3553,11 @@ func ReqGuessColorTake(player *Player, buf []byte) error { }) return err } - GuessColorMod.Take(req.Map.Map, req.OMap) + var M map[int32]int32 + if req.Map != nil { + M = req.Map.Map + } + GuessColorMod.Take(M, req.OMap) player.TeLog("ReqGuessColorTake", map[string]interface{}{ "map": req.Map.Map, "o_map": req.OMap, @@ -5343,10 +5347,10 @@ func ReqCatnipInvite(player *Player, buf []byte) error { if err != nil { return err } - ActivityId := GetActivityId(player, activity.ACT_TYPE_MINING) + ActivityId := GetActivityId(player, activity.ACT_TYPE_CATNIP) ActivityInfo := GetActivityInfo(player, ActivityId) CatnipMod := player.PlayMod.getCatnipMod() - err = CatnipMod.Invite(int(req.Id), int(req.Uid)) + err = CatnipMod.Invite(int(req.Uid), int(req.Id)) if err != nil { player.SendErrClienRes(&msg.ResCatnipInvite{ Code: msg.RES_CODE_FAIL, @@ -5354,7 +5358,7 @@ func ReqCatnipInvite(player *Player, buf []byte) error { }) return err } - player.TeLog("catnip_invite", map[string]interface{}{ + player.TeLog("cats_garden_invite", map[string]interface{}{ "Id": int(req.Id), }) FriendMgrSend(&MsqMod.Msg{ @@ -5368,7 +5372,7 @@ func ReqCatnipInvite(player *Player, buf []byte) error { }, SendT: GoUtil.Now(), }) - + player.CatnipBackData() player.PlayMod.save() player.PushClientRes(&msg.ResCatnipInvite{ Code: msg.RES_CODE_SUCCESS, @@ -5383,8 +5387,8 @@ func ReqCatnipAgree(player *Player, buf []byte) error { return err } CatnipMod := player.PlayMod.getCatnipMod() - ActivityId := GetActivityId(player, activity.ACT_TYPE_MINING) - UserList, err := CatnipMod.Agree(int(req.Id), int(req.Uid)) + ActivityId := GetActivityId(player, activity.ACT_TYPE_CATNIP) + _, err = CatnipMod.Agree(int(req.Id), int(req.Uid)) if err != nil { player.SendErrClienRes(&msg.ResCatnipAgree{ Code: msg.RES_CODE_FAIL, @@ -5400,7 +5404,7 @@ func ReqCatnipAgree(player *Player, buf []byte) error { }) return err } - player.TeLog("catnip_agree", map[string]interface{}{ + player.TeLog("cats_garden_accept_invite", map[string]interface{}{ "Id": int(req.Id), }) FriendMgrSend(&MsqMod.Msg{ @@ -5413,19 +5417,6 @@ func ReqCatnipAgree(player *Player, buf []byte) error { }, SendT: GoUtil.Now(), }) - - for _, v := range UserList { - FriendMgrSend(&MsqMod.Msg{ - From: int(player.M_DwUin), - To: int(v), - Type: MsqMod.HANDLE_TYPE_CATNIP_AGREE, - Extra: CatnipMsg{ - ActivityId: ActivityId, - GameId: int(req.Id), - }, - SendT: GoUtil.Now(), - }) - } player.CatnipBackData() player.PlayMod.save() player.PushClientRes(&msg.ResCatnipAgree{ @@ -5491,11 +5482,12 @@ func ReqCatnipPlay(player *Player, buf []byte) error { Msg: err.Error(), }) } - player.TeLog("catnip_play", map[string]interface{}{ - "Id": int(req.Id), - "Growth": Growth, - "PartnerId": PartnerId, - "Items": Items, + player.TeLog("cats_garden_expend_token", map[string]interface{}{ + "Id": int(req.Id), + "Growth": Growth, + "multiple": CatnipMod.GetMultiple(), + "expend_num": ItemCost[0].Num, + "get_award": Items, }) if Growth > 0 { player.CatnipGrowthMsg(PartnerId, int(req.Id), Growth) @@ -5517,7 +5509,7 @@ func ReqCatnipReward(player *Player, buf []byte) error { return err } CatnipMod := player.PlayMod.getCatnipMod() - Items, err := CatnipMod.Reward(int(req.Id), int(req.Progress)) + Items, GameInfo, err := CatnipMod.Reward(int(req.Id), int(req.Progress)) if err != nil { player.SendErrClienRes(&msg.ResCatnipReward{ Code: msg.RES_CODE_FAIL, @@ -5533,10 +5525,12 @@ func ReqCatnipReward(player *Player, buf []byte) error { }) return err } - player.TeLog("catnip_reward", map[string]interface{}{ - "Id": int(req.Id), - "Progress": int(req.Progress), - "Items": Items, + player.TeLog("cats_garden_stage_ewards", map[string]interface{}{ + "Id": int(req.Id), + "Progress": int(req.Progress), + "friends_ID": GameInfo.Partner, + "friends_get_num": GameInfo.PartnerAdd, + "user_get_num": GameInfo.Progress - GameInfo.PartnerAdd, }) player.CatnipBackData() player.PlayMod.save() @@ -5573,6 +5567,7 @@ func ReqCatnipGrandReward(player *Player, buf []byte) error { player.TeLog("catnip_grand_reward", map[string]interface{}{ "Items": Items, }) + player.CatnipBackData() player.PlayMod.save() player.PushClientRes(&msg.ResCatnipGrandReward{ Code: msg.RES_CODE_SUCCESS, @@ -5604,10 +5599,11 @@ func ReqCatnipRefuse(player *Player, buf []byte) error { Type: MsqMod.HANDLE_TYPE_CATNIP_REFUSE, SendT: GoUtil.Now(), Extra: CatnipMsg{ - ActivityId: GetActivityId(player, activity.ACT_TYPE_MINING), + ActivityId: GetActivityId(player, activity.ACT_TYPE_CATNIP), GameId: int(req.Id), }, }) + player.CatnipBackData() player.PlayMod.save() player.PushClientRes(&msg.ResCatnipRefuse{ Code: msg.RES_CODE_SUCCESS, diff --git a/src/server/game/VarMgr.go b/src/server/game/VarMgr.go index 14897ea4..70c343f4 100644 --- a/src/server/game/VarMgr.go +++ b/src/server/game/VarMgr.go @@ -48,6 +48,9 @@ func (f *VarMgr) Init() { if f.data.(*VarData).UserVar == nil { f.data.(*VarData).UserVar = make(map[string]*VarUserData) } + if f.data.(*VarData).VarExpire == nil { + f.data.(*VarData).VarExpire = make(map[string]*VarExpireData) + } if f.getData().ZeroTime == GoUtil.ZeroTimestamp() { f.ZeroUpdate(&msg.Msg{}) } @@ -86,18 +89,21 @@ func (f *VarMgr) SetCatnipPartner(m *msg.Msg) (interface{}, error) { MyUid := GoUtil.Int(Param["uid"]) CatnipGameId := GoUtil.Int(Param["game_id"]) CatnipPartnerId := GoUtil.Int(Param["partner_uid"]) - myKey := fmt.Sprintf("catnip_partner_%d_%d", MyUid, CatnipGameId) - key := fmt.Sprintf("catnip_partner_%d_%d", CatnipPartnerId, CatnipGameId) - PartnerInfo := f.GetExpireVar(key) - if PartnerInfo.D != nil { - return nil, fmt.Errorf("catnip partner already set for uid %d in game %d", CatnipPartnerId, CatnipGameId) + myKey := fmt.Sprintf("catnip_partner_%d", MyUid) + key := fmt.Sprintf("catnip_partner_%d", CatnipPartnerId) + OtherPartnerInfo := f.GetExpireVar(key) + MyPartnerInfo := f.GetExpireVar(myKey) + MyOfPartnerList := GoUtil.IntSlice(MyPartnerInfo.D) + OtherOfPartnerList := GoUtil.IntSlice(OtherPartnerInfo.D) + if len(MyOfPartnerList) > 4 || len(OtherOfPartnerList) > 4 { + return nil, fmt.Errorf("catnip partner already full for uid %d in game %d", CatnipPartnerId, CatnipGameId) } f.SetExpireVar(key, &VarExpireData{ - D: MyUid, + D: append(OtherOfPartnerList, MyUid), T: m.End, }) f.SetExpireVar(myKey, &VarExpireData{ - D: CatnipPartnerId, + D: append(MyOfPartnerList, CatnipPartnerId), T: m.End, }) return nil, nil diff --git a/src/server/game/mod/catnip/Catnip.go b/src/server/game/mod/catnip/Catnip.go index 9eef0a8b..43e86e96 100644 --- a/src/server/game/mod/catnip/Catnip.go +++ b/src/server/game/mod/catnip/Catnip.go @@ -10,8 +10,10 @@ import ( type CatnipMod struct { Id int Game map[int]*CatnipGame - Mul int // 倍数 - IsGetGrandReward bool // 是否领取过大丰收奖励 + Mul int // 倍数 + IsGetGrandReward bool // 是否领取过大丰收奖励 + InviteList map[int]*InviteInfo // 邀请列表,key: 邀请者ID, value: 被邀请者ID + BeInvitedList map[int]*InviteInfo // 被邀请列表,key: 被邀请者ID, value: 邀请者ID } type InviteInfo struct { @@ -20,15 +22,14 @@ type InviteInfo struct { } type CatnipGame struct { - Id int // 游戏ID - Partner int // 伙伴ID - Progress int // 进度 - PartnerAdd int // 伙伴贡献 - Reward []int // 已领取阶段奖励 - Status int // 0: Not Started, 1: In Progress, 2: Completed - InviteList map[int]*InviteInfo // 邀请列表,key: 邀请者ID, value: 被邀请者ID - BeInvitedList map[int]*InviteInfo // 被邀请列表,key: 被邀请者ID, value: 邀请者ID - EmojiId int // 表情ID + Id int // 游戏ID + Partner int // 伙伴ID + Progress int // 进度 + PartnerAdd int // 伙伴贡献 + Reward []int // 已领取阶段奖励 + Status int // 0: Not Started, 1: In Progress, 2: Completed + + EmojiId int // 表情ID } const ( @@ -43,6 +44,12 @@ func (c *CatnipMod) InitData() { if c.Game == nil { c.Game = make(map[int]*CatnipGame) } + if c.InviteList == nil { + c.InviteList = make(map[int]*InviteInfo) + } + if c.BeInvitedList == nil { + c.BeInvitedList = make(map[int]*InviteInfo) + } } func (c *CatnipMod) Login(Id int) int { @@ -59,14 +66,14 @@ func (c *CatnipMod) Login(Id int) int { c.Game = make(map[int]*CatnipGame) c.Mul = 1 // Default multiplier GameNum := catnipCfg.GetGameNum(c.Id) // Assuming 1 is the default game ID + c.InviteList = make(map[int]*InviteInfo) + c.BeInvitedList = make(map[int]*InviteInfo) for i := 1; i <= GameNum; i++ { c.Game[i] = &CatnipGame{ - Id: i, - Partner: 0, // No partner initially - Progress: 0, // Initial progress - Status: GAME_STATUS_IDLE, // Not started - InviteList: make(map[int]*InviteInfo), // Initialize invite list - BeInvitedList: make(map[int]*InviteInfo), // Initialize be invited list + Id: i, + Partner: 0, // No partner initially + Progress: 0, // Initial progress + Status: GAME_STATUS_IDLE, // Not started } } return c.Id @@ -76,75 +83,75 @@ func (c *CatnipMod) ZeroUpdate(Id int) { c.Login(Id) } -func (c *CatnipMod) Invite(Id, Uid int) error { - GameInfo, ok := c.Game[Id] - if !ok { - return fmt.Errorf("game with ID %d does not exist", Id) - } - if GameInfo.Status != 0 { - return fmt.Errorf("game with ID %d is already in progress or completed", Id) +func (c *CatnipMod) Invite(Uid, Id int) error { + if c.InviteList[Uid] != nil { + return fmt.Errorf("user with ID %d is already invited", Uid) } - if GameInfo.InviteList[Uid] != nil { - return fmt.Errorf("user with ID %d is already invited to game ID %d", Uid, Id) - } - - GameInfo.InviteList[Uid] = &InviteInfo{ - InviteId: Uid, + c.InviteList[Uid] = &InviteInfo{ + InviteId: Id, Time: GoUtil.Now(), } return nil } -func (c *CatnipMod) BeInvited(Id, Uid int, Time int64) error { - GameInfo, ok := c.Game[Id] - if !ok { - return fmt.Errorf("game with ID %d does not exist", Id) - } - if GameInfo.Status != GAME_STATUS_IDLE { - return fmt.Errorf("game with ID %d is already in progress or completed", Id) - } +func (c *CatnipMod) BeInvited(Uid int, Time int64) error { // Check if the user is already invited - invite := GameInfo.BeInvitedList[Uid] - if invite != nil && invite.InviteId == Id { - return fmt.Errorf("user with ID %d has already been invited to game ID %d", Uid, Id) + invite := c.BeInvitedList[Uid] + if invite != nil { + return fmt.Errorf("user with ID %d has already been invited ", Uid) } - GameInfo.BeInvitedList[Uid] = &InviteInfo{ - InviteId: Id, + c.BeInvitedList[Uid] = &InviteInfo{ + InviteId: Uid, Time: Time, } return nil } func (c *CatnipMod) Agree(Id, Uid int) ([]int, error) { - GameInfo, ok := c.Game[Id] - if !ok { - return nil, fmt.Errorf("game with ID %d does not exist", Id) - } - if GameInfo.Status != GAME_STATUS_IDLE { - return nil, fmt.Errorf("game with ID %d is already in progress or completed", Id) - } - // Check if the user is in the invite list - _, exists := GameInfo.InviteList[Uid] + _, exists := c.BeInvitedList[Uid] if !exists { return nil, fmt.Errorf("user with ID %d is not invited to game ID %d", Uid, Id) } // Remove the invite after agreeing - delete(GameInfo.InviteList, Uid) - GameInfo.Partner = Uid // Set the partner for the game - GameInfo.Status = GAME_STATUS_COMPLETED // Set the game status to completed + + delete(c.BeInvitedList, Uid) + for _, GameInfo := range c.Game { + if GameInfo.Partner == 0 { + GameInfo.Partner = Uid + GameInfo.Status = GAME_STATUS_IN_PROGRESS + return []int{}, nil + } + } + return []int{}, nil +} + +func (c *CatnipMod) BeAgree(Id, Uid int) ([]int, error) { + info, exists := c.InviteList[Uid] + if !exists { + return nil, fmt.Errorf("user with ID %d is not invited to game ID %d", Uid, Id) + } + // Remove the invite after agreeing + GameInfo := c.Game[info.InviteId] + if GameInfo.Partner == 0 { + GameInfo.Partner = Uid + GameInfo.Status = GAME_STATUS_IN_PROGRESS + delete(c.InviteList, Uid) + return []int{}, nil + } + delete(c.InviteList, Uid) + for _, GameInfo := range c.Game { + if GameInfo.Partner == 0 { + GameInfo.Partner = Uid + GameInfo.Status = GAME_STATUS_IN_PROGRESS + return []int{}, nil + } + } return []int{}, nil } func (c *CatnipMod) DelInvited(Id, Uid int) error { - GameInfo, ok := c.Game[Id] - if !ok { - return fmt.Errorf("game with ID %d does not exist", Id) - } - if GameInfo.Status != GAME_STATUS_IDLE { - return fmt.Errorf("game with ID %d is already in progress or completed", Id) - } - delete(GameInfo.InviteList, Uid) + delete(c.InviteList, Uid) return nil } @@ -154,14 +161,7 @@ func (c *CatnipMod) Multiply(Mul int) error { } func (c *CatnipMod) Refuse(Id, Uid int) error { - GameInfo, ok := c.Game[Id] - if !ok { - return fmt.Errorf("game with ID %d does not exist", Id) - } - if GameInfo.Status != GAME_STATUS_IDLE { - return fmt.Errorf("game with ID %d is already in progress or completed", Id) - } - delete(GameInfo.BeInvitedList, Uid) + delete(c.BeInvitedList, Uid) return nil } @@ -179,19 +179,19 @@ func (c *CatnipMod) Play(Id int) (int, int, int, []*item.Item, []*item.Item, err return Id, Growth, GameInfo.Partner, Items, ItemCost, nil } -func (c *CatnipMod) Reward(Id, Progress int) ([]*item.Item, error) { +func (c *CatnipMod) Reward(Id, Progress int) ([]*item.Item, *CatnipGame, error) { GameInfo, ok := c.Game[Id] if !ok { - return nil, fmt.Errorf("game with Progress %d does not exist", Id) + return nil, nil, fmt.Errorf("game with Progress %d does not exist", Id) } if GameInfo.Progress < Progress { - return nil, fmt.Errorf("game with ID %d has not reached the required progress %d", Id, Progress) + return nil, nil, fmt.Errorf("game with ID %d has not reached the required progress %d", Id, Progress) } if GoUtil.InArray(Progress, GameInfo.Reward) { - return nil, fmt.Errorf("reward for progress %d has already been claimed in game ID %d", Progress, Id) + return nil, nil, fmt.Errorf("reward for progress %d has already been claimed in game ID %d", Progress, Id) } GameInfo.Reward = append(GameInfo.Reward, Progress) - return catnipCfg.GetProgressReward(c.Id, Progress), nil + return catnipCfg.GetProgressReward(c.Id, Progress), GameInfo, nil } func (c *CatnipMod) GrandReward() ([]*item.Item, error) { @@ -229,3 +229,7 @@ func (c *CatnipMod) SetEmoji(Id, EmojiId int) { // Here we can set the emoji for the game. This is a placeholder implementation. GameInfo.EmojiId = EmojiId } + +func (c *CatnipMod) GetMultiple() int { + return c.Mul +} diff --git a/src/server/game/mod/guessColor/guessColor.go b/src/server/game/mod/guessColor/guessColor.go index 532989bd..4c13e32d 100644 --- a/src/server/game/mod/guessColor/guessColor.go +++ b/src/server/game/mod/guessColor/guessColor.go @@ -89,9 +89,11 @@ func (g *GuessColorMod) FirstIn() []*item.Item { } func (g *GuessColorMod) Take(Map map[int32]int32, OMap map[int32]int32) { - g.MapList = append(g.MapList, Map) + if len(Map) > 0 { + g.MapList = append(g.MapList, Map) + g.Guess++ + } g.OMap = OMap - g.Guess++ } func (g *GuessColorMod) GetLoseItem() []*item.Item { diff --git a/src/server/msg/Gameapi.pb.go b/src/server/msg/Gameapi.pb.go index 149ed7d2..52e07c70 100644 --- a/src/server/msg/Gameapi.pb.go +++ b/src/server/msg/Gameapi.pb.go @@ -25867,12 +25867,13 @@ func (*ReqCatnip) Descriptor() ([]byte, []int) { type ResCatnip struct { state protoimpl.MessageState `protogen:"open.v1"` - Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` // 活动id - Status int32 `protobuf:"varint,2,opt,name=Status,proto3" json:"Status,omitempty"` // 0 未开始 1 进行中 2 已结束 - EndTime int32 `protobuf:"varint,3,opt,name=EndTime,proto3" json:"EndTime,omitempty"` // 结束时间 - Template int32 `protobuf:"varint,4,opt,name=Template,proto3" json:"Template,omitempty"` // 模板 - GameList []*CatnipGame `protobuf:"bytes,5,rep,name=GameList,proto3" json:"GameList,omitempty"` // 小游戏列表 - Multiply int32 `protobuf:"varint,6,opt,name=Multiply,proto3" json:"Multiply,omitempty"` // 倍数 + Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` // 活动id + Status int32 `protobuf:"varint,2,opt,name=Status,proto3" json:"Status,omitempty"` // 0 未开始 1 进行中 2 已结束 + EndTime int32 `protobuf:"varint,3,opt,name=EndTime,proto3" json:"EndTime,omitempty"` // 结束时间 + Template int32 `protobuf:"varint,4,opt,name=Template,proto3" json:"Template,omitempty"` // 模板 + GameList []*CatnipGame `protobuf:"bytes,5,rep,name=GameList,proto3" json:"GameList,omitempty"` // 小游戏列表 + Multiply int32 `protobuf:"varint,6,opt,name=Multiply,proto3" json:"Multiply,omitempty"` // 倍数 + FriendList []*CatnipInvite `protobuf:"bytes,7,rep,name=FriendList,proto3" json:"FriendList,omitempty"` // 好友列表 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -25949,17 +25950,22 @@ func (x *ResCatnip) GetMultiply() int32 { return 0 } +func (x *ResCatnip) GetFriendList() []*CatnipInvite { + if x != nil { + return x.FriendList + } + return nil +} + // 小游戏信息 type CatnipGame struct { state protoimpl.MessageState `protogen:"open.v1"` - Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` // 猫草id - Status int32 `protobuf:"varint,2,opt,name=Status,proto3" json:"Status,omitempty"` // 0 未开始 1 进行中 2 已结束 - Progress int32 `protobuf:"varint,3,opt,name=Progress,proto3" json:"Progress,omitempty"` // 进度 - Reward []int32 `protobuf:"varint,4,rep,packed,name=Reward,proto3" json:"Reward,omitempty"` // 已领取进度奖励列表 [100,150,200] - Partner *ResPlayerSimple `protobuf:"bytes,5,opt,name=Partner,proto3" json:"Partner,omitempty"` // 伙伴 - InviteList []*CatnipInvite `protobuf:"bytes,6,rep,name=InviteList,proto3" json:"InviteList,omitempty"` // 邀请列表 - BeInviteList []*CatnipInvite `protobuf:"bytes,7,rep,name=BeInviteList,proto3" json:"BeInviteList,omitempty"` // 被邀请列表 - Emoji int32 `protobuf:"varint,8,opt,name=Emoji,proto3" json:"Emoji,omitempty"` // 表情id + Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` // 猫草id + Status int32 `protobuf:"varint,2,opt,name=Status,proto3" json:"Status,omitempty"` // 0 未开始 1 进行中 2 已结束 + Progress int32 `protobuf:"varint,3,opt,name=Progress,proto3" json:"Progress,omitempty"` // 进度 + Reward []int32 `protobuf:"varint,4,rep,packed,name=Reward,proto3" json:"Reward,omitempty"` // 已领取进度奖励列表 [100,150,200] + Partner *ResPlayerSimple `protobuf:"bytes,5,opt,name=Partner,proto3" json:"Partner,omitempty"` // 伙伴 + Emoji int32 `protobuf:"varint,6,opt,name=Emoji,proto3" json:"Emoji,omitempty"` // 表情id unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -26029,20 +26035,6 @@ func (x *CatnipGame) GetPartner() *ResPlayerSimple { return nil } -func (x *CatnipGame) GetInviteList() []*CatnipInvite { - if x != nil { - return x.InviteList - } - return nil -} - -func (x *CatnipGame) GetBeInviteList() []*CatnipInvite { - if x != nil { - return x.BeInviteList - } - return nil -} - func (x *CatnipGame) GetEmoji() int32 { if x != nil { return x.Emoji @@ -26054,6 +26046,7 @@ type CatnipInvite struct { state protoimpl.MessageState `protogen:"open.v1"` Uid int64 `protobuf:"varint,1,opt,name=Uid,proto3" json:"Uid,omitempty"` // 好友id Time int64 `protobuf:"varint,2,opt,name=Time,proto3" json:"Time,omitempty"` // 邀请时间 + Type int32 `protobuf:"varint,3,opt,name=Type,proto3" json:"Type,omitempty"` // 状态 0 可以邀请,1 已邀请 2 同意 3 已满员 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -26102,6 +26095,13 @@ func (x *CatnipInvite) GetTime() int64 { return 0 } +func (x *CatnipInvite) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + // 邀请好友 type ReqCatnipInvite struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -29255,29 +29255,29 @@ const file_proto_Gameapi_proto_rawDesc = "" + "ResCollect\x12&\n" + "\x04Code\x18\x01 \x01(\x0e2\x12.tutorial.RES_CODER\x04Code\x12\x10\n" + "\x03Msg\x18\x02 \x01(\tR\x03Msg\"\v\n" + - "\tReqCatnip\"\xb7\x01\n" + + "\tReqCatnip\"\xef\x01\n" + "\tResCatnip\x12\x0e\n" + "\x02Id\x18\x01 \x01(\x05R\x02Id\x12\x16\n" + "\x06Status\x18\x02 \x01(\x05R\x06Status\x12\x18\n" + "\aEndTime\x18\x03 \x01(\x05R\aEndTime\x12\x1a\n" + "\bTemplate\x18\x04 \x01(\x05R\bTemplate\x120\n" + "\bGameList\x18\x05 \x03(\v2\x14.tutorial.CatnipGameR\bGameList\x12\x1a\n" + - "\bMultiply\x18\x06 \x01(\x05R\bMultiply\"\xa7\x02\n" + + "\bMultiply\x18\x06 \x01(\x05R\bMultiply\x126\n" + + "\n" + + "FriendList\x18\a \x03(\v2\x16.tutorial.CatnipInviteR\n" + + "FriendList\"\xb3\x01\n" + "\n" + "CatnipGame\x12\x0e\n" + "\x02Id\x18\x01 \x01(\x05R\x02Id\x12\x16\n" + "\x06Status\x18\x02 \x01(\x05R\x06Status\x12\x1a\n" + "\bProgress\x18\x03 \x01(\x05R\bProgress\x12\x16\n" + "\x06Reward\x18\x04 \x03(\x05R\x06Reward\x123\n" + - "\aPartner\x18\x05 \x01(\v2\x19.tutorial.ResPlayerSimpleR\aPartner\x126\n" + - "\n" + - "InviteList\x18\x06 \x03(\v2\x16.tutorial.CatnipInviteR\n" + - "InviteList\x12:\n" + - "\fBeInviteList\x18\a \x03(\v2\x16.tutorial.CatnipInviteR\fBeInviteList\x12\x14\n" + - "\x05Emoji\x18\b \x01(\x05R\x05Emoji\"4\n" + + "\aPartner\x18\x05 \x01(\v2\x19.tutorial.ResPlayerSimpleR\aPartner\x12\x14\n" + + "\x05Emoji\x18\x06 \x01(\x05R\x05Emoji\"H\n" + "\fCatnipInvite\x12\x10\n" + "\x03Uid\x18\x01 \x01(\x03R\x03Uid\x12\x12\n" + - "\x04Time\x18\x02 \x01(\x03R\x04Time\"3\n" + + "\x04Time\x18\x02 \x01(\x03R\x04Time\x12\x12\n" + + "\x04Type\x18\x03 \x01(\x05R\x04Type\"3\n" + "\x0fReqCatnipInvite\x12\x0e\n" + "\x02Id\x18\x01 \x01(\x05R\x02Id\x12\x10\n" + "\x03Uid\x18\x02 \x01(\x03R\x03Uid\"K\n" + @@ -30422,38 +30422,37 @@ var file_proto_Gameapi_proto_depIdxs = []int32{ 168, // 272: tutorial.CollectItem.Items:type_name -> tutorial.ItemInfo 2, // 273: tutorial.ResCollect.Code:type_name -> tutorial.RES_CODE 459, // 274: tutorial.ResCatnip.GameList:type_name -> tutorial.CatnipGame - 231, // 275: tutorial.CatnipGame.Partner:type_name -> tutorial.ResPlayerSimple - 460, // 276: tutorial.CatnipGame.InviteList:type_name -> tutorial.CatnipInvite - 460, // 277: tutorial.CatnipGame.BeInviteList:type_name -> tutorial.CatnipInvite - 2, // 278: tutorial.ResCatnipInvite.Code:type_name -> tutorial.RES_CODE - 2, // 279: tutorial.ResCatnipAgree.Code:type_name -> tutorial.RES_CODE - 2, // 280: tutorial.ResCatnipRefuse.Code:type_name -> tutorial.RES_CODE - 2, // 281: tutorial.ResCatnipMultiply.Code:type_name -> tutorial.RES_CODE - 2, // 282: tutorial.ResCatnipPlay.Code:type_name -> tutorial.RES_CODE - 2, // 283: tutorial.ResCatnipReward.Code:type_name -> tutorial.RES_CODE - 2, // 284: tutorial.ResCatnipGrandReward.Code:type_name -> tutorial.RES_CODE - 2, // 285: tutorial.ResCatnipEmoji.Code:type_name -> tutorial.RES_CODE - 171, // 286: tutorial.ResGuideTask.TaskEntry.value:type_name -> tutorial.GuideTask - 177, // 287: tutorial.ResDailyTask.WeekRewardEntry.value:type_name -> tutorial.DailyWeek - 178, // 288: tutorial.ResDailyTask.DailyTaskEntry.value:type_name -> tutorial.DailyTask - 214, // 289: tutorial.ResLimitEvent.LimitEventListEntry.value:type_name -> tutorial.LimitEvent - 231, // 290: tutorial.ResRank.RankListEntry.value:type_name -> tutorial.ResPlayerSimple - 283, // 291: tutorial.ResMailList.MailListEntry.value:type_name -> tutorial.MailInfo - 301, // 292: tutorial.ResCharge.SpecialShopEntry.value:type_name -> tutorial.ResSpecialShop - 302, // 293: tutorial.ResCharge.ChessShopEntry.value:type_name -> tutorial.ResChessShop - 293, // 294: tutorial.ResCharge.WeeklyDiscountEntry.value:type_name -> tutorial.WeeklyDiscountInfo - 313, // 295: tutorial.ResEndless.EndlessListEntry.value:type_name -> tutorial.ResEndlessInfo - 233, // 296: tutorial.ResChampshipRank.RankListEntry.value:type_name -> tutorial.ResPlayerRank - 233, // 297: tutorial.ResChampshipPreRank.RankListEntry.value:type_name -> tutorial.ResPlayerRank - 390, // 298: tutorial.ResPlayroom.DressEntry.value:type_name -> tutorial.PlayroomDress - 293, // 299: tutorial.ResPlayroom.WeeklyDiscountEntry.value:type_name -> tutorial.WeeklyDiscountInfo - 168, // 300: tutorial.ResPlayroomInfo.ItemsEntry.value:type_name -> tutorial.ItemInfo - 168, // 301: tutorial.ResPlayroomGame.ItemsEntry.value:type_name -> tutorial.ItemInfo - 302, // [302:302] is the sub-list for method output_type - 302, // [302:302] is the sub-list for method input_type - 302, // [302:302] is the sub-list for extension type_name - 302, // [302:302] is the sub-list for extension extendee - 0, // [0:302] is the sub-list for field type_name + 460, // 275: tutorial.ResCatnip.FriendList:type_name -> tutorial.CatnipInvite + 231, // 276: tutorial.CatnipGame.Partner:type_name -> tutorial.ResPlayerSimple + 2, // 277: tutorial.ResCatnipInvite.Code:type_name -> tutorial.RES_CODE + 2, // 278: tutorial.ResCatnipAgree.Code:type_name -> tutorial.RES_CODE + 2, // 279: tutorial.ResCatnipRefuse.Code:type_name -> tutorial.RES_CODE + 2, // 280: tutorial.ResCatnipMultiply.Code:type_name -> tutorial.RES_CODE + 2, // 281: tutorial.ResCatnipPlay.Code:type_name -> tutorial.RES_CODE + 2, // 282: tutorial.ResCatnipReward.Code:type_name -> tutorial.RES_CODE + 2, // 283: tutorial.ResCatnipGrandReward.Code:type_name -> tutorial.RES_CODE + 2, // 284: tutorial.ResCatnipEmoji.Code:type_name -> tutorial.RES_CODE + 171, // 285: tutorial.ResGuideTask.TaskEntry.value:type_name -> tutorial.GuideTask + 177, // 286: tutorial.ResDailyTask.WeekRewardEntry.value:type_name -> tutorial.DailyWeek + 178, // 287: tutorial.ResDailyTask.DailyTaskEntry.value:type_name -> tutorial.DailyTask + 214, // 288: tutorial.ResLimitEvent.LimitEventListEntry.value:type_name -> tutorial.LimitEvent + 231, // 289: tutorial.ResRank.RankListEntry.value:type_name -> tutorial.ResPlayerSimple + 283, // 290: tutorial.ResMailList.MailListEntry.value:type_name -> tutorial.MailInfo + 301, // 291: tutorial.ResCharge.SpecialShopEntry.value:type_name -> tutorial.ResSpecialShop + 302, // 292: tutorial.ResCharge.ChessShopEntry.value:type_name -> tutorial.ResChessShop + 293, // 293: tutorial.ResCharge.WeeklyDiscountEntry.value:type_name -> tutorial.WeeklyDiscountInfo + 313, // 294: tutorial.ResEndless.EndlessListEntry.value:type_name -> tutorial.ResEndlessInfo + 233, // 295: tutorial.ResChampshipRank.RankListEntry.value:type_name -> tutorial.ResPlayerRank + 233, // 296: tutorial.ResChampshipPreRank.RankListEntry.value:type_name -> tutorial.ResPlayerRank + 390, // 297: tutorial.ResPlayroom.DressEntry.value:type_name -> tutorial.PlayroomDress + 293, // 298: tutorial.ResPlayroom.WeeklyDiscountEntry.value:type_name -> tutorial.WeeklyDiscountInfo + 168, // 299: tutorial.ResPlayroomInfo.ItemsEntry.value:type_name -> tutorial.ItemInfo + 168, // 300: tutorial.ResPlayroomGame.ItemsEntry.value:type_name -> tutorial.ItemInfo + 301, // [301:301] is the sub-list for method output_type + 301, // [301:301] is the sub-list for method input_type + 301, // [301:301] is the sub-list for extension type_name + 301, // [301:301] is the sub-list for extension extendee + 0, // [0:301] is the sub-list for field type_name } func init() { file_proto_Gameapi_proto_init() }