Feat: game setting fields
This commit is contained in:
@ -71,7 +71,6 @@ type CardMark struct {
|
||||
type Room struct {
|
||||
ID string `json:"id" db:"id"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"` // limit?
|
||||
RoomPass string `json:"room_pass"`
|
||||
RoomLink string
|
||||
CreatorName string `json:"creator_name"`
|
||||
ActionHistory []Action
|
||||
@ -97,6 +96,7 @@ type Room struct {
|
||||
Mark CardMark // card is marked
|
||||
// needed for debug
|
||||
LogJournal []string
|
||||
Settings GameSettings
|
||||
}
|
||||
|
||||
func (r *Room) ClearMarks() {
|
||||
@ -325,11 +325,10 @@ type WordCard struct {
|
||||
}
|
||||
|
||||
type GameSettings struct {
|
||||
IsRunning bool `json:"is_running"`
|
||||
Language string `json:"language" example:"en" form:"language"`
|
||||
RoundTime int32 `json:"round_time"`
|
||||
ProgressPct uint32 `json:"progress_pct"`
|
||||
IsOver bool
|
||||
RoomPass string `json:"room_pass"`
|
||||
TurnSeconds uint32
|
||||
RoundTime uint32
|
||||
}
|
||||
|
||||
// =====
|
||||
@ -337,20 +336,26 @@ type GameSettings struct {
|
||||
type RoomReq struct {
|
||||
// is not user or not unique
|
||||
RoomPass string `json:"room_pass" form:"room_pass"`
|
||||
RoomName string `json:"room_name" form:"room_name"`
|
||||
// GameSettings
|
||||
Language string `json:"language" form:"language"`
|
||||
RoundTime uint32
|
||||
}
|
||||
|
||||
func (rr *RoomReq) CreateRoom(creator string) *Room {
|
||||
roomID := xid.New().String()
|
||||
settings := GameSettings{
|
||||
Language: rr.Language,
|
||||
RoomPass: rr.RoomPass,
|
||||
RoundTime: rr.RoundTime,
|
||||
}
|
||||
return &Room{
|
||||
// RoomName: ,
|
||||
RoomPass: rr.RoomPass,
|
||||
ID: roomID,
|
||||
CreatedAt: time.Now(),
|
||||
// PlayerList: []string{creator},
|
||||
CreatorName: creator,
|
||||
BotMap: make(map[string]BotPlayer),
|
||||
Settings: settings,
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user