This commit is contained in:
xinian
2026-04-05 07:30:55 +08:00
committed by cnb
parent 2ee0cbc094
commit 7ec6381cf1
3 changed files with 26 additions and 4 deletions

View File

@@ -101,7 +101,11 @@ func Initfile() {
})
PetMAP = utils.ToMap[PetInfo, int](getXml[Monsters](path+"226.xml").Monsters, func(m PetInfo) int {
pets := getXml[Monsters](path + "226.xml").Monsters
for i := range pets {
pets[i].YieldingEVValues = parseYieldingEV(pets[i].YieldingEV)
}
PetMAP = utils.ToMap[PetInfo, int](pets, func(m PetInfo) int {
return m.ID
})

View File

@@ -1,6 +1,11 @@
package xmlres
import "github.com/ECUST-XX/xml"
import (
"strconv"
"strings"
"github.com/ECUST-XX/xml"
)
// Move 表示怪物可学习的技能
type PetMoves struct {
@@ -45,6 +50,7 @@ type PetInfo struct {
Recycle int `xml:"Recycle,attr"` // 是否可回收
LearnableMoves LearnableMoves `xml:"LearnableMoves"` // 可学习的技能
NaturalEnemy string `xml:"NaturalEnemy,attr"` //天敌
YieldingEVValues []int64 `xml:"-"` // 预解析后的努力值奖励
}
func (basic *PetInfo) GetBasic() uint32 {
@@ -61,3 +67,16 @@ type Monsters struct {
XMLName xml.Name `xml:"Monsters"`
Monsters []PetInfo `xml:"Monster"`
}
func parseYieldingEV(raw string) []int64 {
values := make([]int64, 6)
parts := strings.Fields(raw)
for i := 0; i < len(parts) && i < len(values); i++ {
value, err := strconv.ParseInt(parts[i], 10, 64)
if err != nil {
continue
}
values[i] = value
}
return values
}