Chore: model update
This commit is contained in:
@ -9,6 +9,44 @@ import (
|
||||
"github.com/rs/xid"
|
||||
)
|
||||
|
||||
type (
|
||||
UserTeam string
|
||||
UserRole string
|
||||
)
|
||||
|
||||
const (
|
||||
// UserTeam
|
||||
UserTeamBlue = "blue"
|
||||
UserTeamRed = "red"
|
||||
UserTeamNone = ""
|
||||
//UserRole
|
||||
UserRoleMime = "mime"
|
||||
UserRoleGuesser = "guesser"
|
||||
UserRoleNone = ""
|
||||
)
|
||||
|
||||
func StrToUserTeam(s string) UserTeam {
|
||||
switch s {
|
||||
case "blue":
|
||||
return UserTeamBlue
|
||||
case "red":
|
||||
return UserTeamRed
|
||||
default:
|
||||
return UserTeamNone
|
||||
}
|
||||
}
|
||||
|
||||
func StrToUserRole(s string) UserRole {
|
||||
switch s {
|
||||
case "mime":
|
||||
return UserRoleMime
|
||||
case "guesser":
|
||||
return UserRoleGuesser
|
||||
default:
|
||||
return UserRoleNone
|
||||
}
|
||||
}
|
||||
|
||||
type WordColor string
|
||||
|
||||
const (
|
||||
@ -50,20 +88,20 @@ type Team struct {
|
||||
}
|
||||
|
||||
type Action struct {
|
||||
ID int `json:"id" db:"id"`
|
||||
RoomID string `json:"room_id" db:"room_id"`
|
||||
Actor string `json:"actor" db:"actor"`
|
||||
ActorColor string `json:"actor_color" db:"actor_color"`
|
||||
Action string `json:"action_type" db:"action_type"`
|
||||
Word string `json:"word" db:"word"`
|
||||
WordColor string `json:"word_color" db:"word_color"`
|
||||
Number string `json:"number_associated" db:"number_associated"`
|
||||
CreatedAt time.Time `json:"created_at" db:"-"`
|
||||
CreatedAtUnix int64 `db:"created_at"`
|
||||
ID uint32 `json:"id" db:"id"`
|
||||
RoomID string `json:"room_id" db:"room_id"`
|
||||
Actor string `json:"actor" db:"actor"`
|
||||
ActorColor string `json:"actor_color" db:"actor_color"`
|
||||
Action string `json:"action_type" db:"action_type"`
|
||||
Word string `json:"word" db:"word"`
|
||||
WordColor string `json:"word_color" db:"word_color"`
|
||||
Number string `json:"number_associated" db:"number_associated"`
|
||||
CreatedAt time.Time `json:"created_at" db:"-"`
|
||||
CreatedAtUnix int64 `db:"created_at"`
|
||||
}
|
||||
|
||||
type Player struct {
|
||||
ID int `json:"id" db:"id"`
|
||||
ID uint32 `json:"id" db:"id"`
|
||||
RoomID string `json:"room_id" db:"room_id"`
|
||||
Username string `json:"username" db:"username"`
|
||||
Team UserTeam `json:"team" db:"team"`
|
||||
@ -71,6 +109,15 @@ type Player struct {
|
||||
IsBot bool `json:"is_bot" db:"is_bot"`
|
||||
}
|
||||
|
||||
func InitPlayer(username string) *Player {
|
||||
return &Player{
|
||||
// last id + 1?
|
||||
Username: username,
|
||||
Team: UserTeamNone,
|
||||
Role: UserRoleNone,
|
||||
}
|
||||
}
|
||||
|
||||
type BotPlayer struct {
|
||||
Role UserRole // gueeser | mime
|
||||
Team UserTeam
|
||||
|
Reference in New Issue
Block a user