From 01c8c04df6abb01afdd0801e843fd8b7890f4503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <12574910+72wo@users.noreply.github.com> Date: Sun, 1 Mar 2026 00:02:41 +0800 Subject: [PATCH] =?UTF-8?q?```=20refactor(fight):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84xmlres=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=E5=9B=9E=E8=A1=80=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除input包中未使用的xmlres导入,将宠物血量处理逻辑 封装到PetInfo模型中,并添加ModelHP方法来统一处理血量增减 逻辑。 feat(dict): 注释初始化数据相关代码 注释掉字典模块 --- logic/service/fight/input/fight.go | 25 +------- login/main.go | 51 ++++++++++------- .../resource/initjson/base_sys_param.json | 57 ------------------- modules/dict/dict.go | 7 +-- modules/dict/packed/packed.go | 9 --- modules/dict/resource/initjson/dict_info.json | 52 ----------------- modules/dict/resource/initjson/dict_type.json | 16 ------ modules/dict/service/dict_info.go | 7 +++ modules/player/model/pet.go | 30 ++++++++++ 9 files changed, 73 insertions(+), 181 deletions(-) delete mode 100644 modules/base/resource/initjson/base_sys_param.json delete mode 100644 modules/dict/packed/packed.go delete mode 100644 modules/dict/resource/initjson/dict_info.json delete mode 100644 modules/dict/resource/initjson/dict_type.json diff --git a/logic/service/fight/input/fight.go b/logic/service/fight/input/fight.go index f954d8755..f83b44907 100644 --- a/logic/service/fight/input/fight.go +++ b/logic/service/fight/input/fight.go @@ -2,7 +2,6 @@ package input import ( element "blazing/common/data/Element" - "blazing/common/data/xmlres" "blazing/common/utils" "blazing/logic/service/fight/action" @@ -55,32 +54,12 @@ func (our *Input) Heal(in *Input, ac action.BattleActionI, value alpacadecimal.D our.AttackValue.GainHp = int32(value.IntPart()) //道具有专门的回血包 } - if value.IsPositive() { - our.CurrentPet.Info.Hp += uint32(value.IntPart()) - - our.CurrentPet.Info.Hp = utils.Min(our.CurrentPet.Info.Hp, our.CurrentPet.Info.MaxHp) - } else { - if uint32(value.Abs().IntPart()) > our.CurrentPet.Info.Hp { - our.CurrentPet.Info.Hp = 0 - } else { - our.CurrentPet.Info.Hp += uint32(value.IntPart()) - - } - - } + our.CurrentPet.Info.ModelHP(value.IntPart()) } func (our *Input) HealPP(value int) { - for i := 0; i < len(our.CurrentPet.Info.SkillList); i++ { - if value == -1 { - our.CurrentPet.Info.SkillList[i].PP = uint32(xmlres.SkillMap[int(our.CurrentPet.Info.SkillList[i].ID)].MaxPP) - } else { - our.CurrentPet.Info.SkillList[i].PP += uint32(value) - our.CurrentPet.Info.SkillList[i].PP = utils.Min(our.CurrentPet.Info.SkillList[i].PP, uint32(xmlres.SkillMap[int(our.CurrentPet.Info.SkillList[i].ID)].MaxPP)) - } - - } + our.CurrentPet.Info.HealPP(value) } func (our *Input) DelPP(value int) { diff --git a/login/main.go b/login/main.go index 302aa80cc..571934d14 100644 --- a/login/main.go +++ b/login/main.go @@ -23,33 +23,46 @@ import ( "github.com/gogf/gf/v2/os/gctx" ) +// // 定义XML根节点结构体 +// type Root struct { +// XMLName xml.Name `xml:"root"` +// Items []Item `xml:"item"` // 匹配所有item子节点 +// } + +// // 定义Item节点结构体,映射所有属性 +// type Item struct { +// ID int `xml:"id,attr"` // 映射id属性 +// Level string `xml:"level,attr"` // 映射level属性 +// Color string `xml:"color,attr"` // 映射color属性 +// Des string `xml:"des,attr"` // 映射des属性 +// } + func init() { xmlres.Initfile() } func main() { - // superMaps := &xmlres.MonsterRoot{} - // err := xml.Unmarshal([]byte(gfile.GetBytes("help/地图配置野怪.xml")), superMaps) - // for _, v := range superMaps.Maps { + // // 初始化根结构体 + // var root Root - // if v.Monsters != nil { - // for _, v1 := range v.Bosses { - // if strings.Index(v1.Name, "SPT") != -1 { - // //fmt.Println(v.Name, v1) - // g.Dump(v.Name, v1) - // } - - // } - - // } - - // } - // fmt.Println(err) - // err := service.RemoteExecuteScript(ip, sshPort, user, password, scriptPort) + // // 解析XML字符串 + // err := xml.Unmarshal(gfile.GetBytes("public/assets/xmltip.xml"), &root) // if err != nil { - // log.Fatal(err) + // fmt.Printf("XML解析失败: %v\n", err) + // os.Exit(1) // } - // 调用方法 + + // // 遍历解析后的Item列表并输出 + // fmt.Println("解析结果:") + // for i, item := range root.Items { + // fmt.Printf("第%d个Item:\n", i+1) + // fmt.Printf(" ID: %s\n", item.ID) + // fmt.Printf(" Level: %s\n", item.Level) + // fmt.Printf(" Color: %s\n", item.Color) + // fmt.Printf(" 描述: %s\n\n", item.Des) + // service.NewDictInfoService().SetItemRemark(item.ID, item.Des) + // } + // userInfo, err := service.GetUserInfo("694425176@qq.com", "qq694425176") // if err != nil { // log.Fatal(err) diff --git a/modules/base/resource/initjson/base_sys_param.json b/modules/base/resource/initjson/base_sys_param.json deleted file mode 100644 index e0335a501..000000000 --- a/modules/base/resource/initjson/base_sys_param.json +++ /dev/null @@ -1,57 +0,0 @@ -[ - { - "id": 2, - "createTime": "2025-09-27 13:09:19.615082 +00:00", - "updateTime": "2025-09-27 13:09:19.615082 +00:00", - "deleted_at": null, - "keyName": "json", - "name": "JSON参数", - "data": "{\n code: 111\n}", - "dataType": 0, - "remark": null - }, - { - "id": 3, - "createTime": "2025-09-27 13:09:19.615082 +00:00", - "updateTime": "2025-09-27 13:09:19.615082 +00:00", - "deleted_at": "2025-07-24 01:58:08.256613 +00:00", - "keyName": "22222", - "name": "2222", - "data": "", - "dataType": 0, - "remark": null - }, - { - "id": 1, - "createTime": "2025-09-27 13:09:19.615082 +00:00", - "updateTime": "2025-09-27 13:09:19.615082 +00:00", - "deleted_at": null, - "keyName": "text", - "name": "富文本参数", - "data": "
111xxxxx2222
", - "dataType": 0, - "remark": null - }, - { - "id": 5, - "createTime": "2025-09-27 14:13:14.898259 +00:00", - "updateTime": "2025-09-27 14:13:14.898259 +00:00", - "deleted_at": null, - "keyName": "test_ip", - "name": "测试地址", - "data": "192.168.1.44", - "dataType": 0, - "remark": null - }, - { - "id": 4, - "createTime": "2025-09-27 14:12:43.000000 +00:00", - "updateTime": "2025-10-05 14:08:00.646162 +00:00", - "deleted_at": null, - "keyName": "server_ip", - "name": "后端地址", - "data": "api.seersun.com", - "dataType": 0, - "remark": null - } -] \ No newline at end of file diff --git a/modules/dict/dict.go b/modules/dict/dict.go index 37d18ad64..9c7a93ad1 100644 --- a/modules/dict/dict.go +++ b/modules/dict/dict.go @@ -3,12 +3,9 @@ package dict import ( "blazing/cool" - _ "blazing/modules/dict/packed" - "github.com/gogf/gf/v2/os/gctx" _ "blazing/modules/dict/controller" - "blazing/modules/dict/model" ) func init() { @@ -16,7 +13,7 @@ func init() { ctx = gctx.GetInitCtx() ) cool.Logger.Debug(ctx, "module dict init start ...") - cool.FillInitData(ctx, "dict", &model.DictInfo{}, nil) - cool.FillInitData(ctx, "dict", &model.DictType{}, nil) + // cool.FillInitData(ctx, "dict", &model.DictInfo{}, nil) + // cool.FillInitData(ctx, "dict", &model.DictType{}, nil) cool.Logger.Debug(ctx, "module dict init finished ...") } diff --git a/modules/dict/packed/packed.go b/modules/dict/packed/packed.go deleted file mode 100644 index f3d33dbe4..000000000 --- a/modules/dict/packed/packed.go +++ /dev/null @@ -1,9 +0,0 @@ -package packed - -import "github.com/gogf/gf/v2/os/gres" - -func init() { - if err := gres.Add("H4sIAAAAAAAC/wrwZmYRYeBgYGBgjRYNZUACcgycDLn5KaU5qcX6KZnJJfpFqcX5pUXJqfqZeZklWcX5eaEhrAyMt0WZkgO82TmQtcIM5WD4FYVqqC5BQ8HC8Zl5afl6cDtOijIlr7lk6H3EQOTAx73zH038qfdkr0r52ei5LB/FzAs1zA4/3DrtAp9Sn5/Sjp0dCs9VLH53iryP7ohrXbxNYEWy3H+VPw9k1RmmczI0RDxrYlS/fTjzQ+Tb/mmt4jxNIhdDzi7PYsuQCN4WtYxtatCit7O15N/JLp50btbcfftW/Pn3rj11295fP7f8q9jx9+w553eHE4M52LLcD4pHWgjzpG6O2rpZi3vfmvp7v+epMYRP5utRSvRbduvIoapfiTd+/fz7dR172+MEK7ZnEZkv5/S1Wrppn0ziyflccZn/8uMENSa3E2l6EzWE3I6YTF5RnXil9e7+nHX3/9WL5vL0SASvnNrd/vcle2J199GDP1x9/PYxMTD8/w8K7Bds/55wMjIw2LIgBzZ6DBIb2CWVBal6KBHa9SwoYMWzoICAgIBTPoGbggyuNBZM6g4S9g5yNioOnrpGZEoPT09PCe+ZUt4zIjy+a3h01/jwfNU5o8vLwzNlwStv7iCPoPnTOQJ/1jx+t1x2deKimyunKhycdKopRFWPtTVK1uS6pOBDK2Vn7eRk2+JibqXYdl/bM6X+6uZ27984FscGBSbFcd2ojNnYwADz8YJNgQ19DAwM9owwH4MAF5qPxXD6GOy1p+C0Ckvw6JpFcWlG0os9nWOaxYNmFhlGsCOMwKObkUmEGXf+hQABhreOIJro3AwzFJJ/kRObLtxQBoYljaEEDcWVm5HtADkcOXpR7TjEyEBmIobZgSuhwALnv+MWJgbCyQYR0tgSDsKwj7gMI8osHhSzbJkZcCUj3EawoxjRgDACSTcrG0QlO4M5EwPDPmYQDxAAAP//BVSc8gsGAAA="); err != nil { - panic("add binary content to resource manager failed: " + err.Error()) - } -} diff --git a/modules/dict/resource/initjson/dict_info.json b/modules/dict/resource/initjson/dict_info.json deleted file mode 100644 index 86bab95ea..000000000 --- a/modules/dict/resource/initjson/dict_info.json +++ /dev/null @@ -1,52 +0,0 @@ -[ - { - "id": 1, - "createTime": "2022-07-06 14:18:53.841000", - "updateTime": "2022-07-06 14:19:10.954000", - "typeId": 1, - "name": "衣服", - "ordernum": 2, - "remark": null, - "parentId": null - }, - { - "id": 2, - "createTime": "2022-07-06 14:18:59.834000", - "updateTime": "2022-07-06 14:18:59.834000", - "typeId": 1, - "name": "裤子", - "ordernum": 1, - "remark": null, - "parentId": null - }, - { - "id": 3, - "createTime": "2022-07-06 14:19:03.993000", - "updateTime": "2022-07-06 14:19:15.251000", - "typeId": 1, - "name": "鞋子", - "ordernum": 3, - "remark": null, - "parentId": null - }, - { - "id": 4, - "createTime": "2022-07-06 14:21:47.122000", - "updateTime": "2022-07-06 14:22:26.131000", - "typeId": 2, - "name": "闪酷", - "ordernum": 2, - "remark": null, - "parentId": null - }, - { - "id": 5, - "createTime": "2022-07-06 14:22:18.309000", - "updateTime": "2022-07-06 14:22:18.309000", - "typeId": 2, - "name": "SUN", - "ordernum": 1, - "remark": null, - "parentId": null - } -] \ No newline at end of file diff --git a/modules/dict/resource/initjson/dict_type.json b/modules/dict/resource/initjson/dict_type.json deleted file mode 100644 index 583ac0e2b..000000000 --- a/modules/dict/resource/initjson/dict_type.json +++ /dev/null @@ -1,16 +0,0 @@ -[ - { - "id": 1, - "createTime": "2022-07-06 14:18:41.879000", - "updateTime": "2022-07-06 14:18:41.879000", - "name": "类别", - "key": "type" - }, - { - "id": 2, - "createTime": "2022-07-06 14:21:33.778000", - "updateTime": "2022-07-06 14:21:33.778000", - "name": "品牌", - "key": "brand" - } -] \ No newline at end of file diff --git a/modules/dict/service/dict_info.go b/modules/dict/service/dict_info.go index b0225a919..8011270e4 100644 --- a/modules/dict/service/dict_info.go +++ b/modules/dict/service/dict_info.go @@ -120,6 +120,13 @@ func (s *DictInfoService) GetShiny() []int { return res.Array("value").Ints() +} +func (s *DictInfoService) SetItemRemark(id int, b string) { + //获取精灵的排序作为精灵的数组 + m := cool.DBM(s.Model) + + m.Where("typeId", 6).Where("value", id).Data("remark", b).Update() + } // ModifyAfter 修改后 diff --git a/modules/player/model/pet.go b/modules/player/model/pet.go index 6863b801c..2ca11900a 100644 --- a/modules/player/model/pet.go +++ b/modules/player/model/pet.go @@ -118,6 +118,36 @@ type PetInfo struct { ExtSkin []uint32 `struc:"skip"` //可用皮肤 } +func (pet *PetInfo) ModelHP(tt int64) { + if pet.Hp <= 0 { + if tt > int64(pet.Hp) { + pet.Hp = 0 + } else { + pet.Hp += uint32(tt) + + } + + } else { + pet.Hp += uint32(tt) + if pet.Hp > pet.MaxHp { + pet.Hp = pet.MaxHp + } + } + +} + +func (pet *PetInfo) HealPP(value int) { + for i := 0; i < len(pet.SkillList); i++ { + if value == -1 { + pet.SkillList[i].PP = uint32(xmlres.SkillMap[int(pet.SkillList[i].ID)].MaxPP) + } else { + pet.SkillList[i].PP += uint32(value) + pet.SkillList[i].PP = utils.Min(pet.SkillList[i].PP, uint32(xmlres.SkillMap[int(pet.SkillList[i].ID)].MaxPP)) + } + + } +} + // 定义常量,提升可维护性(避免魔法数字) const ( maxSingleEV uint32 = 255 // 单个EV最大值