From ef325d3b49c7203397d049385cd5040f67e56903 Mon Sep 17 00:00:00 2001 From: hahwu <31872165+hahwu@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:56:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=A6=E6=A0=87?= =?UTF-8?q?=E8=B5=9Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/game/ChampshipMgr.go | 15 ++++++++------- src/server/game/GameLogic.go | 5 +++-- src/server/game/Player.go | 3 +++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/server/game/ChampshipMgr.go b/src/server/game/ChampshipMgr.go index cfd75874..52d97259 100644 --- a/src/server/game/ChampshipMgr.go +++ b/src/server/game/ChampshipMgr.go @@ -1,6 +1,7 @@ package game import ( + "math" "server/GoUtil" champshipCfg "server/conf/champship" randnameCfg "server/conf/randname" @@ -143,21 +144,21 @@ func (c *ChampshipMgr) ai(m *msg.Msg) (interface{}, error) { Notify := make(map[int]int) for e, r := range v { if r.Type == RANK_PLAYER_ROBOT { - AddScore := 0 + AddScore := 0.0 Robot := ChampshipData.Robot[r.Uid] if Robot == nil { continue } if Robot.Type == 2 && Robot.Time+60 < Now { - AddScore = int(Robot.PerScore) + AddScore = Robot.PerScore Robot.Time = Now } if Robot.Type == 3 && Robot.Time+1800 < Now { - AddScore = int(Robot.PerScore) + AddScore = Robot.PerScore Robot.Time = Now } - r.Score += float64(AddScore) + r.Score += AddScore } else { Notify[r.Uid] = e } @@ -692,12 +693,12 @@ func CreateRobot(M float64, GroupId int) *ChampshipRobot { Score := M / 10 PerScore := 0.0 if Type == 2 { - PerScore = (M / 10 * 0.34) / float64(GoUtil.NextZeroTimestampDuration()) / 60 + PerScore = math.Round((M/10*0.34)/(float64(GoUtil.NextZeroTimestampDuration())/60)*100) / 100 Score = M / 10 * 0.66 } if Type == 3 { - PerScore = (M / 10 * 0.34) / float64(GoUtil.NextZeroTimestampDuration()) / 1800 - Score = 0 + PerScore = math.Round((M/10*0.34)/(float64(GoUtil.NextZeroTimestampDuration())/1800)*100) / 100 + Score = 2 } return &ChampshipRobot{ diff --git a/src/server/game/GameLogic.go b/src/server/game/GameLogic.go index e7fe0241..f9d8178d 100644 --- a/src/server/game/GameLogic.go +++ b/src/server/game/GameLogic.go @@ -102,8 +102,9 @@ func (gl *GameLogic) ZeroFlush() { }) var a1 = []interface{}{gl.DailyTaskTimestamp} GoUtil.CallEvent(MergeConst.Notify_Daily_Renew, a1) - gl.RankMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新排行榜 - gl.VarMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新变量 + gl.RankMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新排行榜 + gl.ChampshipMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新锦标赛 + gl.VarMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新变量 gl.NotifyAll(MsgMod.MSG_ZERO_UPDATE) gl.CreateDailyLogFile() } diff --git a/src/server/game/Player.go b/src/server/game/Player.go index b7e8a544..16f4de98 100644 --- a/src/server/game/Player.go +++ b/src/server/game/Player.go @@ -691,6 +691,9 @@ func (p *Player) GetSimpleData(Uid int, simple *PlayerSimpleData) error { p.M_DwUin = int64(Uid) p.InitPlayerOnly() Base := p.GetPlayerBaseMod() + if Base == nil { + return errors.New("GetSimpleData failed") + } simple.Name = p.GetPlayerBaseMod().GetName() simple.Avatar = p.PlayMod.getAvatarMod().SetId simple.Face = p.PlayMod.getFaceMod().SetId From 61ad4fdab2a44906cf0518d511594f3b534ce578 Mon Sep 17 00:00:00 2001 From: hahwu <31872165+hahwu@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:10:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AE=9D=E7=AE=B1=E9=9B=A8=E6=94=B9?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/game/Player.go | 14 ++-- src/server/game/RegisterNetworkFunc.go | 95 ++++++++++++++------------ src/server/msg/Gameapi.pb.go | 29 ++++---- 3 files changed, 77 insertions(+), 61 deletions(-) diff --git a/src/server/game/Player.go b/src/server/game/Player.go index 16f4de98..8080ba23 100644 --- a/src/server/game/Player.go +++ b/src/server/game/Player.go @@ -47,7 +47,7 @@ type Player struct { agent gate.Agent lock sync.Mutex stopSignal chan bool - Msg map[string]PlayerMsg + Msg []PlayerMsg Trigger []*quest.Trigger MDispatr *timer.Dispatcher McronSave *cron.Cron @@ -113,16 +113,16 @@ func (p *Player) SendClientRes() { for _, v := range p.Msg { G_GameLogicPtr.PackResInfo(p.GetAgent(), v.F, v.B) } - p.Msg = make(map[string]PlayerMsg) + p.Msg = make([]PlayerMsg, 0) } func (p *Player) PushClientRes(m proto.Message) { key := GetStructName(m) buff, _ := proto.Marshal(m) - p.Msg[key] = PlayerMsg{ + p.Msg = append(p.Msg, PlayerMsg{ F: key, B: buff, - } + }) } func (p *Player) PushAndSendClienRes(m proto.Message) { @@ -173,14 +173,14 @@ func (p *Player) BackUp() *PlayerBackUp { func (p *Player) Recover(backUp *PlayerBackUp) { // p.GetPlayerBaseMod().Data = backUp.Data p.PlayMod.Recover(backUp) - p.Msg = make(map[string]PlayerMsg) + p.Msg = make([]PlayerMsg, 0) } func (p *Player) InitPlayer(UserName string) error { p.lock.Lock() defer p.lock.Unlock() p.msgChan = make(chan *MsgMod.Msg, 100) - p.Msg = make(map[string]PlayerMsg) + p.Msg = make([]PlayerMsg, 0) p.args = make(map[string]interface{}) p.timerList = make(map[string]*timer.Timer) p.MDispatr = timer.NewDispatcher(100) @@ -660,7 +660,7 @@ func (p *Player) LoginBackData() { func (p *Player) InitPlayerOnly() { p.lock.Lock() defer p.lock.Unlock() - p.Msg = make(map[string]PlayerMsg) + p.Msg = make([]PlayerMsg, 0) p.args = make(map[string]interface{}) p.timerList = make(map[string]*timer.Timer) p.MDispatr = timer.NewDispatcher(10) diff --git a/src/server/game/RegisterNetworkFunc.go b/src/server/game/RegisterNetworkFunc.go index 5de10248..86e0252a 100644 --- a/src/server/game/RegisterNetworkFunc.go +++ b/src/server/game/RegisterNetworkFunc.go @@ -186,6 +186,15 @@ func ReqRewardOrder(args []interface{}) error { Item1 := PlayroomMod.GetReward() Item = item.Merge(Item, Item1) } + + if !OrderMod.CheckSuperOrder() { + if LimitedTimeEventMod.RemoveSuperOrder() { + player.PushClientRes(&msg.LimitEventNotify{ + Id: limitedTimeEvent.EVENT_TYPE_SUPER_ORDER, + Type: limitedTimeEvent.EVENT_NOTIFY_TYPE_DEL, + }) + } + } if LimitedTimeEventMod.CheckExist(limitedTimeEvent.EVENT_TYPE_METEOR_SHOW) { //流星雨活动 AddItem := LimitedTimeEventMod.GetMeteorReward(mergeList) if len(AddItem) > 0 { @@ -196,48 +205,6 @@ func ReqRewardOrder(args []interface{}) error { } Item = item.Merge(Item, AddItem) } - if LimitedTimeEventMod.CheckExist(limitedTimeEvent.EVENT_TYPE_CHEST_RAIN) { //宝箱雨活动 - AddItem, CardLv, ProductLv, Jackpot := LimitedTimeEventMod.GetChestReward(mergeList) - ChestRainItems := make([]*item.Item, 0) - if len(AddItem) > 0 { - ChestRainItems = AddItem - } - JackpotId := 0 - if CardLv > 0 { - CardId := CardMod.RandCard(CardLv) - ItemId := cardCfg.GetItemIdByCardId(CardId) - ChestRainItems = []*item.Item{{Id: ItemId, Num: 1}} - } - if ProductLv > 0 { - Color := order.RandChessColor(ChessMod.GetOrderEmit()) - ChessId := mergeDataCfg.GetChessIdByLvAndColor(ProductLv, Color) - ChestRainItems = append(ChestRainItems, &item.Item{Id: ChessId, Num: 1}) - } - if Jackpot > 0 { - ProbList := limitedTimeEventCfg.GetSenceJackpotProb() - JackpotId = GoUtil.RandMap(ProbList) - ChestRainItems = limitedTimeEventCfg.GetSenceJackpotReward(JackpotId) - } - Item = item.Merge(Item, ChestRainItems) - if len(ChestRainItems) > 0 { - player.PushClientRes(&msg.ResChessRainReward{ - Items: item.ItemToMsg(ChestRainItems), - Id: int32(JackpotId), - }) - player.TeLog("time_limited_event_action", map[string]interface{}{ - "event_type": "chest_rain", - "item_list": ChestRainItems, - }) - } - } - if !OrderMod.CheckSuperOrder() { - if LimitedTimeEventMod.RemoveSuperOrder() { - player.PushClientRes(&msg.LimitEventNotify{ - Id: limitedTimeEvent.EVENT_TYPE_SUPER_ORDER, - Type: limitedTimeEvent.EVENT_NOTIFY_TYPE_DEL, - }) - } - } if err != nil { player.SendErrClienRes(&msg.ResRewardOrder{ Code: msg.RES_CODE_FAIL, @@ -263,6 +230,50 @@ func ReqRewardOrder(args []interface{}) error { }) return err } + + if LimitedTimeEventMod.CheckExist(limitedTimeEvent.EVENT_TYPE_CHEST_RAIN) { //宝箱雨活动 + AddItem, CardLv, ProductLv, Jackpot := LimitedTimeEventMod.GetChestReward(mergeList) + ChestRainItems := make([]*item.Item, 0) + if len(AddItem) > 0 { + ChestRainItems = AddItem + } + JackpotId := 0 + if CardLv > 0 { + CardId := CardMod.RandCard(CardLv) + ItemId := cardCfg.GetItemIdByCardId(CardId) + ChestRainItems = []*item.Item{{Id: ItemId, Num: 1}} + } + if ProductLv > 0 { + Color := order.RandChessColor(ChessMod.GetOrderEmit()) + ChessId := mergeDataCfg.GetChessIdByLvAndColor(ProductLv, Color) + ChestRainItems = append(ChestRainItems, &item.Item{Id: ChessId, Num: 1}) + } + if Jackpot > 0 { + ProbList := limitedTimeEventCfg.GetSenceJackpotProb() + JackpotId = GoUtil.RandMap(ProbList) + ChestRainItems = limitedTimeEventCfg.GetSenceJackpotReward(JackpotId) + } + player.args["ResItemPopId"] = JackpotId + err = player.HandleItem(ChestRainItems, msg.ITEM_POP_LABEL_LimitEventChestRain.String()) + if err != nil { + player.SendErrClienRes(&msg.ResRewardOrder{ + Code: msg.RES_CODE_FAIL, + Msg: err.Error(), + }) + return err + } + + if len(ChestRainItems) > 0 { + player.PushClientRes(&msg.ResChessRainReward{ + Items: item.ItemToMsg(ChestRainItems), + Id: int32(JackpotId), + }) + player.TeLog("time_limited_event_action", map[string]interface{}{ + "event_type": "chest_rain", + "item_list": ChestRainItems, + }) + } + } data := &PlayerChessData{} err = data.UpdateChessData(player, req.MChessData) if err != nil { diff --git a/src/server/msg/Gameapi.pb.go b/src/server/msg/Gameapi.pb.go index 248a44b6..48cf0e54 100644 --- a/src/server/msg/Gameapi.pb.go +++ b/src/server/msg/Gameapi.pb.go @@ -71,6 +71,7 @@ const ( ITEM_POP_LABEL_GM ITEM_POP_LABEL = 45 ITEM_POP_LABEL_Friendtreasure ITEM_POP_LABEL = 46 ITEM_POP_LABEL_CardHandbookReward ITEM_POP_LABEL = 47 // 卡牌图鉴奖励 + ITEM_POP_LABEL_LimitEventChestRain ITEM_POP_LABEL = 48 // 限时事件宝箱雨 ) // Enum value maps for ITEM_POP_LABEL. @@ -124,6 +125,7 @@ var ( 45: "GM", 46: "Friendtreasure", 47: "CardHandbookReward", + 48: "LimitEventChestRain", } ITEM_POP_LABEL_value = map[string]int32{ "Playroom": 0, @@ -174,6 +176,7 @@ var ( "GM": 45, "Friendtreasure": 46, "CardHandbookReward": 47, + "LimitEventChestRain": 48, } ) @@ -20037,7 +20040,7 @@ var file_Gameapi_proto_rawDesc = []byte{ 0x55, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x55, 0x69, 0x64, 0x22, 0x22, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x6e, - 0x66, 0x6f, 0x2a, 0x8d, 0x07, 0x0a, 0x0e, 0x49, 0x54, 0x45, 0x4d, 0x5f, 0x50, 0x4f, 0x50, 0x5f, + 0x66, 0x6f, 0x2a, 0xa6, 0x07, 0x0a, 0x0e, 0x49, 0x54, 0x45, 0x4d, 0x5f, 0x50, 0x4f, 0x50, 0x5f, 0x4c, 0x41, 0x42, 0x45, 0x4c, 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x79, 0x72, 0x6f, 0x6f, 0x6d, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x50, 0x69, 0x67, 0x67, 0x79, 0x42, 0x61, 0x6e, 0x6b, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x10, 0x02, 0x12, 0x0b, @@ -20094,17 +20097,19 @@ var file_Gameapi_proto_rawDesc = []byte{ 0x0a, 0x02, 0x47, 0x4d, 0x10, 0x2d, 0x12, 0x12, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x10, 0x2e, 0x12, 0x16, 0x0a, 0x12, 0x43, 0x61, 0x72, 0x64, 0x48, 0x61, 0x6e, 0x64, 0x62, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, - 0x10, 0x2f, 0x2a, 0x42, 0x0a, 0x0b, 0x48, 0x41, 0x4e, 0x44, 0x4c, 0x45, 0x5f, 0x54, 0x59, 0x50, - 0x45, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x44, 0x44, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x4f, - 0x4d, 0x50, 0x4f, 0x53, 0x45, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x42, 0x55, 0x59, 0x10, 0x02, - 0x12, 0x08, 0x0a, 0x04, 0x53, 0x45, 0x4c, 0x4c, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x52, 0x45, - 0x4d, 0x4f, 0x56, 0x45, 0x10, 0x04, 0x2a, 0x21, 0x0a, 0x08, 0x52, 0x45, 0x53, 0x5f, 0x43, 0x4f, - 0x44, 0x45, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x41, 0x49, 0x4c, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, - 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x01, 0x2a, 0x2e, 0x0a, 0x09, 0x49, 0x54, 0x45, - 0x4d, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x12, 0x0a, 0x0a, 0x06, 0x45, 0x4e, 0x45, 0x52, 0x47, 0x59, - 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x54, 0x41, 0x52, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, - 0x44, 0x49, 0x41, 0x4d, 0x4f, 0x4e, 0x44, 0x10, 0x02, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2e, 0x2f, - 0x6d, 0x73, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x10, 0x2f, 0x12, 0x17, 0x0a, 0x13, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x43, 0x68, 0x65, 0x73, 0x74, 0x52, 0x61, 0x69, 0x6e, 0x10, 0x30, 0x2a, 0x42, 0x0a, 0x0b, 0x48, + 0x41, 0x4e, 0x44, 0x4c, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x44, + 0x44, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x4f, 0x4d, 0x50, 0x4f, 0x53, 0x45, 0x10, 0x01, + 0x12, 0x07, 0x0a, 0x03, 0x42, 0x55, 0x59, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x45, 0x4c, + 0x4c, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x52, 0x45, 0x4d, 0x4f, 0x56, 0x45, 0x10, 0x04, 0x2a, + 0x21, 0x0a, 0x08, 0x52, 0x45, 0x53, 0x5f, 0x43, 0x4f, 0x44, 0x45, 0x12, 0x08, 0x0a, 0x04, 0x46, + 0x41, 0x49, 0x4c, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, + 0x10, 0x01, 0x2a, 0x2e, 0x0a, 0x09, 0x49, 0x54, 0x45, 0x4d, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x12, + 0x0a, 0x0a, 0x06, 0x45, 0x4e, 0x45, 0x52, 0x47, 0x59, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x53, + 0x54, 0x41, 0x52, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x49, 0x41, 0x4d, 0x4f, 0x4e, 0x44, + 0x10, 0x02, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2e, 0x2f, 0x6d, 0x73, 0x67, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var (