feat(fight): 增加战斗模式枚举并重构战斗逻辑判断

- 引入完整的 BattleMode 枚举定义,替代原有的 BattleStatus,明确区分各类战斗场景
- 在多个控制器中替换对旧 Status 字段的依赖,统一使用 Mode 判断战斗状态
- 修复部分函数调用前未检查 FightC 是否为空的问题,增加 ErrBattleEnded 错误返回
- 调整
This commit is contained in:
2025-11-21 02:40:27 +08:00
parent 105c6f5a23
commit e54d4bacaa
18 changed files with 217 additions and 123 deletions

View File

@@ -103,8 +103,6 @@ func (p *Player) Getfightinfo() info.Fightinfo {
return p.Fightinfo
}
func (p *Player) QuitFight() {
//将战斗标记设置为0 这里的标记是
atomic.StoreUint32(&p.Fightinfo.Status, 0)
p.FightC = nil
@@ -116,11 +114,14 @@ func (p *Player) GetSpace() *space.Space {
// 0无战斗1PVP2,BOOS,3PVE
func (p *Player) CanFight() bool {
// if atomic.CompareAndSwapUint32(&p.Fightinfo.Status, 0, staus) { //先判断是否竞态条件被挑战
if len(p.Info.PetList) == 0 {
atomic.StoreUint32(&p.Fightinfo.Mode, 0)
return false
//成功,继续判断
}
if p.FightC != nil {
atomic.StoreUint32(&p.Fightinfo.Mode, 0)
return false
}
@@ -133,7 +134,7 @@ func (p *Player) CanFight() bool {
}
}
// 遍历完所有宠物都没有血量大于0的才不能战斗
atomic.StoreUint32(&p.Fightinfo.Mode, 0)
return false
// }