summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-01 09:39:06 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-01 09:39:06 +0200
commitf9666a530c1834f23f64d4a0bd34eeab066c0560 (patch)
treee3b1b2f80cb9e6527633b211baea6d54a83fc27d
parent816dce94f0cbf800853229da045adc382cfc6403 (diff)
downloadRustAndDust-f9666a530c1834f23f64d4a0bd34eeab066c0560.zip
RustAndDust-f9666a530c1834f23f64d4a0bd34eeab066c0560.tar.gz
SearchBoard: add boolean inMap()
-rw-r--r--core/src/ch/asynk/tankontank/engine/SearchBoard.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/SearchBoard.java b/core/src/ch/asynk/tankontank/engine/SearchBoard.java
index fea114a..536ea85 100644
--- a/core/src/ch/asynk/tankontank/engine/SearchBoard.java
+++ b/core/src/ch/asynk/tankontank/engine/SearchBoard.java
@@ -71,6 +71,18 @@ public class SearchBoard
this.los = new Vector<Node>(10);
}
+ private boolean inMap(int col, int row)
+ {
+ if ((row < 0) || (row >= rows))
+ return false;
+
+ int colOffset = ((row + 1) / 2);
+ if ((col < colOffset) || ((col - colOffset) >= cols))
+ return false;
+
+ return true;
+ }
+
private Node getNode(int col, int row)
{
int colOffset = ((row + 1) / 2);