summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/engine
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-05 10:55:14 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-05 10:55:14 +0100
commitfbed4659a16b7e28ab960e28f11d11b841ed1d86 (patch)
treeca4ee5fcb8fb5a1045af203679970f7ef9da1d1f /core/src/ch/asynk/tankontank/engine
parent802c84833d1d510d45f0bc9a03049e199d2159ce (diff)
downloadRustAndDust-fbed4659a16b7e28ab960e28f11d11b841ed1d86.zip
RustAndDust-fbed4659a16b7e28ab960e28f11d11b841ed1d86.tar.gz
PossiblePaths: support int init(Pawn pawn, Tile from, Tile to)
Diffstat (limited to 'core/src/ch/asynk/tankontank/engine')
-rw-r--r--core/src/ch/asynk/tankontank/engine/PossiblePaths.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/PossiblePaths.java b/core/src/ch/asynk/tankontank/engine/PossiblePaths.java
index 55a5cd9..bcda72b 100644
--- a/core/src/ch/asynk/tankontank/engine/PossiblePaths.java
+++ b/core/src/ch/asynk/tankontank/engine/PossiblePaths.java
@@ -13,6 +13,7 @@ public class PossiblePaths implements Iterable<Vector3>
private final Board board;
public Pawn pawn;
+ public Tile from;
public Tile to;
public Orientation orientation;
private List<Tile> stack;
@@ -34,15 +35,21 @@ public class PossiblePaths implements Iterable<Vector3>
this.orientation = Orientation.KEEP;
}
- public int init(Pawn pawn, Tile to)
+ public int init(Pawn pawn, Tile from, Tile to)
{
clear();
this.pawn = pawn;
+ this.from = from;
this.to = to;
return build();
}
+ public int init(Pawn pawn, Tile to)
+ {
+ return init(pawn, pawn.getTile(), to);
+ }
+
public void clear()
{
for (List<Tile> tiles : this.paths) tiles.clear();
@@ -78,7 +85,6 @@ public class PossiblePaths implements Iterable<Vector3>
private int build()
{
// from and to are not part of the path
- Tile from = pawn.getTile();
if (board.distance(from, to) == 1) {
ArrayList<Tile> temp = new ArrayList<Tile>(0);
// temp.add(from);
@@ -199,7 +205,7 @@ public class PossiblePaths implements Iterable<Vector3>
{
int steps = 0;
- Tile tile = pawn.getTile();
+ Tile tile = from;
Orientation o = pawn.getOrientation();
for (Tile next : getPath(idx)) {
Orientation nextO = Orientation.fromMove(tile.col, tile.row, next.col, next.row);
@@ -221,7 +227,7 @@ public class PossiblePaths implements Iterable<Vector3>
@Override
public Iterator<Vector3> iterator()
{
- return new Vector3Iterator(pawn, to, orientation, getPath(0));
+ return new Vector3Iterator(pawn, from, to, orientation, getPath(0));
}
private void printToErr(String what, List<ArrayList<Tile>> paths)
@@ -248,13 +254,13 @@ class Vector3Iterator implements Iterator<Vector3>
private int i;
private List<Tile> path;
- public Vector3Iterator(Pawn pawn, Tile to, Orientation orientation, List<Tile> path)
+ public Vector3Iterator(Pawn pawn, Tile from, Tile to, Orientation orientation, List<Tile> path)
{
this.pawn = pawn;
this.to = to;
+ this.tile = from;
this.orientation = orientation;
this.path = path;
- this.tile = pawn.getTile();
this.o = pawn.getOrientation();
this.v.set(pawn.getPosition().x, pawn.getPosition().y, o.r());
this.i = 0;