diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-08 17:50:10 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:50:10 +0200 |
| commit | 45df9bf319d38db916ca983b8c92bb912f5ce9ee (patch) | |
| tree | d7966002dad4a20bc3ef385bd152554fe278a6df /go/game/unit.go | |
| parent | eb10f6f4940ecd09fd7d881fe5e1735ff146f919 (diff) | |
| download | muhqs-game-45df9bf319d38db916ca983b8c92bb912f5ce9ee.tar.gz muhqs-game-45df9bf319d38db916ca983b8c92bb912f5ce9ee.zip | |
intermediate commit
Diffstat (limited to 'go/game/unit.go')
| -rw-r--r-- | go/game/unit.go | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/go/game/unit.go b/go/game/unit.go index 8b57b0ae..adb608ab 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 @@ -238,3 +251,23 @@ func (u *Unit) onUnpile(containing Permanent) { func (u *Unit) onDrop(containing Permanent) { u.onUnpile(containing) } + +func (u *Unit) removeFullAction(tag string) { + for i, fa := range u.FullActions { + if fa.tag != tag { + continue + } + u.FullActions[i] = u.FullActions[len(u.FullActions)-1] + u.FullActions = u.FullActions[:len(u.FullActions)-1] + break + } +} + +func (u *Unit) AddDamage(damage int) { + if u.Marks(UnitMarks.Ward) > 0 { + u.adjustMarks(UnitMarks.Ward, -1) + return + } + + u.PermanentBase.AddDamage(damage) +} |
