refactor(fight): 重构战斗系统

- 优化了技能解析和存储逻辑
- 重构了战斗流程和回合结算机制
- 调整了数据结构以提高性能
- 移除了未使用的代码和注释
This commit is contained in:
2025-09-04 23:57:22 +08:00
parent 51407864b7
commit 7d48e9ab64
17 changed files with 224 additions and 377 deletions

View File

@@ -5,9 +5,28 @@ import (
"fmt"
"io"
"net/http"
"strconv"
"strings"
"time"
)
func parseSideEffectArgs(argsStr string) []int {
if argsStr == "" {
return []int{}
}
parts := strings.Fields(argsStr)
args := make([]int, 0, len(parts))
for _, part := range parts {
if num, err := strconv.Atoi(part); err == nil {
args = append(args, num)
}
}
return args
}
// MovesTbl 定义 XML 根元素
type MovesTbl struct {
XMLName xml.Name `xml:"MovesTbl"`
@@ -43,15 +62,18 @@ type Move struct {
PwrBindDv int `xml:"PwrBindDv,attr,omitempty"` //威力power取决于自身的潜力个体值
PwrDouble int `xml:"PwrDouble,attr,omitempty"` //攻击时,若对方处于异常状态, 则威力翻倍;
SideEffect string `xml:"SideEffect,attr,omitempty"`
SideEffectArg string `xml:"SideEffectArg,attr,omitempty"`
AtkNum int `xml:"AtkNum,attr,omitempty"`
Url string `xml:"Url,attr,omitempty"`
SideEffect string `xml:"SideEffect,attr,omitempty"`
SideEffectArg string `xml:"SideEffectArg,attr,omitempty"`
SideEffectS []int
SideEffectArgS []int
AtkNum int `xml:"AtkNum,attr,omitempty"`
Url string `xml:"Url,attr,omitempty"`
Info string `xml:"info,attr,omitempty"`
CD int `xml:"CD,attr"`
}
type SideEffect struct {
ID int `xml:"ID,attr"`
Help string `xml:"help,attr"`