game/common/baseroom/baseSeat.go

62 lines
1005 B
Go
Raw Normal View History

2025-06-06 20:02:58 +08:00
package baseroom
2025-06-07 01:58:14 +08:00
type SeatStatus int
const (
SsWaitStart SeatStatus = 0 // 等待开始
SsReadyStart SeatStatus = 1 // 准备
SsPlaying SeatStatus = 2 // 游戏中
SsFakeLeave SeatStatus = 3 // 假离开
2025-06-06 20:02:58 +08:00
)
2025-06-07 01:58:14 +08:00
func (t SeatStatus) String() string {
switch t {
case SsWaitStart:
return "wait-start"
case SsReadyStart:
return "ready-start"
case SsPlaying:
return "playing"
case SsFakeLeave:
return "fake-leave"
}
return "not-exist-seat-status"
2025-06-06 20:02:58 +08:00
}
2025-06-07 01:58:14 +08:00
type BaseSeat struct {
no int
player IPlayer
status SeatStatus
2025-06-06 20:02:58 +08:00
}
2025-06-07 01:58:14 +08:00
func NewBaseSeat(no int) *BaseSeat {
return &BaseSeat{
no: no,
status: SsWaitStart,
}
2025-06-06 20:02:58 +08:00
}
func (s *BaseSeat) No() int {
return s.no
}
func (s *BaseSeat) Empty() bool {
return s.player == nil
}
func (s *BaseSeat) Player() IPlayer {
return s.player
}
func (s *BaseSeat) SetPlayer(player IPlayer) {
s.player = player
}
2025-06-07 01:58:14 +08:00
func (s *BaseSeat) Status() SeatStatus {
return s.status
2025-06-06 20:02:58 +08:00
}
2025-06-07 01:58:14 +08:00
func (s *BaseSeat) SetStatus(status SeatStatus) {
s.status = status
2025-06-06 20:02:58 +08:00
}