From ed473052c558fbda6bb03d9083b425cb2e7a808f Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 22 Jul 2025 19:25:43 -0400 Subject: do not pass the map through the Attackable* function family --- go/game/unit.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'go/game/unit.go') diff --git a/go/game/unit.go b/go/game/unit.go index c7528224..1bf3afa1 100644 --- a/go/game/unit.go +++ b/go/game/unit.go @@ -112,12 +112,13 @@ func (u *Unit) MoveRangeTiles(m *Map) []*Tile { return tiles } -func (u *Unit) AttackableTiles(m *Map) []*Tile { +func (u *Unit) AttackableTiles() []*Tile { // Units not on the map can not attack if u.tile == nil { return nil } + m := u.controller.gameState.Map() tilesInRange := TilesInRange(m, u, u.Attack.MaxRange()) if u.Attack.MaxRange() == 1 { return tilesInRange @@ -134,9 +135,9 @@ func (u *Unit) AttackableTiles(m *Map) []*Tile { return aTiles } -func (u *Unit) AttackablePermanents(m *Map) []Permanent { +func (u *Unit) AttackablePermanents() []Permanent { permanents := []Permanent{} - for _, t := range u.AttackableTiles(m) { + for _, t := range u.AttackableTiles() { if t.Permanent != nil && t.Permanent.Attackable() { permanents = append(permanents, t.Permanent) } @@ -144,10 +145,10 @@ func (u *Unit) AttackablePermanents(m *Map) []Permanent { return permanents } -func (u *Unit) AttackableEnemyPermanents(m *Map) []Permanent { +func (u *Unit) AttackableEnemyPermanents() []Permanent { controller := u.Controller() permanents := []Permanent{} - for _, t := range u.AttackableTiles(m) { + for _, t := range u.AttackableTiles() { if t.Permanent != nil && t.Permanent.Attackable() && t.Permanent.Controller() != controller { @@ -182,7 +183,7 @@ func (u *Unit) AvailSlowActions() (actions []Action) { m := u.Controller().gameState.Map() if u.AvailAttackActions > 0 && !INVALID_ATTACK(u.Attack) && - len(u.AttackableEnemyPermanents(m)) > 0 { + len(u.AttackableEnemyPermanents()) > 0 { actions = append(actions, NewAttackAction(u)) } -- cgit v1.2.3