summaryrefslogtreecommitdiff
path: root/internal/api/database/models.go
blob: f065a8cf1aba3a7891ec4b159d55e69a706c18cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package database

import "time"

type User struct {
	ID        int       `json:"id"`
	Username  string    `json:"username"`
	Password  string    `json:"password"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type GameType string

const (
	SingleGameType GameType = "single"
	PairGameType   GameType = "pair"
)

type Game struct {
	ID         int       `json:"id"`
	Type       GameType  `json:"type"`
	Player1ID  int       `json:"-"`
	Player1    User      `gorm:"foreignKey:Player1ID" json:"player1"`
	Player2ID  *int      `json:"-"`
	Player2    *User     `gorm:"foreignKey:Player2ID;null" json:"player2"`
	Player3ID  *int      `json:"-"`
	Player3    *User     `gorm:"foreignKey:Player3ID;null" json:"player3"`
	Player4ID  *int      `json:"-"`
	Player4    *User     `gorm:"foreignKey:Player4ID;null" json:"player4"`
	Name       string    `json:"name"`
	IP1        string    `json:"ip1"`
	IP2        string    `json:"ip2"`
	IP3        string    `json:"ip3"`
	IP4        string    `json:"ip4"`
	Outcome    string    `json:"outcome"`
	LastPlayer int       `json:"last_player"` // Last player entered in game
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
}