From 5c6f35b1da7d0f2331b7b36996fc390128450b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <1@72wo.cn> Date: Wed, 3 Sep 2025 02:09:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor(common):=20=E9=87=8D=E6=9E=84=E5=AE=A0?= =?UTF-8?q?=E7=89=A9=E7=9B=B8=E5=85=B3=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E5=92=8C=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 PetMM 结构体重命名为 PetInfo,更准确地反映其用途 - 更新了相关文件中的结构体引用和变量命名 - 优化了部分代码的格式和注释 --- common/data/xmlres/file.go | 4 ++-- common/data/xmlres/pet.go | 16 ++++++++-------- logic/service/fight/info/BattlePetEntity.go | 4 +++- logic/service/fight/info/BattleSkillEntity.go | 19 +++++++++---------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/common/data/xmlres/file.go b/common/data/xmlres/file.go index 243f842c..8b885d8a 100644 --- a/common/data/xmlres/file.go +++ b/common/data/xmlres/file.go @@ -31,7 +31,7 @@ var ( MonsterMap map[int]TMapConfig //Skill MovesTbl //技能配置 SkillMap map[int]Move - PetMAP map[int]PetMM //宠物配置 + PetMAP map[int]PetInfo //宠物配置 NatureRootMap map[int]NatureItem ) @@ -54,7 +54,7 @@ func initfile() { }) pet := getXml[Monsters](path + "226.xml") - PetMAP = utils.ToMap[PetMM, int](pet.Monsters, func(m PetMM) int { + PetMAP = utils.ToMap[PetInfo, int](pet.Monsters, func(m PetInfo) int { return m.ID }) diff --git a/common/data/xmlres/pet.go b/common/data/xmlres/pet.go index f88c688f..8a9aec5a 100644 --- a/common/data/xmlres/pet.go +++ b/common/data/xmlres/pet.go @@ -13,13 +13,13 @@ type LearnableMoves struct { Moves []PetMoves `xml:"Move"` } -// PetMM 表示一个怪物的信息 -type PetMM struct { +// PetInfo 表示一个怪物的信息 +type PetInfo struct { ID int `xml:"ID,attr"` - DefName string `xml:"DefName,attr"` - Type int `xml:"Type,attr"` - GrowthType int `xml:"GrowthType,attr"` - HP int `xml:"HP,attr"` + DefName string `xml:"DefName,attr"` //名字 + Type int `xml:"Type,attr"` //类型 + GrowthType int `xml:"GrowthType,attr"` //成长类型 + HP int `xml:"HP,attr"` //血量种族值 Atk int `xml:"Atk,attr"` Def int `xml:"Def,attr"` SpAtk int `xml:"SpAtk,attr"` @@ -45,6 +45,6 @@ type PetMM struct { // Monsters 表示所有怪物的集合 type Monsters struct { - XMLName xml.Name `xml:"Monsters"` - Monsters []PetMM `xml:"Monster"` + XMLName xml.Name `xml:"Monsters"` + Monsters []PetInfo `xml:"Monster"` } diff --git a/logic/service/fight/info/BattlePetEntity.go b/logic/service/fight/info/BattlePetEntity.go index f3632bb3..8358245a 100644 --- a/logic/service/fight/info/BattlePetEntity.go +++ b/logic/service/fight/info/BattlePetEntity.go @@ -2,6 +2,7 @@ package info import ( element "blazing/common/data/Element" + "blazing/common/data/xmlres" "blazing/modules/blazing/model" "context" "sync" @@ -41,7 +42,8 @@ func (a *Attribute) Value() int64 { } type BattlePetEntity struct { - model.PetInfo //通过偏移赋值 + xmlres.PetInfo + info model.PetInfo //通过偏移赋值 ctx context.Context Capturable bool // 是否可捕获 statusConditions sync.Map // key: StatusCondition, value: int (剩余回合) diff --git a/logic/service/fight/info/BattleSkillEntity.go b/logic/service/fight/info/BattleSkillEntity.go index c746951d..5e5f712b 100644 --- a/logic/service/fight/info/BattleSkillEntity.go +++ b/logic/service/fight/info/BattleSkillEntity.go @@ -36,16 +36,15 @@ var Category = enum.New[struct { // 战斗中可以修改技能实体值,比如是否暴击,是否必中等 type BattleSkillEntity struct { xmlres.Move - ctx context.Context - SideEffects []int - SideEffectArgs []int - PP int - InfinityPP bool - DamageZone map[EnumCategory]map[EnumsZoneType]map[EnumsZoneType][]float64 // 三维map 伤害类型-》增还是减-》加还是乘-》值 - isCritical bool //技能是否暴击 - isHIt bool //技能是否命中 - ATTACK_COUNT_ZONE int //攻击次数 - DamageValue decimal.Decimal // 伤害值 + ctx context.Context + SideEffects []int + SideEffectArgs []int + PP int + InfinityPP bool + DamageZone map[EnumCategory]map[EnumsZoneType]map[EnumsZoneType][]float64 // 三维map 伤害类型-》增还是减-》加还是乘-》值 + + ATTACK_COUNT_ZONE int //攻击次数 + DamageValue decimal.Decimal // 伤害值 // 技能类型属性 //SkillType EnumCategory // 技能类型(物理/特殊/状态)