From e8f44219976edf8cf57cbd9e964f66fe9d145a9c Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Thu, 2 Feb 2023 00:13:30 +0100 Subject: change unit attack representation and implement sword --- go/game/unit.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'go/game/unit.go') 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)) -- cgit v1.2.3