32 lines
545 B
Go
32 lines
545 B
Go
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),
|
|
)
|
|
}
|