aboutsummaryrefslogtreecommitdiff
path: root/go/game/unit.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-02-08 17:50:10 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-01-27 16:43:49 +0100
commit805cbf397589e5cb861f866713c2eb4bec9ce40b (patch)
tree084ef7d136f33b87efe5aa02c7401bde50c9d251 /go/game/unit.go
parent05de94b9d97079ca9a7b23e011516f55056472b3 (diff)
downloadmuhqs-game-805cbf397589e5cb861f866713c2eb4bec9ce40b.tar.gz
muhqs-game-805cbf397589e5cb861f866713c2eb4bec9ce40b.zip
intermediate commit
Diffstat (limited to 'go/game/unit.go')
-rw-r--r--go/game/unit.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/go/game/unit.go b/go/game/unit.go
index 8b57b0ae..94458c07 100644
--- a/go/game/unit.go
+++ b/go/game/unit.go
@@ -1,6 +1,7 @@
package game
import (
+ "fmt"
"log"
)
@@ -14,7 +15,7 @@ type Unit struct {
Health int
Movement Movement
Attack Attack
- Upkeep int
+ upkeep int
FullActions []*FullAction
FreeActions []*FreeAction
// Effects []Effects
@@ -48,7 +49,7 @@ func NewUnit(card *Card, tile *Tile, owner *Player) *Unit {
Health: card.Values["health"].(int),
Movement: movement,
Attack: attack,
- Upkeep: upkeep,
+ upkeep: upkeep,
AvailMoveActions: DEFAULT_AVAIL_MOVE_ACTIONS,
AvailAttackActions: DEFAULT_AVAIL_ATTACK_ACTIONS,
}
@@ -61,10 +62,22 @@ func NewUnit(card *Card, tile *Tile, owner *Player) *Unit {
return u
}
+func (u *Unit) Fmt() string {
+ return fmt.Sprintf("%s@%v", u.Card().Name, u.TileOrContainingPermTile())
+}
+
+func (u *Unit) FmtWController() string {
+ return fmt.Sprintf("%s's %s@%v", u.Controller().Name, u.Card().Name, u.TileOrContainingPermTile())
+}
+
func NewUnitFromPath(cardPath string, tile *Tile, owner *Player) *Unit {
return NewUnit(NewCard(cardPath), tile, owner)
}
+func (u *Unit) UpkeepCost() int {
+ return u.upkeep
+}
+
func (u *Unit) resetBaseActions() {
u.AvailMoveActions = DEFAULT_AVAIL_MOVE_ACTIONS + u.additionalMoveActions
u.AvailAttackActions = DEFAULT_AVAIL_ATTACK_ACTIONS + u.additionalAttackActions