tome_lib/card.go

58 lines
1.1 KiB
Go
Raw Normal View History

2021-10-01 12:43:55 -04:00
package tome_lib
import (
"fmt"
"log"
2021-10-01 12:43:55 -04:00
"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"`
Spell bool `json:"spell"`
2021-11-08 15:46:03 -05:00
Token bool `json:"token"`
2021-11-16 15:51:09 -05:00
Phased bool `json:"phased"`
2021-10-01 12:43:55 -04:00
Effects []*Effect `json:"effects"`
}
func NewEmpty(o, p int) *Card {
if o != ScourgeID && o != SentinalID {
log.Printf("Need valid owner for empty card:%v", o)
panic("err")
return nil
}
2021-10-01 12:43:55 -04:00
return &Card{
Type: EmptyValue,
BasePower: -1,
Power: -1,
Id: uuid.New(),
Sick: false,
Counters: 0,
Owner: o,
2021-10-01 12:43:55 -04:00
Position: p,
Spell: false,
2021-11-08 15:46:03 -05:00
Token: false,
2021-11-16 15:51:09 -05:00
Phased: false,
2021-10-01 12:43:55 -04:00
Effects: []*Effect{},
}
}
func (c *Card) Empty() bool {
return c.Type == EmptyValue
}
func (c *Card) String() string {
ready := " "
if c.Sick {
ready = "*"
}
return fmt.Sprintf("%v%v%v", c.Type, c.Power, ready)
}