diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-07-24 05:40:27 -0400 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:57:29 +0200 |
| commit | 135a654e497cd53ca66da31b839c83251a072e3c (patch) | |
| tree | abec9d7314212a31ae80b65c92687a39c760a922 | |
| parent | d8386510cef293f57cd8d066753c900420997740 (diff) | |
| download | muhqs-game-135a654e497cd53ca66da31b839c83251a072e3c.tar.gz muhqs-game-135a654e497cd53ca66da31b839c83251a072e3c.zip | |
add boss type as unit specialization
| -rw-r--r-- | go/game/card.go | 19 | ||||
| -rw-r--r-- | go/game/unit.go | 2 |
2 files changed, 18 insertions, 3 deletions
diff --git a/go/game/card.go b/go/game/card.go index 38346c2b..921830cc 100644 --- a/go/game/card.go +++ b/go/game/card.go @@ -19,6 +19,7 @@ type CardType int const ( undefinedCardType CardType = iota unitType + bossType spellType artifactType equipmentType @@ -32,6 +33,8 @@ func (ct CardType) String() string { return "undefined" case unitType: return "unit" + case bossType: + return "boss" case spellType: return "spell" case artifactType: @@ -49,6 +52,7 @@ func (ct CardType) String() string { var CardTypes = struct { Unit CardType + Boss CardType Spell CardType Artifact CardType Equipment CardType @@ -56,6 +60,7 @@ var CardTypes = struct { Intention CardType }{ Unit: unitType, + Boss: bossType, Spell: spellType, Artifact: artifactType, Equipment: equipmentType, @@ -65,6 +70,7 @@ var CardTypes = struct { var CardTypeNames = map[string]CardType{ "unit": unitType, + "boss": unitType, "spell": spellType, "artifact": artifactType, "equipment": equipmentType, @@ -74,7 +80,16 @@ var CardTypeNames = map[string]CardType{ func (ct CardType) IsPermanent() bool { switch ct { - case CardTypes.Unit, CardTypes.Artifact, CardTypes.Equipment, CardTypes.Potion: + case CardTypes.Unit, CardTypes.Boss, CardTypes.Artifact, CardTypes.Equipment, CardTypes.Potion: + return true + default: + return false + } +} + +func (ct CardType) IsUnit() bool { + switch ct { + case CardTypes.Unit, CardTypes.Boss: return true default: return false @@ -320,7 +335,7 @@ func (card *Card) getXEffect(effect string) (int, error) { func (card *Card) hasPlacementConstrain(effect string) bool { if slices.Contains(card.getEffects(), effect) { return true - } else if card.Type != CardTypes.Unit { + } else if !card.Type.IsUnit() { return false } diff --git a/go/game/unit.go b/go/game/unit.go index d1192dc0..75fddf3e 100644 --- a/go/game/unit.go +++ b/go/game/unit.go @@ -27,7 +27,7 @@ type Unit struct { } func NewUnit(card *Card, tile *Tile, owner *Player) *Unit { - if card.Type != CardTypes.Unit { + if !card.Type.IsUnit() { log.Panic(card.Name, " is not a unit") } var movement Movement |
