summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-04-05 09:23:50 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2016-04-05 09:23:50 +0200
commit24645c441330a33db1cc2d90d8f097a2adf0b868 (patch)
treeffcb86e67e073b2719ef7f488c60ec9db54a7b4a /core/src/ch/asynk/rustanddust
parent16d5333e84dc0a2f981252d49f5cc87c82f513e2 (diff)
downloadRustAndDust-24645c441330a33db1cc2d90d8f097a2adf0b868.zip
RustAndDust-24645c441330a33db1cc2d90d8f097a2adf0b868.tar.gz
Map,Board: Map cleans Collection<Unit> before calling Board methods
Diffstat (limited to 'core/src/ch/asynk/rustanddust')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/Board.java3
-rw-r--r--core/src/ch/asynk/rustanddust/engine/SearchBoard.java2
-rw-r--r--core/src/ch/asynk/rustanddust/game/map/Map1Units.java7
-rw-r--r--core/src/ch/asynk/rustanddust/game/map/Map2Moves.java3
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<Pawn> units, Collection<Pawn> 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<Pawn> 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<Pawn> units, Collection<Pawn> 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<Tile> moves)
{
- moves.clear();
searchCount += 1;
Node adjacents[] = new Node[6];
@@ -264,7 +263,6 @@ public class SearchBoard
public int possibleTargetsFrom(Pawn shooter, Collection<Pawn> 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;
}