package game import ( "fmt" "github.com/google/uuid" ) type Card struct { Type CardType `json:"type"` BasePower int `json:"base_power"` Power int `json:"power"` Id uuid.UUID `json:"id"` Sick bool `json:"sick"` Counters int `json:"counters"` Owner int `json:"owner"` Position int `json:"position"` } type CardType int const ( Valk CardType = iota Ace Two Three Four Five Six Seven Eight ) const ( EmptyValue CardType = -1 ) func (c CardType) String() string { if c == -1 { return " " } return []string{"V", "A", "2", "3", "4", "5", "6", "7", "8"}[c] } func NewCard(v, o, p int, id uuid.UUID) *Card { if id == uuid.Nil { id = uuid.New() } return &Card{ Type: CardType(v), BasePower: OraclePower(CardType(v), nil), Power: OraclePower(CardType(v), nil), Id: id, Sick: false, Counters: 0, Owner: o, Position: p, } } func NewEmpty(p int) *Card { return &Card{ Type: EmptyValue, BasePower: -1, Power: -1, Id: uuid.New(), Sick: false, Counters: 0, Owner: -1, Position: p, } } func (c *Card) Empty() bool { return c.Type == EmptyValue } func (c *Card) String() string { return fmt.Sprintf("|%v|", c.Type) }