Files
bl/logic/service/space/arena.go

46 lines
918 B
Go
Raw Normal View History

2025-11-18 23:41:31 +00:00
package space
import (
"blazing/logic/service/common"
"sync/atomic"
)
2025-11-19 00:09:12 +00:00
type ARENA struct {
ARENA_Player common.PlayerI `struc:"skip"`
Flag uint32 // 0=清除ArenaInfoflag为0时其他字段全为空 1=站上擂台的信息 2=挑战中的信息
UserID uint32
2025-11-18 23:41:31 +00:00
Nick string `struc:"[16]byte"`
HostWins uint32 // 应该是擂台人的连胜数
ChallengerID uint32 // 挑战者的userid
}
func (t *ARENA) Reset() {
t.Flag = 0
t.UserID = 0
t.Nick = ""
t.HostWins = 0
t.ChallengerID = 0
t.ARENA_Player = nil
}
func (t *ARENA) Set(c common.PlayerI) bool {
if c.GetInfo().UserID == atomic.LoadUint32(&t.UserID) {
t.HostWins += 1 //连胜+1
} else {
t.HostWins = 0 //连胜重置
t.UserID = c.GetInfo().UserID //添加用户ID
t.Nick = c.GetInfo().Nick
t.ARENA_Player = c //添加用户
}
atomic.StoreUint32(&t.Flag, 1)
return true
}