服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
121 lines
3.5 KiB
Go
121 lines
3.5 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/binary"
|
|
"testing"
|
|
)
|
|
|
|
func TestRemoveItemTimeLimitSectionsRemovesBothFieldsAndPreservesNeighbors(t *testing.T) {
|
|
resolved := map[int]string{
|
|
1: "[name]",
|
|
2: "[expiration date]",
|
|
3: "[usable period]",
|
|
4: "[action type]",
|
|
5: "[level up ticket]",
|
|
}
|
|
raw := encodeTokens(
|
|
rawToken{typ: 3, value: 1},
|
|
rawToken{typ: 6, value: 5},
|
|
rawToken{typ: 3, value: 2},
|
|
rawToken{typ: 6, value: 99},
|
|
rawToken{typ: 3, value: 3},
|
|
rawToken{typ: 0, value: 7},
|
|
rawToken{typ: 3, value: 4},
|
|
rawToken{typ: 6, value: 5},
|
|
)
|
|
patched, counts, err := removeItemTimeLimitSections(raw, func(value int) string { return resolved[value] })
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
want := encodeTokens(
|
|
rawToken{typ: 3, value: 1},
|
|
rawToken{typ: 6, value: 5},
|
|
rawToken{typ: 3, value: 4},
|
|
rawToken{typ: 6, value: 5},
|
|
)
|
|
if string(patched) != string(want) {
|
|
t.Fatalf("patched=%x want=%x", patched, want)
|
|
}
|
|
if counts["expiration date"] != 1 || counts["usable period"] != 1 {
|
|
t.Fatalf("counts=%v", counts)
|
|
}
|
|
}
|
|
|
|
func TestRemoveItemTimeLimitSectionsRemovesRepeatedAndEmptyFields(t *testing.T) {
|
|
resolved := map[int]string{1: "[expiration date]", 2: "[name]"}
|
|
raw := encodeTokens(
|
|
rawToken{typ: 3, value: 1},
|
|
rawToken{typ: 3, value: 1},
|
|
rawToken{typ: 6, value: 10},
|
|
rawToken{typ: 3, value: 2},
|
|
rawToken{typ: 6, value: 11},
|
|
)
|
|
patched, counts, err := removeItemTimeLimitSections(raw, func(value int) string { return resolved[value] })
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
want := encodeTokens(rawToken{typ: 3, value: 2}, rawToken{typ: 6, value: 11})
|
|
if string(patched) != string(want) || counts["expiration date"] != 2 {
|
|
t.Fatalf("patched=%x counts=%v want=%x", patched, counts, want)
|
|
}
|
|
}
|
|
|
|
func TestRemoveItemTimeLimitSectionsRejectsPartialToken(t *testing.T) {
|
|
if _, _, err := removeItemTimeLimitSections([]byte{3, 1, 2}, func(int) string { return "" }); err == nil {
|
|
t.Fatal("partial token stream was accepted")
|
|
}
|
|
}
|
|
|
|
func TestRewriteItemTimeLimitSectionsMakesEffectExpirationUnlimited(t *testing.T) {
|
|
resolved := map[int]string{
|
|
1: "[damage font info]",
|
|
2: "[expiration info]",
|
|
3: "[date]",
|
|
4: "2048-12-31 06:00:00",
|
|
5: "[/damage font info]",
|
|
6: "[unlimit]",
|
|
}
|
|
raw := encodeTokens(
|
|
rawToken{typ: 3, value: 1},
|
|
rawToken{typ: 3, value: 2},
|
|
rawToken{typ: 6, value: 3},
|
|
rawToken{typ: 6, value: 4},
|
|
rawToken{typ: 3, value: 5},
|
|
)
|
|
patched, counts, err := rewriteItemTimeLimitSections(raw, func(value int) string { return resolved[value] }, 6)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
want := encodeTokens(
|
|
rawToken{typ: 3, value: 1},
|
|
rawToken{typ: 3, value: 2},
|
|
rawToken{typ: 6, value: 6},
|
|
rawToken{typ: 3, value: 5},
|
|
)
|
|
if string(patched) != string(want) || counts.Transformed["expiration info"] != 1 {
|
|
t.Fatalf("patched=%x counts=%+v want=%x", patched, counts, want)
|
|
}
|
|
rewritten, secondCounts, err := rewriteItemTimeLimitSections(patched, func(value int) string { return resolved[value] }, 6)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if string(rewritten) != string(want) || countPatchSections(secondCounts) != 0 {
|
|
t.Fatalf("second rewrite was not idempotent: patched=%x counts=%+v", rewritten, secondCounts)
|
|
}
|
|
}
|
|
|
|
type rawToken struct {
|
|
typ byte
|
|
value int32
|
|
}
|
|
|
|
func encodeTokens(tokens ...rawToken) []byte {
|
|
out := make([]byte, len(tokens)*scriptTokenSize)
|
|
for index, token := range tokens {
|
|
offset := index * scriptTokenSize
|
|
out[offset] = token.typ
|
|
binary.LittleEndian.PutUint32(out[offset+1:offset+scriptTokenSize], uint32(token.value))
|
|
}
|
|
return out
|
|
}
|