aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-07-24 05:40:27 -0400
committerFlorian Fischer <florian.fischer@muhq.space>2025-07-24 12:22:10 -0400
commit8fd776573f8f7eb5befc7b8d9106dd258b4ea947 (patch)
tree182dba0fe4356206a14e8d7659fb2c403a6363e8
parent9175de76012680eb10807380c64156a723d48fae (diff)
downloadmuhqs-game-8fd776573f8f7eb5befc7b8d9106dd258b4ea947.tar.gz
muhqs-game-8fd776573f8f7eb5befc7b8d9106dd258b4ea947.zip
add boss type as unit specialization
-rw-r--r--go/game/card.go19
-rw-r--r--go/game/unit.go2
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