From 7005c1047f263bbfc0c5c8714366ce878b5d9f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <1@72wo.cn> Date: Mon, 8 Dec 2025 00:17:04 +0800 Subject: [PATCH] =?UTF-8?q?```=20feat(fight=5Fboss):=20=E6=9B=B4=E6=96=B0B?= =?UTF-8?q?OSS=E6=88=98=E6=96=97=E6=95=88=E6=9E=9C=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BB=A5=E4=BD=BF=E7=94=A8=E6=96=B0=E7=9A=84=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将原来直接访问xmlres.EffectMAP获取效果信息的方式, 替换为通过service.NewEffectService().Args方法获取EID与参数, 提高代码解耦性与可维护性。 refactor(item_buy): 调整金币商品购买时的价格计算逻辑 修复购买金币商品时价格未正确乘以100的问题, 确保消耗金币数量准确无 --- logic/controller/EGG_GAME.go | 17 +++++++++ logic/controller/fight_boss.go | 9 +++-- logic/controller/item_buy.go | 2 +- logic/controller/map.go | 5 ++- logic/service/egg/egg.go | 24 +++++++++++++ logic/service/fight/input/effect.go | 13 +++++++ logic/service/player/save.go | 2 +- modules/blazing/controller/admin/effec.go | 39 ++++++++++++++++++++ modules/blazing/model/effect.go | 43 +++++++++++++++++++++++ modules/blazing/service/effect.go | 40 +++++++++++++++++++++ public/config/30001.xml | 2 +- public/config/地图配置野怪.xml | 6 ++-- 12 files changed, 190 insertions(+), 12 deletions(-) create mode 100644 logic/controller/EGG_GAME.go create mode 100644 logic/service/egg/egg.go create mode 100644 modules/blazing/controller/admin/effec.go create mode 100644 modules/blazing/model/effect.go create mode 100644 modules/blazing/service/effect.go diff --git a/logic/controller/EGG_GAME.go b/logic/controller/EGG_GAME.go new file mode 100644 index 00000000..75852103 --- /dev/null +++ b/logic/controller/EGG_GAME.go @@ -0,0 +1,17 @@ +package controller + +import ( + "blazing/common/socket/errorcode" + "blazing/logic/service/egg" + "blazing/logic/service/player" + "blazing/modules/blazing/model" +) + +func (h Controller) EGG(data *egg.C2S_EGG_GAME_PLAY, c *player.Player) (result *egg.S2C_EGG_GAME_PLAY, err errorcode.ErrorCode) { + r := model.GenPetInfo(1, -1, -1, -1, 0, 1) + c.Service.Pet.PetAdd(r) + result = &egg.S2C_EGG_GAME_PLAY{HadTime: r.CatchTime, ListInfo: []model.ItemInfo{}, PetID: r.ID} + + return + +} diff --git a/logic/controller/fight_boss.go b/logic/controller/fight_boss.go index 6e8e7abe..e1163249 100644 --- a/logic/controller/fight_boss.go +++ b/logic/controller/fight_boss.go @@ -10,6 +10,7 @@ import ( "blazing/logic/service/player" "blazing/modules/blazing/model" + "blazing/modules/blazing/service" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/grand" @@ -88,11 +89,13 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *pla for _, v := range strings.Split(bm.NewSeIdxs, " ") { idx := gconv.Uint16(v) - eff := xmlres.EffectMAP[int(idx)] - args := strings.Split(eff.Args, " ") + // eff := xmlres.EffectMAP[int(idx)] + // args := strings.Split(eff.Args, " ") + + EID, args := service.NewEffectService().Args(uint32(idx)) mo.EffectInfo = append(mo.EffectInfo, model.PetEffectInfo{ Idx: idx, - EID: gconv.Uint16(eff.Eid), + EID: gconv.Uint16(EID), Args: gconv.Ints(args), }) } diff --git a/logic/controller/item_buy.go b/logic/controller/item_buy.go index 18f47d2f..18d2f076 100644 --- a/logic/controller/item_buy.go +++ b/logic/controller/item_buy.go @@ -58,7 +58,7 @@ func (h Controller) BuyMItem(data *item.BuyMultiInboundInfo, c *player.Player) ( func (h Controller) BuyGoldItem(data *item.C2S_GOLD_BUY_PRODUCT, c *player.Player) (result *item.S2C_GoldBuyProductInfo, err errorcode.ErrorCode) { r := xmlres.GoldProductMap[int(data.ProductID)] - if !c.UseGold(uint32(data.Count) * uint32(gconv.Uint32(r.Price))) { + if !c.UseGold(uint32(data.Count) * uint32(gconv.Uint32(r.Price)*100)) { return nil, errorcode.ErrorCodes.ErrSystemError } r1 := c.ItemAdd(model.ItemInfo{ItemId: uint32(gconv.Uint32(r.ItemID)), ItemCnt: uint32(data.Count)}) diff --git a/logic/controller/map.go b/logic/controller/map.go index 97791a72..49671d7c 100644 --- a/logic/controller/map.go +++ b/logic/controller/map.go @@ -17,11 +17,11 @@ func (h *Controller) MapEnter(data *maps.InInfo, c *player.Player) (result *info c.Info.MapID = data.MapId //登录地图 c.GetSpace().User.Store(c.Info.UserID, c) //添加玩家 - + println("进入地图", c.Info.UserID, c.Info.MapID) result = info.NewOutInfo() c.Info.Pos = data.Point copier.Copy(result, c.Info) - + atomic.StoreUint32(&c.Canmon, 2) defer c.GetSpace().EnterMap(c) // go func() { @@ -72,7 +72,6 @@ func (h *Controller) MapList(data *maps.ListMapPlayerInboundInfo, c *player.Play result = &info.ListMapPlayerOutboundInfo{ Player: c.GetSpace().GetInfo(), } - atomic.StoreUint32(&c.Canmon, 2) return } diff --git a/logic/service/egg/egg.go b/logic/service/egg/egg.go new file mode 100644 index 00000000..8d5a5393 --- /dev/null +++ b/logic/service/egg/egg.go @@ -0,0 +1,24 @@ +package egg + +import ( + "blazing/logic/service/common" + "blazing/modules/blazing/model" +) + +// C2S_EGG_GAME_PLAY 前端向后端发送的抽蛋请求结构体 +// 对应原 C# 的 C2S_EGG_GAME_PLAY +type C2S_EGG_GAME_PLAY struct { + Head common.TomeeHeader `cmd:"3201" struc:"skip"` + EggNum uint32 `json:"eggNum"` // 抽蛋次数标识:1 = 1次 2 = 5次 3 = 10次 + // 注:Go 中 uint 是平台相关类型(32/64位),游戏开发中推荐用 uint32 明确匹配 C# 的 uint +} + +// S2C_EGG_GAME_PLAY 后端向前端返回的抽蛋结果结构体 +// 对应原 C# 的 S2C_EGG_GAME_PLAY +type S2C_EGG_GAME_PLAY struct { + GiftIN uint32 `json:"giftIN"` // 未知字段 写0 未引用 + PetID uint32 `json:"petID"` // 抽中精灵的id + HadTime uint32 `json:"hadTime"` // 抽中精灵的捕捉时间(若为时间戳,建议改为 uint64) + ListInfoLen uint32 `struc:"sizeof=ListInfo"` + ListInfo []model.ItemInfo `json:"listinfo"` // 抽中物品的物品数组 +} diff --git a/logic/service/fight/input/effect.go b/logic/service/fight/input/effect.go index 85e6a40e..5fcb769b 100644 --- a/logic/service/fight/input/effect.go +++ b/logic/service/fight/input/effect.go @@ -35,6 +35,19 @@ func InitEffect(etype EnumEffectType, id int, t Effect) { NodeM[pr.EffectID()] = t } +func GeteffectIDs(etype EnumEffectType) []uint32 { + + var ret []uint32 = make([]uint32, 0) + for _, v := range NodeM { + if v.ID().GetEffectType() == etype { + + ret = append(ret, uint32(v.ID().Suffix())) + + } + + } + return ret +} // 这里的catchtime为0,取出来之后如果是魂印,要重新赋值 func Geteffect[T int | byte | uint16](etype EnumEffectType, id T) Effect { diff --git a/logic/service/player/save.go b/logic/service/player/save.go index 4b9172eb..33259f9c 100644 --- a/logic/service/player/save.go +++ b/logic/service/player/save.go @@ -66,7 +66,7 @@ func (p *Player) CanGetExp() bool { // CompleteLogin 标记登录完成并通知等待者 func (lw *Player) CompleteLogin() { - if lw.Info.MapID > 500 || lw.Info.MapID == 0 { //如果位于基地,就重置到传送仓 + if lw.Info.MapID > 300 || lw.Info.MapID == 0 { //如果位于基地,就重置到传送仓 lw.Info.MapID = 1 } diff --git a/modules/blazing/controller/admin/effec.go b/modules/blazing/controller/admin/effec.go new file mode 100644 index 00000000..b4e39455 --- /dev/null +++ b/modules/blazing/controller/admin/effec.go @@ -0,0 +1,39 @@ +package admin + +import ( + "blazing/cool" + _ "blazing/logic/service/fight/boss" + "blazing/logic/service/fight/input" + "blazing/modules/blazing/service" + "context" + + "github.com/gogf/gf/v2/frame/g" +) + +type EffectController struct { + *cool.Controller +} + +func init() { + var task_info_controller = &EffectController{ + &cool.Controller{ + Prefix: "/admin/monster/effect", + Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"}, + Service: service.NewEffectService(), + }, + } + // 注册路由 + cool.RegisterController(task_info_controller) +} + +type EffIDReq struct { + g.Meta `path:"/effid" method:"GET"` +} + +func (c *EffectController) GetSession(ctx context.Context, req *EffIDReq) (res *cool.BaseRes, err error) { + res = &cool.BaseRes{} + res.Data = input.GeteffectIDs(input.EffectType.NewSel) + + return + +} diff --git a/modules/blazing/model/effect.go b/modules/blazing/model/effect.go new file mode 100644 index 00000000..9f1366d8 --- /dev/null +++ b/modules/blazing/model/effect.go @@ -0,0 +1,43 @@ +package model + +import ( + "blazing/cool" +) + +// 表名常量(遵循现有命名规范) +const TableNamePlayerPetSpecialEffect = "player_pet_special_effect" + +// PlayerPetSpecialEffect 精灵特效表(仅包含XML中指定的4个核心字段) +// 对应XML中的节点:Idx、Stat、Eid、Args +type PlayerPetSpecialEffect struct { + *cool.Model // 嵌入基础Model(包含主键、创建/更新时间等通用字段) + + // 严格对应XML的4个核心字段 + SeIdx uint32 `gorm:"not null;uniqueIndex:idx_se_idx;comment:'精灵特效索引(XML中的Idx)'" json:"se_idx"` + //Stat uint32 `gorm:"not null;default:0;comment:'精灵特效状态(XML中的Stat)'" json:"stat"` + Eid uint32 `gorm:"not null;index:idx_eid;comment:'精灵特效Eid(XML中的Eid)'" json:"eid"` + Args []int `gorm:"type:json;comment:'精灵特效参数(XML中的Args)'" json:"args"` + Desc string `gorm:"type:varchar(255);default:'';comment:'精灵特效描述(XML中的Desc)'" json:"desc"` +} + +// TableName 指定表名(遵循现有规范) +func (*PlayerPetSpecialEffect) TableName() string { + return TableNamePlayerPetSpecialEffect +} + +// GroupName 指定表分组(默认分组,与现有Item表一致) +func (*PlayerPetSpecialEffect) GroupName() string { + return "default" +} + +// NewPlayerPetSpecialEffect 创建精灵特效表实例(初始化基础Model) +func NewPlayerPetSpecialEffect() *PlayerPetSpecialEffect { + return &PlayerPetSpecialEffect{ + Model: cool.NewModel(), + } +} + +// init 程序启动时自动创建表(与现有Item表的初始化逻辑一致) +func init() { + cool.CreateTable(&PlayerPetSpecialEffect{}) +} diff --git a/modules/blazing/service/effect.go b/modules/blazing/service/effect.go new file mode 100644 index 00000000..214f6729 --- /dev/null +++ b/modules/blazing/service/effect.go @@ -0,0 +1,40 @@ +package service + +import ( + "blazing/cool" + "blazing/modules/blazing/model" +) + +type EffectService struct { + *cool.Service +} + +func (s *EffectService) Args(id uint32) (int, []int) { + + m := cool.DBM(s.Model).Where("se_idx", id) + var tt model.PlayerPetSpecialEffect + err := m.Scan(&tt) + if err != nil { + return 0, nil + } + + ret := tt.Args + + return int(tt.Eid), ret + +} +func NewEffectService() *EffectService { + return &EffectService{ + &cool.Service{ + // PageQueryOp: &cool.QueryOp{ + // ModifyResult: func(ctx g.Ctx, data interface{}) interface{} { + + // // t, _ := json.Marshal(data) + // // gjson.GetBytes(t, "list") + // return data + // }, + // }, + Model: model.NewPlayerPetSpecialEffect(), + }, + } +} diff --git a/public/config/30001.xml b/public/config/30001.xml index f5bbc53a..378fc171 120000 --- a/public/config/30001.xml +++ b/public/config/30001.xml @@ -1 +1 @@ -E:/newcode/flash/out/resource/xml/30001.xml \ No newline at end of file +E:/newcode/flash/out/dll/30001.xml \ No newline at end of file diff --git a/public/config/地图配置野怪.xml b/public/config/地图配置野怪.xml index d3f853eb..49872124 100644 --- a/public/config/地图配置野怪.xml +++ b/public/config/地图配置野怪.xml @@ -3442,11 +3442,11 @@ eg: - + - +