Draft: big refactor

This commit is contained in:
2025-09-16 16:03:27 +08:00
parent f527230f1e
commit 85fa3dfe73
47 changed files with 1166 additions and 351 deletions

31
types/game.go Normal file
View File

@@ -0,0 +1,31 @@
package types
import "fmt"
type RoomStatus int
const (
RoomStatusWaiting RoomStatus = iota
RoomStatusPlaying
RoomStatusEnded
)
var (
RoomStatusStr = []string{"Waiting", "Playing", "Ended"}
)
type Room struct {
ID string `json:"id"`
Creater string `json:"creater"`
Status RoomStatus `json:"status"`
Players []string `json:"players"`
Addr string `json:"-"`
}
func (self Room) View() string {
return fmt.Sprintf("%s's room [%s] (%d/2)",
self.Creater,
RoomStatusStr[self.Status],
len(self.Players),
)
}