```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

refactor(fight): 移除未使用的xmlres导入并优化回血逻辑

移除input包中未使用的xmlres导入,将宠物血量处理逻辑
封装到PetInfo模型中,并添加ModelHP方法来统一处理血量增减
逻辑。

feat(dict): 注释初始化数据相关代码

注释掉字典模块
This commit is contained in:
昔念
2026-03-01 00:02:41 +08:00
parent 24f83c0284
commit 01c8c04df6
9 changed files with 73 additions and 181 deletions

View File

@@ -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) {

View File

@@ -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)

View File

@@ -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": "<p><strong>111xxxxx2222 </strong></p>",
"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
}
]

View File

@@ -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 ...")
}

View File

@@ -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())
}
}

View File

@@ -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
}
]

View File

@@ -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"
}
]

View File

@@ -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 修改后

View File

@@ -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最大值