feat(xmlres): 使用rawFlexibleString替换字符串类型以支持灵活解析 - 将EffectArg结构体中的SideEffectArg字段类型从string改为rawFlexibleString - 将Move结构体中的Name字段类型从string改为rawFlexibleString,并更新反序列化逻辑 - 统一配置文件解析方式,移除磁盘回退机制并简化readConfigContent函数 - 移除不再使用的导入包和变量 fix(fight): 修复战斗系统中的空技能和无效数据问题 - 在
This commit is contained in:
26
common/data/xmlres/json_compat_test.go
Normal file
26
common/data/xmlres/json_compat_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package xmlres
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMoveUnmarshalJSONAcceptsNumericName(t *testing.T) {
|
||||
var move Move
|
||||
if err := json.Unmarshal([]byte(`{"ID":10001,"Name":1,"Category":1,"Type":8,"Power":35,"MaxPP":35,"Accuracy":95}`), &move); err != nil {
|
||||
t.Fatalf("unmarshal move failed: %v", err)
|
||||
}
|
||||
if move.Name != "1" {
|
||||
t.Fatalf("expected numeric name to convert to string, got %q", move.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEffectArgUnmarshalJSONAcceptsNumericSideEffectArg(t *testing.T) {
|
||||
var cfg EffectArg
|
||||
if err := json.Unmarshal([]byte(`{"SideEffects":{"SideEffect":[{"ID":1,"SideEffectArgcount":1,"SideEffectArg":3}]}}`), &cfg); err != nil {
|
||||
t.Fatalf("unmarshal effect arg failed: %v", err)
|
||||
}
|
||||
if got := string(cfg.SideEffects.SideEffect[0].SideEffectArg); got != "3" {
|
||||
t.Fatalf("expected numeric side effect arg to convert to string, got %q", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user