From b6b7853f387b6cf0d052cc99bfddd22793bbec2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 13 Oct 2014 16:56:23 +0200 Subject: Board: buildAttackAssists(...) -> buildAttack() returns the count of possible assists --- core/src/ch/asynk/tankontank/engine/Board.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 6c5fb63..8ad214b 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -346,24 +346,28 @@ public abstract class Board implements Disposable return assists.size(); } - protected void buildAttackAssists(Pawn pawn, GridPoint2 hex, Iterator units, ArrayList assists) + protected int buildAttack(Pawn pawn, Pawn target, GridPoint2 hex, Iterator units, ArrayList assists) { clearPointVector(assists); GridPoint2 from = null; while (units.hasNext()) { Pawn p = units.next(); - if ((p == pawn) || !p.canAttack()) continue; + if (!p.canAttack()) continue; if (from == null) from = gridPoint2Pool.obtain(); getHexUnder(p, from); - if (searchBoard.canAttack(p, from.x, from.y, hex.x, hex.y)) { - assists.add(from); - from = null; + if (searchBoard.buildAttack(p, target, from.x, from.y, hex.x, hex.y)) { + if (p != pawn) { + assists.add(from); + from = null; + } } } if (from != null) gridPoint2Pool.free(from); + + return assists.size(); } protected void clearPointSet(Set points) -- cgit v1.1-2-g2b99