From 24645c441330a33db1cc2d90d8f097a2adf0b868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 5 Apr 2016 09:23:50 +0200 Subject: Map,Board: Map cleans Collection before calling Board methods --- core/src/ch/asynk/rustanddust/engine/Board.java | 3 --- core/src/ch/asynk/rustanddust/engine/SearchBoard.java | 2 -- core/src/ch/asynk/rustanddust/game/map/Map1Units.java | 7 +++---- core/src/ch/asynk/rustanddust/game/map/Map2Moves.java | 3 +-- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/engine/Board.java b/core/src/ch/asynk/rustanddust/engine/Board.java index 5db34e3..6b80c04 100644 --- a/core/src/ch/asynk/rustanddust/engine/Board.java +++ b/core/src/ch/asynk/rustanddust/engine/Board.java @@ -325,7 +325,6 @@ public abstract class Board implements Disposable, Animation protected int collectPossibleTargets(Pawn pawn, Collection units, Collection targets) { - targets.clear(); for (Pawn target : units) { if (pawn.canEngage(target) && searchBoard.canAttack(pawn, target, true)) targets.add(target); @@ -336,7 +335,6 @@ public abstract class Board implements Disposable, Animation protected int collectMoveAssists(Pawn pawn, Collection assists) { - assists.clear(); setAdjacentTiles(pawn.getTile(), neighbours); for (int i = 0; i < 6; i++) { Tile tile = neighbours[i]; @@ -352,7 +350,6 @@ public abstract class Board implements Disposable, Animation protected int collectAttackAssists(Pawn pawn, Pawn target, Collection units, Collection assists) { - assists.clear(); for (Pawn p : units) { if ((p != pawn) && p.canEngage(target) && searchBoard.canAttack(p, target, !p.canAssistEngagementWithoutLos())) assists.add(p); diff --git a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java index 141f5cc..803214e 100644 --- a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java +++ b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java @@ -110,7 +110,6 @@ public class SearchBoard public int possibleMovesFrom(Pawn pawn, Collection moves) { - moves.clear(); searchCount += 1; Node adjacents[] = new Node[6]; @@ -264,7 +263,6 @@ public class SearchBoard public int possibleTargetsFrom(Pawn shooter, Collection targets) { - targets.clear(); searchCount += 1; Node adjacents[] = new Node[6]; diff --git a/core/src/ch/asynk/rustanddust/game/map/Map1Units.java b/core/src/ch/asynk/rustanddust/game/map/Map1Units.java index c018d56..3aa0c8d 100644 --- a/core/src/ch/asynk/rustanddust/game/map/Map1Units.java +++ b/core/src/ch/asynk/rustanddust/game/map/Map1Units.java @@ -38,10 +38,9 @@ public abstract class Map1Units extends Map0Hex public int collectMoveable(Unit unit) { + activableUnits.clear(); if (unit.canHQMove()) collectMoveAssists(unit, activableUnits.asPawns()); - else - activableUnits.clear(); if (unit.canMove()) activableUnits.add(unit); @@ -51,15 +50,15 @@ public abstract class Map1Units extends Map0Hex public int collectTargets(Unit unit, UnitList foes) { + targetUnits.clear(); if (unit.canEngage()) return collectPossibleTargets(unit, foes.asPawns(), targetUnits.asPawns()); - - targetUnits.clear(); return 0; } public int collectAssists(Unit unit, Unit target, UnitList units) { + activableUnits.clear(); int s = collectAttackAssists(unit, target, units.asPawns(), activableUnits.asPawns()); activatedUnits.add(unit); return s; diff --git a/core/src/ch/asynk/rustanddust/game/map/Map2Moves.java b/core/src/ch/asynk/rustanddust/game/map/Map2Moves.java index 4f87971..e7ba8ce 100644 --- a/core/src/ch/asynk/rustanddust/game/map/Map2Moves.java +++ b/core/src/ch/asynk/rustanddust/game/map/Map2Moves.java @@ -45,10 +45,9 @@ public abstract class Map2Moves extends Map1Units public int movesCollect(Unit unit) { + moves.clear(); if (unit.canMove()) return collectPossibleMoves(unit, moves); - - moves.clear(); return 0; } -- cgit v1.1-2-g2b99