diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-02 00:13:30 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:46:38 +0200 |
| commit | e8f44219976edf8cf57cbd9e964f66fe9d145a9c (patch) | |
| tree | 8618f3b22d94ff443227d7ebbc84014e2a786fae /go/game/unit.go | |
| parent | e64e268155c4398a82245626cf36bc39f3bea6a8 (diff) | |
| download | muhqs-game-e8f44219976edf8cf57cbd9e964f66fe9d145a9c.tar.gz muhqs-game-e8f44219976edf8cf57cbd9e964f66fe9d145a9c.zip | |
change unit attack representation and implement sword
Diffstat (limited to 'go/game/unit.go')
| -rw-r--r-- | go/game/unit.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/go/game/unit.go b/go/game/unit.go index 5d85ff4b..c24e3901 100644 --- a/go/game/unit.go +++ b/go/game/unit.go @@ -87,10 +87,7 @@ func NewUnit(card *Card, tile *Tile, owner *Player) *Unit { } var attack Attack - attackDesc, found := card.Values["attack"] - if !found { - attack = INVALID_ATTACK() - } else { + if attackDesc, found := card.Values["attack"]; found { attack = parseAttack(attackDesc) } @@ -154,7 +151,7 @@ func (u *Unit) MoveRangeTiles(m *Map) []*Tile { } func (u *Unit) AttackableTiles(m *Map) []*Tile { - return TilesInRange(m, u, u.Attack.Range) + return TilesInRange(m, u, u.Attack.MaxRange()) } func (u *Unit) AttackablePermanents(m *Map) []Permanent { @@ -181,7 +178,8 @@ func (u *Unit) AttackableEnemyPermanents(m *Map) []Permanent { } func (u *Unit) Fight(p Permanent) { - DealDamage(u, p, u.Attack.Damage) + r := DistanceBetweenPermanents(p, u) + DealDamage(u, p, u.Attack.DamageInRange(r)) } func (u *Unit) IsDestroyed() bool { @@ -205,7 +203,7 @@ func (u *Unit) AvailActions() (actions []Action) { } m := u.Controller().gameState.Map - if u.AvailAttackActions > 0 && u.Attack != INVALID_ATTACK() && + if u.AvailAttackActions > 0 && !INVALID_ATTACK(u.Attack) && len(u.AttackableEnemyPermanents(m)) > 0 { actions = append(actions, NewAttackAction(u)) |
