feat(fight): 优化擂台战斗逻辑与状态管理

- 修改了擂台主人设置逻辑,引入 `Set` 方法统一处理玩家信息更新
- 增加对擂主是否可战斗的判断,防止无效挑战
- 调整连胜计算和广播机制,确保数据一致性
- 修复擂台挑战失败时的状态回滚问题
- 引入错误码替代硬编码返回值,提高代码可读性与维护性
- 统一访问擂台玩家的方式,移除冗余字段
This commit is contained in:
2025-11-28 00:16:51 +08:00
parent 0ab1a85d17
commit f90581e0f6
13 changed files with 90 additions and 54 deletions

View File

@@ -24,7 +24,7 @@ func (p *Player) JoinFight(fn func(p common.PlayerI) bool) errorcode.ErrorCode {
if v.GetInfo().UserID != p.Info.UserID {
//确认是乱斗模式
if v.Getfightinfo() == p.Getfightinfo() {
if v.Getfightinfo() == p.Getfightinfo() && p.CanFight() {
// p.Fightinfo = nil //先将自身的准备信息置空
// //value.PVPinfo = nil