aboutsummaryrefslogtreecommitdiff
path: root/go/game/artifact.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/game/artifact.go')
-rw-r--r--go/game/artifact.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/go/game/artifact.go b/go/game/artifact.go
new file mode 100644
index 00000000..acbaeb74
--- /dev/null
+++ b/go/game/artifact.go
@@ -0,0 +1,51 @@
+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{NewPermanentBase(card, tile, owner), 0}
+ tile.Permanent = a
+
+ 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.Fatalf("Invalid Solid definition %s\n", e)
+ }
+ }
+ }
+
+ return a
+}
+
+func (a *Artifact) Fight(p Permanent) {
+}
+
+func (a *Artifact) IsDestroyed() bool {
+ return a.Damage() >= a.Solid
+}
+
+func (a *Artifact) Attackable() bool {
+ return a.Solid > 0
+}
+
+func (a *Artifact) AvailActions() []Action {
+ return []Action{}
+}