package game import ( "log" "strconv" "strings" ) type Artifact struct { permanentBase Solid int } func NewArtifactFromPath(cardPath string, tile *Tile, owner *Player) *Artifact { card := NewCard(cardPath) return NewArtifact(card, tile, owner) } func NewArtifact(card *Card, tile *Tile, owner *Player) *Artifact { a := &Artifact{ permanentBase: permanentBase{ card: card, tile: tile, owner: owner, controller: owner, marks: make(map[PermanentMark]int), }, } effects := card.getEffects() for _, e := range effects { if strings.HasPrefix(e, "Solid") { tokens := strings.Split(e, " ") var err error a.Solid, err = strconv.Atoi(tokens[1]) if err != nil { log.Panicf("Invalid Solid definition %s\n", e) } } } return a } func (a *Artifact) String() string { return FmtPermanent(a) } func (a *Artifact) IsDestroyed() bool { return a.Solid > 0 && a.Damage() >= a.Solid } func (a *Artifact) Attackable() bool { return a.permanentBase.Attackable() && a.Solid > 0 }