feat(utils): 重构 OrderedMap 为 OrderMap,支持排序和非阻塞遍历

- 将原有的 `OrderedMap` 替换为 `OrderMap`,基于 `map` 和 `slice` 实现,提升性能并简化逻辑
- 支持自定义 key 排序规则,若未提供则按插入顺序维护
- 提供 `Set`、`Get`、`Delete`、`Keys`、`Values` 等基本操作,均并发安全
- 引入非阻塞遍历机制(`Iter`、`Iter
This commit is contained in:
2025-10-22 21:30:05 +08:00
parent ae88790ed3
commit 83fb06a229
7 changed files with 258 additions and 208 deletions

View File

@@ -21,7 +21,7 @@ type Input struct {
*info.AttackValue
FightC common.FightI
// info.BattleActionI
Effects *utils.OrderedMap[int, Effect] //effects 实际上全局就是effect无限回合 //effects容器 技能的
Effects *utils.OrderMap[int, Effect] //effects 实际上全局就是effect无限回合 //effects容器 技能的
DamageZone struct {
Damage decimal.Decimal //伤害
BeforeADD decimal.Decimal //攻击伤害
@@ -40,7 +40,7 @@ type Input struct {
func NewInput(c common.FightI, p common.PlayerI) *Input {
ret := &Input{FightC: c, Player: p}
ret.Effects = utils.NewOrderedMap[int, Effect]()
ret.Effects = utils.NewOrderedMap[int, Effect](nil)
// t := Geteffect(EffectType.Damage, 0)
// t.Effect.SetArgs(ret)
@@ -58,7 +58,16 @@ func (i *Input) GetPetInfo() *info.BattlePetEntity {
// 这个每回合都会调用
func (i *Input) InitAttackValue() {
var old *info.AttackValue
if i.AttackValue != nil {
old = i.AttackValue
}
i.AttackValue = info.NewAttackValue(i.Player.GetInfo().UserID)
if old != nil {
i.AttackValue.Prop = old.Prop
i.AttackValue.Status = old.Status
}
}
func (i *Input) GetPet(id uint32) (ii *info.BattlePetEntity, Reason info.ChangePetInfo) {