models

package
v0.0.0-...-d96fec9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2023 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlackCard

type BlackCard struct {
	Id   int
	Deck string `json:"deck"`
	Icon string `json:"icon"`
	Text string `json:"text"`
	Pick int    `json:"pick"`
}

func RemoveBlackCard

func RemoveBlackCard(cards []BlackCard, index int) []BlackCard

func (BlackCard) GetColor

func (c BlackCard) GetColor() CardColor

func (BlackCard) GetId

func (c BlackCard) GetId() int

func (BlackCard) GetText

func (c BlackCard) GetText() string

type Card

type Card interface {
	GetText() string
	GetColor() CardColor
	GetId() int
}

type CardColor

type CardColor int
const (
	WHITE_CARD CardColor = iota
	BLACK_CARD
)

func (CardColor) String

func (i CardColor) String() string

type Config

type Config struct {
	General ConfigGeneral
}

type ConfigGeneral

type ConfigGeneral struct {
	Decks []string
}

type Deck

type Deck struct {
	Black_cards       []BlackCard
	White_cards       []WhiteCard
	LastExtractedCard *Card
}

func (*Deck) NewRandomBlackCard

func (deck *Deck) NewRandomBlackCard() *BlackCard

func (*Deck) NewRandomWhiteCard

func (deck *Deck) NewRandomWhiteCard() *WhiteCard

type DeckData

type DeckData struct {
	Black    []BlackCard             `json:"black"`
	White    []WhiteCard             `json:"white"`
	Metadata map[string]DeckMetadata `json:"metadata"`
}

type DeckMetadata

type DeckMetadata struct {
	Description string `json:"description"`
	Icon        string `json:"icon"`
	Name        string `json:"name"`
	Official    bool   `json:"official"`
}

type Juror

type Juror struct {
	User *User
}

type Match

type Match struct {
	Id        int
	Players   []*Player
	Jury      []*Juror
	CreatedOn time.Time
	Rounds    []Round
	State     MatchState
	Deck      *Deck
}

func NewMatch

func NewMatch(id int, players []*Player) *Match

func (*Match) EndVote

func (m *Match) EndVote() bool

func (*Match) GetPlayerByID

func (m *Match) GetPlayerByID(id int64) *Player

func (*Match) GetRound

func (m *Match) GetRound() *Round

func (*Match) NewBlackCard

func (m *Match) NewBlackCard() *BlackCard

func (*Match) NewDeck

func (m *Match) NewDeck()

func (*Match) RemoveVote

func (m *Match) RemoveVote(round *Round, card *WhiteCard, juror *Juror)

type MatchState

type MatchState int
const (
	MATCH_WAIT_USERS MatchState = iota
	MATCH_PLAYBALE
	MATCH_VOTING
	MATCH_SHOW_RESULTS
	MATCH_END
)

type Player

type Player struct {
	User  *User
	Cards []*WhiteCard
}

type Round

type Round struct {
	BlackCard *BlackCard
	Wcs       map[*WhiteCard][]Juror
	Mutex     sync.Mutex
	Voters    []Juror
}

func (*Round) AddCard

func (r *Round) AddCard(card *WhiteCard) bool

func (*Round) GetChoices

func (r *Round) GetChoices() []*WhiteCard

type User

type User struct {
	Id       int64 `db:"user_id"`
	Username string
	PwHash   string
	Admin    bool
	UserType UserType
	Score    int
}

func (*User) IsAdmin

func (u *User) IsAdmin() bool

type UserType

type UserType int
const (
	PlayerType UserType = iota
	JurorType
)

type WhiteCard

type WhiteCard struct {
	Id    int
	Deck  string  `json:"deck"`
	Icon  string  `json:"icon"`
	Text  string  `json:"text"`
	Owner *Player `json:"-"`
}

func RemoveWhiteCard

func RemoveWhiteCard(cards []WhiteCard, index int) []WhiteCard

func (WhiteCard) GetColor

func (c WhiteCard) GetColor() CardColor

func (WhiteCard) GetId

func (c WhiteCard) GetId() int

func (WhiteCard) GetText

func (c WhiteCard) GetText() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL