game/common/baseroom/interface.go

55 lines
1022 B
Go
Raw Normal View History

2025-06-06 20:02:58 +08:00
package baseroom
2025-06-07 01:58:14 +08:00
import (
"game/common/proto/pb"
"github.com/golang/protobuf/proto"
"time"
)
2025-06-06 20:02:58 +08:00
type IRoom interface {
Id() int
RoomType() int // 房间配置id
PlayType() int
// SeatPlayerNum() int
// HasEmptySeat() bool
// HasPlayer(uid int64) bool
OnMessage(cmd int32, params ...any)
// ReleaseRoom()
}
type ISeat interface {
No() int
Empty() bool
Player() IPlayer
SetPlayer(player IPlayer)
2025-06-07 01:58:14 +08:00
Status() SeatStatus
SetStatus(status SeatStatus)
2025-06-06 20:02:58 +08:00
}
type IPlayer interface {
Id() int64
Robot() IRobot
}
type IRobot interface {
OnMessage(cmd pb.MsgId, params ...any)
}
2025-06-07 01:58:14 +08:00
type ITimer interface {
2025-06-06 20:02:58 +08:00
OnTimer(timerType TimerType, args ...interface{})
2025-06-07 01:58:14 +08:00
NewTimer(duration time.Duration, cb func(), needLog bool, desc ...string) uint32
CancelTimer(timerId uint32)
2025-06-06 20:02:58 +08:00
}
type ISender interface {
2025-06-07 01:58:14 +08:00
SendMsg(user IPlayer, msgId pb.MsgId, msg proto.Message)
2025-06-06 20:02:58 +08:00
}
type ICreateRoom interface {
CreateRoom(id, roomType int) (IRoom, pb.ErrCode)
}
2025-06-07 01:58:14 +08:00
type ICreatePlayer interface {
CreatePlayer(id int64) (IPlayer, pb.ErrCode)
}