summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/gdx/boardgame/boards
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2020-05-31 17:17:07 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2020-05-31 17:17:07 +0200
commit5fc05067bfcb75add378b93df3886a1c621d2ea9 (patch)
treebcf1bb91cc6787c8908bf28278058a8c0f1a41e6 /core/src/ch/asynk/gdx/boardgame/boards
parent4287bab85436fb55f1b1367f709ffe52f73ad157 (diff)
downloadgdx-boardgame-5fc05067bfcb75add378b93df3886a1c621d2ea9.zip
gdx-boardgame-5fc05067bfcb75add378b93df3886a1c621d2ea9.tar.gz
TriangleBoard : fix horizontal negative index
Diffstat (limited to 'core/src/ch/asynk/gdx/boardgame/boards')
-rw-r--r--core/src/ch/asynk/gdx/boardgame/boards/TriangleBoard.java20
1 files changed, 9 insertions, 11 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/boards/TriangleBoard.java b/core/src/ch/asynk/gdx/boardgame/boards/TriangleBoard.java
index 9b7c4bc..1a16772 100644
--- a/core/src/ch/asynk/gdx/boardgame/boards/TriangleBoard.java
+++ b/core/src/ch/asynk/gdx/boardgame/boards/TriangleBoard.java
@@ -47,7 +47,7 @@ public class TriangleBoard implements Board
this.adjacents = new Tile[3];
}
- @Override public int size() { return 0; } // FIXME
+ @Override public int size() { return cols * rows; }
@Override public int[] getAngles()
{
@@ -64,17 +64,14 @@ public class TriangleBoard implements Board
{
}
- @Override public int genKey(int x, int y) { return -1; } // FIXME
+ @Override public int genKey(int x, int y)
+ {
+ return (y * cols + x);
+ }
@Override public boolean isOnMap(int x, int y)
{
- if (this.orientation == BoardFactory.BoardOrientation.VERTICAL) {
- if ((y < 0) || (y >= rows)) return false;
- if ((x < 0) || (x >= cols)) return false;
- } else {
- if ((y < 0) || (y >= rows)) return false;
- if ((x < -1) || (x >= (cols - 1))) return false;
- }
+ if (x < 0 || x >= cols || y < 0 || y >= rows) return false;
return true;
}
@@ -87,8 +84,8 @@ public class TriangleBoard implements Board
cy += (y * this.d);
cx += ((x * this.h) + (((x + y) % 2 == 0) ? this.h23 : this.h13));
} else {
- cx += (this.d + (x * this.d));
- cy += ((y * this.h) + (((x + y) % 2 == 0) ? this.h13 : this.h23));
+ cx += (this.d + ((x -1) * this.d));
+ cy += ((y * this.h) + (((x + y) % 2 == 0) ? this.h23 : this.h13));
}
v.set(cx, cy);
@@ -146,6 +143,7 @@ public class TriangleBoard implements Board
col -= 1;
}
}
+ col += 1;
}
v.set(col, row);