From cedb02faf70d13b1d40405891fc455cfbafd0f0a Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Fri, 12 Dec 2025 19:10:09 +0000 Subject: [PATCH] =?UTF-8?q?```feat(item):=20=E6=96=B0=E5=A2=9E=E7=89=A9?= =?UTF-8?q?=E5=93=81=E5=87=BA=E5=94=AE=E4=BB=B7=E6=A0=BC=E5=B1=9E=E6=80=A7?= =?UTF-8?q?(SellPrice)=E5=B9=B6=E5=AE=9E=E7=8E=B0=E7=89=A9=E5=93=81?= =?UTF-8?q?=E5=87=BA=E5=94=AE=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=AE=A0=E7=89=A9=E9=9D=A2=E6=9D=BF=E8=AE=A1=E7=AE=97=E5=92=8C?= =?UTF-8?q?=E6=97=B6=E5=8C=BA=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91```?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/data/xmlres/item.go | 1 + .../{controller.go => Controller.go} | 0 .../controller/{EGG_GAME.go => action_egg.go} | 0 .../{active.go => active_xiyou_in1.go} | 0 logic/controller/gold_exp.go | 23 --------- logic/controller/item_sale.go | 21 ++++++++ .../{getserver.go => login_getserver.go} | 0 logic/controller/{login.go => login_main.go} | 18 ++----- logic/controller/map.go | 12 ++--- logic/controller/nono.go | 2 +- logic/controller/{ev.go => pet_ev.go} | 0 .../{PET_FUSION.go => pet_fusion.go} | 0 logic/controller/{pet.go => pet_info.go} | 1 + logic/controller/{user.go => user_action.go} | 26 ---------- .../{CreatePlayer.go => user_create.go} | 0 .../controller/{Friend.go => user_friend.go} | 0 logic/controller/user_info.go | 50 +++++++++++++++++++ logic/controller/{talk.go => user_talk.go} | 0 logic/controller/{task.go => user_task.go} | 0 logic/controller/walk.go | 6 +-- logic/service/item/pet.go | 8 +++ logic/service/maps/mapin.go | 23 --------- logic/service/maps/maplist.go | 11 ---- logic/service/maps/walk.go | 18 ------- logic/service/player/new.go | 3 ++ logic/service/player/pet.go | 1 + logic/service/space/fixboos.go | 2 +- logic/service/space/in_out.go | 11 ++-- logic/service/space/info.go | 41 +++++++++++++++ logic/service/{maps => space}/info/info.go | 0 logic/service/space/space.go | 11 ++-- logic/service/space/wer_boss.go | 2 +- modules/blazing/service/info.go | 9 ++-- modules/blazing/service/pet.go | 11 ++++ modules/blazing/service/task.go | 13 +++-- 35 files changed, 172 insertions(+), 152 deletions(-) rename logic/controller/{controller.go => Controller.go} (100%) rename logic/controller/{EGG_GAME.go => action_egg.go} (100%) rename logic/controller/{active.go => active_xiyou_in1.go} (100%) delete mode 100644 logic/controller/gold_exp.go create mode 100644 logic/controller/item_sale.go rename logic/controller/{getserver.go => login_getserver.go} (100%) rename logic/controller/{login.go => login_main.go} (78%) rename logic/controller/{ev.go => pet_ev.go} (100%) rename logic/controller/{PET_FUSION.go => pet_fusion.go} (100%) rename logic/controller/{pet.go => pet_info.go} (99%) rename logic/controller/{user.go => user_action.go} (77%) rename logic/controller/{CreatePlayer.go => user_create.go} (100%) rename logic/controller/{Friend.go => user_friend.go} (100%) create mode 100644 logic/controller/user_info.go rename logic/controller/{talk.go => user_talk.go} (100%) rename logic/controller/{task.go => user_task.go} (100%) delete mode 100644 logic/service/maps/mapin.go delete mode 100644 logic/service/maps/maplist.go delete mode 100644 logic/service/maps/walk.go create mode 100644 logic/service/space/info.go rename logic/service/{maps => space}/info/info.go (100%) diff --git a/common/data/xmlres/item.go b/common/data/xmlres/item.go index e327e2b51..3fabc9eec 100644 --- a/common/data/xmlres/item.go +++ b/common/data/xmlres/item.go @@ -46,6 +46,7 @@ type Item struct { DualEvTimes int `xml:"DualEvTimes,attr,omitempty"` // 双倍学习力次数(学习力双倍仪) YuanshenDegrade int `xml:"YuanshenDegrade,attr,omitempty"` // 融合精灵还原标识(融合精灵还原药剂) EvRemove int `xml:"EvRemove,attr,omitempty"` // 学习力遗忘类型(各类学习力遗忘剂) + SellPrice int `xml:"SellPrice,attr,omitempty"` // 出售价格(出售价格修正) //bShowPetBag int `xml:"bShowPetBag,attr,omitempty"` // 宠物背包显示标识(副融合精灵保留药剂等) Nature *string `xml:"Nature,attr"` // 指向int的指针,无值时为nil NatureSet *string `xml:"NatureSet,attr"` // 指向string的指针,无值时为nil diff --git a/logic/controller/controller.go b/logic/controller/Controller.go similarity index 100% rename from logic/controller/controller.go rename to logic/controller/Controller.go diff --git a/logic/controller/EGG_GAME.go b/logic/controller/action_egg.go similarity index 100% rename from logic/controller/EGG_GAME.go rename to logic/controller/action_egg.go diff --git a/logic/controller/active.go b/logic/controller/active_xiyou_in1.go similarity index 100% rename from logic/controller/active.go rename to logic/controller/active_xiyou_in1.go diff --git a/logic/controller/gold_exp.go b/logic/controller/gold_exp.go deleted file mode 100644 index aee562335..000000000 --- a/logic/controller/gold_exp.go +++ /dev/null @@ -1,23 +0,0 @@ -package controller - -import ( - "blazing/common/socket/errorcode" - "blazing/logic/service/item" - "blazing/logic/service/player" -) - -func (h Controller) PlayerGoldCount(data *item.GoldOnlineRemainInboundInfo, c *player.Player) (result *item.GoldOnlineRemainOutboundInfo, err errorcode.ErrorCode) { - - return &item.GoldOnlineRemainOutboundInfo{ - - GoldNumber: c.User.GetGold(uint(c.Info.UserID)), - Coin: c.Info.Coins, - }, 0 -} -func (h Controller) PlayerExp(data *item.ExpTotalRemainInboundInfo, c *player.Player) (result *item.ExpTotalRemainOutboundInfo, err errorcode.ErrorCode) { - - return &item.ExpTotalRemainOutboundInfo{ - - TotalExp: uint32(c.Info.ExpPool), - }, 0 -} diff --git a/logic/controller/item_sale.go b/logic/controller/item_sale.go new file mode 100644 index 000000000..205d96991 --- /dev/null +++ b/logic/controller/item_sale.go @@ -0,0 +1,21 @@ +package controller + +import ( + "blazing/common/data/xmlres" + "blazing/common/socket/errorcode" + "blazing/logic/service/fight" + "blazing/logic/service/item" + "blazing/logic/service/player" +) + +func (h Controller) ITEM_SALE(data *item.C2S_ITEM_SALE, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { + if c.Service.Item.CheakItem(data.ItemId) < data.Amount { + return nil, errorcode.ErrorCodes.ErrSystemError + } + + if xmlres.ItemsMAP[int(data.ItemId)].SellPrice != 0 { + c.Info.Coins += uint32(int64(data.Amount) * int64(xmlres.ItemsMAP[int(data.ItemId)].SellPrice)) + + } + return result, 0 +} diff --git a/logic/controller/getserver.go b/logic/controller/login_getserver.go similarity index 100% rename from logic/controller/getserver.go rename to logic/controller/login_getserver.go diff --git a/logic/controller/login.go b/logic/controller/login_main.go similarity index 78% rename from logic/controller/login.go rename to logic/controller/login_main.go index b9bce946e..afb195196 100644 --- a/logic/controller/login.go +++ b/logic/controller/login_main.go @@ -11,7 +11,6 @@ import ( "blazing/logic/service/player" "blazing/logic/service/space" - "blazing/modules/base/service" blservice "blazing/modules/blazing/service" "context" "time" @@ -19,16 +18,6 @@ import ( "github.com/panjf2000/gnet/v2" ) -func IsToday(t time.Time) bool { - // 获取当前时间 - now := time.Now() - - // 比较年、月、日是否相同 - return t.Year() == now.Year() && - t.Month() == now.Month() && - t.Day() == now.Day() -} - // 处理命令: 1001 func (h *Controller) Login(data *user.MAIN_LOGIN_IN, c gnet.Conn) (result *user.LoginMSInfo, err errorcode.ErrorCode) { //这个时候player应该是空的 tt := data.CheakSession() @@ -38,15 +27,13 @@ func (h *Controller) Login(data *user.MAIN_LOGIN_IN, c gnet.Conn) (result *user. return } - cool.Loger.Info(context.TODO(), "准备踢人") err1 := h.RPCClient.Kick(data.Head.UserID) //先踢人 if err1 != nil { fmt.Println("踢人失败", err) } - //player.KickPlayer(data.Head.UserID) + cool.Loger.Info(context.TODO(), "踢人请求完成,继续登录流程") - // <-time.After(time.Millisecond * 3000) share.ShareManager.SetUserOnline(data.Head.UserID, h.Port) //设置用户登录服务器 t := player.GetPlayer(c, data.Head.UserID) if t == nil { @@ -56,7 +43,7 @@ func (h *Controller) Login(data *user.MAIN_LOGIN_IN, c gnet.Conn) (result *user. return } t.Service = blservice.NewUserService(data.Head.UserID) - t.User = service.NewBaseSysUserService() + t.Info = t.Service.Info.Personself() if t.Info == nil { @@ -65,6 +52,7 @@ func (h *Controller) Login(data *user.MAIN_LOGIN_IN, c gnet.Conn) (result *user. } t.Info.UserID = data.Head.UserID t.Logintime = uint32(time.Now().Unix()) //保存时间戳 + t.CompleteLogin() //通知客户端登录成功 diff --git a/logic/controller/map.go b/logic/controller/map.go index 64fb1ff09..f7cbb4869 100644 --- a/logic/controller/map.go +++ b/logic/controller/map.go @@ -6,15 +6,15 @@ import ( "blazing/logic/service/fight" "blazing/logic/service/maphot" - "blazing/logic/service/maps" - "blazing/logic/service/maps/info" + "blazing/logic/service/space/info" + "blazing/logic/service/player" "blazing/logic/service/space" "github.com/jinzhu/copier" ) -func (h *Controller) MapEnter(data *maps.InInfo, c *player.Player) (result *info.OutInfo, err errorcode.ErrorCode) { //这个时候player应该是空的 +func (h *Controller) MapEnter(data *space.InInfo, c *player.Player) (result *info.OutInfo, err errorcode.ErrorCode) { //这个时候player应该是空的 c.Info.MapID = data.MapId //登录地图 c.GetSpace().User.Store(c.Info.UserID, c) //添加玩家 @@ -36,7 +36,7 @@ func (h Controller) MapHot(data *maphot.InInfo, c *player.Player) (result *mapho return } -func (h *Controller) MapLeave(data *maps.LeaveMapInboundInfo, c *player.Player) (result *info.LeaveMapOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的 +func (h *Controller) MapLeave(data *space.LeaveMapInboundInfo, c *player.Player) (result *info.LeaveMapOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的 //data.Broadcast(c.Info.MapID, info.LeaveMapOutboundInfo{UserID: c.Info.UserID}) //同步广播 result = &info.LeaveMapOutboundInfo{ @@ -49,7 +49,7 @@ func (h *Controller) MapLeave(data *maps.LeaveMapInboundInfo, c *player.Player) //c.Info.MapID = 0 // 重置当前地图 return } -func (h *Controller) MapList(data *maps.ListMapPlayerInboundInfo, c *player.Player) (result *info.ListMapPlayerOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的 +func (h *Controller) MapList(data *space.ListMapPlayerInboundInfo, c *player.Player) (result *info.ListMapPlayerOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的 atomic.StoreUint32(&c.Canmon, 2) result = &info.ListMapPlayerOutboundInfo{ @@ -58,7 +58,7 @@ func (h *Controller) MapList(data *maps.ListMapPlayerInboundInfo, c *player.Play return } -func (h *Controller) Attack_Boss(data *maps.AttackBossInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的 +func (h *Controller) Attack_Boss(data *space.AttackBossInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的 if atomic.LoadInt32(&c.GetSpace().MapBossInfo.Hp) > 0 { atomic.AddInt32(&c.GetSpace().MapBossInfo.Hp, -1) diff --git a/logic/controller/nono.go b/logic/controller/nono.go index a2f5a241f..46b8653be 100644 --- a/logic/controller/nono.go +++ b/logic/controller/nono.go @@ -8,7 +8,7 @@ import ( "github.com/jinzhu/copier" ) -// 处理命令: 105 + func (h *Controller) NonoFollowOrHome(data *nono.NonoFollowOrHomeInInfo, c *player.Player) (result *nono.NonoFollowOutInfo, err errorcode.ErrorCode) { //这个时候player应该是空的 c.Info.NONO.Flag = data.Flag result = &nono.NonoFollowOutInfo{ diff --git a/logic/controller/ev.go b/logic/controller/pet_ev.go similarity index 100% rename from logic/controller/ev.go rename to logic/controller/pet_ev.go diff --git a/logic/controller/PET_FUSION.go b/logic/controller/pet_fusion.go similarity index 100% rename from logic/controller/PET_FUSION.go rename to logic/controller/pet_fusion.go diff --git a/logic/controller/pet.go b/logic/controller/pet_info.go similarity index 99% rename from logic/controller/pet.go rename to logic/controller/pet_info.go index 19ecc13d1..c139163eb 100644 --- a/logic/controller/pet.go +++ b/logic/controller/pet_info.go @@ -237,6 +237,7 @@ func (h Controller) SetPetExp(data *pet.PetSetExpInboundInfo, c *player.Player) }, 0 } +//精灵图鉴 func (h Controller) PetBargeList(data *pet.PetBargeListInboundInfo, c *player.Player) (result *pet.PetBargeListOutboundInfo, err errorcode.ErrorCode) { return &pet.PetBargeListOutboundInfo{ diff --git a/logic/controller/user.go b/logic/controller/user_action.go similarity index 77% rename from logic/controller/user.go rename to logic/controller/user_action.go index 430697490..f773f79f1 100644 --- a/logic/controller/user.go +++ b/logic/controller/user_action.go @@ -8,34 +8,8 @@ import ( "blazing/logic/service/player" "blazing/logic/service/user" "blazing/modules/blazing/model" - - "github.com/jinzhu/copier" ) -// UserSimInfo 根据用户ID获取模拟用户信息 -// data: 包含用户ID的输入信息 -// c: 玩家对象 -// 返回: 模拟用户信息及错误码 -func (h Controller) UserSimInfo(data *user.SimUserInfoInboundInfo, c *player.Player) (result *user.SimUserInfoOutboundInfo, err errorcode.ErrorCode) { - ret := &user.SimUserInfoOutboundInfo{} - - copier.Copy(ret, c.Service.Info.Person(data.UserId)) - return ret, 0 -} - -// UserMoreInfo 获取用户的更多信息。 -// data: 包含用户ID的输入信息。 -// c: 当前玩家对象。 -// 返回: 包含用户更多信息的输出结果和错误码。 -func (h Controller) UserMoreInfo(data *user.MoreUserInfoInboundInfo, c *player.Player) (result *user.MoreUserInfoOutboundInfo, err errorcode.ErrorCode) { - ret := &user.MoreUserInfoOutboundInfo{} - info := c.Service.Info.Person(data.UserId) - copier.CopyWithOption(ret, info, copier.Option{IgnoreEmpty: true, DeepCopy: true}) - - //todo 待实现 - return ret, 0 -} - // 射击 func (h Controller) Aimat(data *user.AimatInboundInfo, c *player.Player) (result *user.AimatOutboundInfo, err errorcode.ErrorCode) { result = &user.AimatOutboundInfo{ diff --git a/logic/controller/CreatePlayer.go b/logic/controller/user_create.go similarity index 100% rename from logic/controller/CreatePlayer.go rename to logic/controller/user_create.go diff --git a/logic/controller/Friend.go b/logic/controller/user_friend.go similarity index 100% rename from logic/controller/Friend.go rename to logic/controller/user_friend.go diff --git a/logic/controller/user_info.go b/logic/controller/user_info.go new file mode 100644 index 000000000..4951c3389 --- /dev/null +++ b/logic/controller/user_info.go @@ -0,0 +1,50 @@ +package controller + +import ( + "blazing/common/socket/errorcode" + "blazing/logic/service/item" + "blazing/logic/service/player" + "blazing/logic/service/user" + + "github.com/jinzhu/copier" +) + +// UserSimInfo 根据用户ID获取模拟用户信息 +// data: 包含用户ID的输入信息 +// c: 玩家对象 +// 返回: 模拟用户信息及错误码 +func (h Controller) UserSimInfo(data *user.SimUserInfoInboundInfo, c *player.Player) (result *user.SimUserInfoOutboundInfo, err errorcode.ErrorCode) { + ret := &user.SimUserInfoOutboundInfo{} + + copier.Copy(ret, c.Service.Info.Person(data.UserId)) + return ret, 0 +} + +// UserMoreInfo 获取用户的更多信息。 +// data: 包含用户ID的输入信息。 +// c: 当前玩家对象。 +// 返回: 包含用户更多信息的输出结果和错误码。 +func (h Controller) UserMoreInfo(data *user.MoreUserInfoInboundInfo, c *player.Player) (result *user.MoreUserInfoOutboundInfo, err errorcode.ErrorCode) { + ret := &user.MoreUserInfoOutboundInfo{} + info := c.Service.Info.Person(data.UserId) + copier.CopyWithOption(ret, info, copier.Option{IgnoreEmpty: true, DeepCopy: true}) + + //todo 待实现 + return ret, 0 +} + +func (h Controller) PlayerGoldCount(data *item.GoldOnlineRemainInboundInfo, c *player.Player) (result *item.GoldOnlineRemainOutboundInfo, err errorcode.ErrorCode) { + + return &item.GoldOnlineRemainOutboundInfo{ + + GoldNumber: c.User.GetGold(uint(c.Info.UserID)), + Coin: c.Info.Coins, + }, 0 +} +func (h Controller) PlayerExp(data *item.ExpTotalRemainInboundInfo, c *player.Player) (result *item.ExpTotalRemainOutboundInfo, err errorcode.ErrorCode) { + + return &item.ExpTotalRemainOutboundInfo{ + + TotalExp: uint32(c.Info.ExpPool), + }, 0 +} diff --git a/logic/controller/talk.go b/logic/controller/user_talk.go similarity index 100% rename from logic/controller/talk.go rename to logic/controller/user_talk.go diff --git a/logic/controller/task.go b/logic/controller/user_task.go similarity index 100% rename from logic/controller/task.go rename to logic/controller/user_task.go diff --git a/logic/controller/walk.go b/logic/controller/walk.go index 1f1498850..64739c52b 100644 --- a/logic/controller/walk.go +++ b/logic/controller/walk.go @@ -2,12 +2,12 @@ package controller import ( "blazing/common/socket/errorcode" - "blazing/logic/service/maps" - "blazing/logic/service/maps/info" "blazing/logic/service/player" + "blazing/logic/service/space" + "blazing/logic/service/space/info" ) -func (h Controller) Walk(data *maps.WalkInInfo, c *player.Player) (result *info.WalkOutInfo, err errorcode.ErrorCode) { +func (h Controller) Walk(data *space.WalkInInfo, c *player.Player) (result *info.WalkOutInfo, err errorcode.ErrorCode) { result = &info.WalkOutInfo{ Flag: data.Flag, Point: data.Point, diff --git a/logic/service/item/pet.go b/logic/service/item/pet.go index 9b8eeaa52..b4059fcd7 100644 --- a/logic/service/item/pet.go +++ b/logic/service/item/pet.go @@ -37,3 +37,11 @@ type C2S_PET_RESET_NATURE struct { Nature uint32 // 目标性格值 ItemId uint32 // 消耗的物品ID } + +// C2S_ITEM_SALE 物品出售/兑换请求结构体(对应原 C# 结构体) +// 字段注释保持与原逻辑一致,字段名遵循 Go 命名规范(首字母大写以支持序列化/反序列化) +type C2S_ITEM_SALE struct { + Head common.TomeeHeader `cmd:"2602" struc:"skip"` + ItemId uint32 // 兑换的物品id + Amount uint32 // 兑换的数量 +} diff --git a/logic/service/maps/mapin.go b/logic/service/maps/mapin.go deleted file mode 100644 index 1aa60458e..000000000 --- a/logic/service/maps/mapin.go +++ /dev/null @@ -1,23 +0,0 @@ -package maps - -import ( - "blazing/logic/service/common" - "blazing/modules/blazing/model" -) - -type LeaveMapInboundInfo struct { - Head common.TomeeHeader `cmd:"2002" struc:"skip"` //切换地图 -} - -type InInfo struct { - Head common.TomeeHeader `cmd:"2001" struc:"skip"` //切换地图 - // 地图类型 - MapType uint32 - - MapId uint32 - // Point: 直接给坐标x,y - Point model.Pos `fieldDesc:"直接给坐标x,y"` - - // Reverse2: 暂定 占位字符2 - //Reverse2 string `struc:"[2]byte"` -} diff --git a/logic/service/maps/maplist.go b/logic/service/maps/maplist.go deleted file mode 100644 index d494d1890..000000000 --- a/logic/service/maps/maplist.go +++ /dev/null @@ -1,11 +0,0 @@ -package maps - -import "blazing/logic/service/common" - -type ListMapPlayerInboundInfo struct { - Head common.TomeeHeader `cmd:"2003" struc:"skip"` //切换地图 -} - -type AttackBossInboundInfo struct { - Head common.TomeeHeader `cmd:"2412" struc:"skip"` //切换地图 -} diff --git a/logic/service/maps/walk.go b/logic/service/maps/walk.go deleted file mode 100644 index d8782793d..000000000 --- a/logic/service/maps/walk.go +++ /dev/null @@ -1,18 +0,0 @@ -package maps - -import ( - "blazing/logic/service/common" - "blazing/modules/blazing/model" -) - -type WalkInInfo struct { - Head common.TomeeHeader `cmd:"2101" struc:"skip"` //走路包 - // Flag: 0为走,1为飞行模式,@UInt long - Flag uint32 - - // Point: 直接给坐标x,y - Point model.Pos `fieldDesc:"直接给坐标x,y"` - - PathLen uint32 `struc:"sizeof=Path" ` - Path string -} diff --git a/logic/service/player/new.go b/logic/service/player/new.go index 1629fc033..ab0a6adf3 100644 --- a/logic/service/player/new.go +++ b/logic/service/player/new.go @@ -3,6 +3,7 @@ package player import ( "blazing/cool" "blazing/logic/service/common" + "blazing/modules/base/service" "blazing/modules/blazing/model" "time" ) @@ -14,6 +15,8 @@ func NewPlayer(opts ...PlayerOption) *Player { HavePVPinfo: make([]common.PlayerI, 0), baseplayer: newbaseplayer(), } + + p.User = service.NewBaseSysUserService() p.monsters = generateThreeUniqueNumbers() p.Done = NewDone(p) //发布订阅事件 p.StopChan = cool.Cron.ScheduleFunc(10*time.Second, func() { diff --git a/logic/service/player/pet.go b/logic/service/player/pet.go index 6944729d0..f68d1bf70 100644 --- a/logic/service/player/pet.go +++ b/logic/service/player/pet.go @@ -41,6 +41,7 @@ func (p *Player) AddPetExp(petinfo *model.PetInfo, addExp uint32) { petinfo.CalculatePetPane(false) petinfo.Cure() + p.Info.PetMaxLevel = utils.Max(petinfo.Level, p.Info.PetMaxLevel) } // 处理技能学习 diff --git a/logic/service/space/fixboos.go b/logic/service/space/fixboos.go index 5e54deca2..e08704dfe 100644 --- a/logic/service/space/fixboos.go +++ b/logic/service/space/fixboos.go @@ -2,7 +2,7 @@ package space import ( "blazing/cool" - "blazing/logic/service/maps/info" + "blazing/logic/service/space/info" "sync/atomic" "time" diff --git a/logic/service/space/in_out.go b/logic/service/space/in_out.go index 4a6bfd1c2..db5741134 100644 --- a/logic/service/space/in_out.go +++ b/logic/service/space/in_out.go @@ -2,8 +2,9 @@ package space import ( "blazing/logic/service/common" - "blazing/logic/service/maps/info" - maps "blazing/logic/service/maps/info" + + "blazing/logic/service/space/info" + "sync/atomic" "github.com/jinzhu/copier" @@ -68,7 +69,7 @@ func (s *Space) EnterMap(c common.PlayerI) { } } -func (s *Space) GetInfo(c common.PlayerI) []maps.OutInfo { +func (s *Space) GetInfo(c common.PlayerI) []info.OutInfo { if atomic.LoadUint32(&s.TimeBoss.Flag) == 1 { defer c.SendPackCmd(2022, &s.TimeBoss) @@ -80,8 +81,8 @@ func (s *Space) GetInfo(c common.PlayerI) []maps.OutInfo { } defer c.SendPackCmd(50004, &info.S2C_50004{Id: uint32(s.Weather)}) //获取天气 - ret := make([]maps.OutInfo, 0) - s.UserInfo.Range(func(k uint32, v maps.OutInfo) (stop bool) { + ret := make([]info.OutInfo, 0) + s.UserInfo.Range(func(k uint32, v info.OutInfo) (stop bool) { ret = append(ret, v) return len(ret) > 30 }) diff --git a/logic/service/space/info.go b/logic/service/space/info.go new file mode 100644 index 000000000..39e4804fb --- /dev/null +++ b/logic/service/space/info.go @@ -0,0 +1,41 @@ +package space + +import ( + "blazing/logic/service/common" + "blazing/modules/blazing/model" +) + +type ListMapPlayerInboundInfo struct { + Head common.TomeeHeader `cmd:"2003" struc:"skip"` //切换地图 +} + +type AttackBossInboundInfo struct { + Head common.TomeeHeader `cmd:"2412" struc:"skip"` //切换地图 +} +type LeaveMapInboundInfo struct { + Head common.TomeeHeader `cmd:"2002" struc:"skip"` //切换地图 +} + +type InInfo struct { + Head common.TomeeHeader `cmd:"2001" struc:"skip"` //切换地图 + // 地图类型 + MapType uint32 + + MapId uint32 + // Point: 直接给坐标x,y + Point model.Pos `fieldDesc:"直接给坐标x,y"` + + // Reverse2: 暂定 占位字符2 + //Reverse2 string `struc:"[2]byte"` +} +type WalkInInfo struct { + Head common.TomeeHeader `cmd:"2101" struc:"skip"` //走路包 + // Flag: 0为走,1为飞行模式,@UInt long + Flag uint32 + + // Point: 直接给坐标x,y + Point model.Pos `fieldDesc:"直接给坐标x,y"` + + PathLen uint32 `struc:"sizeof=Path" ` + Path string +} diff --git a/logic/service/maps/info/info.go b/logic/service/space/info/info.go similarity index 100% rename from logic/service/maps/info/info.go rename to logic/service/space/info/info.go diff --git a/logic/service/space/space.go b/logic/service/space/space.go index 3bcb6454e..55cececd3 100644 --- a/logic/service/space/space.go +++ b/logic/service/space/space.go @@ -6,8 +6,7 @@ import ( "blazing/cool" "blazing/logic/service/common" - "blazing/logic/service/maps/info" - maps "blazing/logic/service/maps/info" + "blazing/logic/service/space/info" csmap "github.com/mhmtszr/concurrent-swiss-map" "github.com/tnnmigga/enum" @@ -23,7 +22,7 @@ var WeatherStatus = enum.New[struct { // Space 针对Player的并发安全map,键为uint32类型 type Space struct { User *csmap.CsMap[uint32, common.PlayerI] // 存储玩家数据的map,键为玩家ID - UserInfo *csmap.CsMap[uint32, maps.OutInfo] + UserInfo *csmap.CsMap[uint32, info.OutInfo] CanRefresh bool //是否能够刷怪 Super uint32 //SuperValue *int32 @@ -53,10 +52,10 @@ func NewSpace() *Space { // set the total capacity, every shard map has total capacity/shard count capacity. the default value is 0. // csmap.WithSize[string, int](1000), ), - UserInfo: csmap.New[uint32, maps.OutInfo]( + UserInfo: csmap.New[uint32, info.OutInfo]( // set the number of map shards. the default value is 32. - csmap.WithShardCount[uint32, maps.OutInfo](32), - csmap.WithCustomHasher[uint32, maps.OutInfo](func(key uint32) uint64 { + csmap.WithShardCount[uint32, info.OutInfo](32), + csmap.WithCustomHasher[uint32, info.OutInfo](func(key uint32) uint64 { return uint64(key) }), diff --git a/logic/service/space/wer_boss.go b/logic/service/space/wer_boss.go index db776adcc..76996cd1e 100644 --- a/logic/service/space/wer_boss.go +++ b/logic/service/space/wer_boss.go @@ -1,7 +1,7 @@ package space import ( - "blazing/logic/service/maps/info" + "blazing/logic/service/space/info" "sync/atomic" "time" diff --git a/modules/blazing/service/info.go b/modules/blazing/service/info.go index 6aa4d30e9..ef5f1477d 100644 --- a/modules/blazing/service/info.go +++ b/modules/blazing/service/info.go @@ -39,12 +39,7 @@ func (s *InfoService) Reg(nick string, color uint32) { //设置用户信息 t.Data = model.NewPlayerInfo() t.Data.Nick = nick - - // for i := 0; i < 80; i++ { //超NO芯片填充 - - // t.Data.NonoChipList[i] = 255 - // } - + t.Data.UserID = s.userid t.Data.Color = color t.Data.RegisterTime = uint32(time.Now().Unix()) //写入注册时间 @@ -76,6 +71,8 @@ func (s *InfoService) Personself() *model.PlayerInfo { if err != nil { return nil } + tt.Data.AllPetNumber = uint32(NewPetService(s.userid).PetCount(0)) + if !IsToday(tt.LastResetTime) { //判断是否是今天 //每天login时候检查重置时间,然后把电池,任务,挖矿重置 diff --git a/modules/blazing/service/pet.go b/modules/blazing/service/pet.go index 4e69a07a9..ba7c4bbcf 100644 --- a/modules/blazing/service/pet.go +++ b/modules/blazing/service/pet.go @@ -25,6 +25,17 @@ func (s *PetService) PetInfo(flag int) []model.PetEX { return tt +} +func (s *PetService) PetCount(flag int) int { + + ret, err := cool.DBM(s.Model).Where("player_id", s.userid).Where("free", flag).Count() + + if err != nil { + return 0 + } + + return ret + } func (s *PetService) PetInfo_One_exec(cachetime uint32, t func(*model.PetEX)) { diff --git a/modules/blazing/service/task.go b/modules/blazing/service/task.go index dad9586e1..a5c0ea477 100644 --- a/modules/blazing/service/task.go +++ b/modules/blazing/service/task.go @@ -59,15 +59,14 @@ func IsToday(t1 *gtime.Time) bool { if t1 == nil { return false } - t := t1.Time - // 获取当前时间 - now := time.Now() + // 统一转换为 UTC 时区 + tUTC := t1.Time.UTC() + // 截断 UTC 时间到当天 00:00:00 + nowUTC := time.Now().UTC().Truncate(24 * time.Hour) + tTrunc := tUTC.Truncate(24 * time.Hour) - // 比较年、月、日是否相同 - return t.Year() == now.Year() && - t.Month() == now.Month() && - t.Day() == now.Day() + return nowUTC.Equal(tTrunc) } type TaskService struct {