Enha: state to hold room_id instead of whole room
This commit is contained in:
@ -1,6 +1,10 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/rs/xid"
|
||||
)
|
||||
|
||||
type WordColor string
|
||||
|
||||
@ -28,10 +32,10 @@ func StrToWordColor(s string) WordColor {
|
||||
}
|
||||
|
||||
type Room struct {
|
||||
ID string `json:"id" db:"id"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
RoomName string `json:"room_name"`
|
||||
RoomPass string `json:"room_pass"`
|
||||
ID string `json:"id" db:"id"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
// RoomName string `json:"room_name"`
|
||||
RoomPass string `json:"room_pass"`
|
||||
RoomLink string
|
||||
CreatorName string `json:"creator_name"`
|
||||
PlayerList []string `json:"player_list"`
|
||||
@ -70,3 +74,22 @@ type RoomReq struct {
|
||||
RoomName string `json:"room_name" form:"room_name"`
|
||||
// GameSettings
|
||||
}
|
||||
|
||||
func (rr *RoomReq) CreateRoom(creator string) *Room {
|
||||
roomID := xid.New().String()
|
||||
return &Room{
|
||||
// RoomName: ,
|
||||
RoomPass: rr.RoomPass,
|
||||
ID: roomID,
|
||||
CreatedAt: time.Now(),
|
||||
PlayerList: []string{creator},
|
||||
CreatorName: creator,
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
|
||||
type FullInfo struct {
|
||||
State *UserState
|
||||
Room *Room
|
||||
}
|
||||
|
Reference in New Issue
Block a user