111
This commit is contained in:
@@ -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
|
||||
|
||||
})
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user