summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-03-10 21:48:20 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-03-10 21:48:20 +0900
commit8281249806eca3ae8447bddde9d00a1a9b3ae7a9 (patch)
tree13531865474d534bde465023e3ccf9620236cd53 /src/common
parentImprove readability (diff)
downloadsharkey-8281249806eca3ae8447bddde9d00a1a9b3ae7a9.tar.gz
sharkey-8281249806eca3ae8447bddde9d00a1a9b3ae7a9.tar.bz2
sharkey-8281249806eca3ae8447bddde9d00a1a9b3ae7a9.zip
Fix bug
Diffstat (limited to 'src/common')
-rw-r--r--src/common/othello/core.ts13
-rw-r--r--src/common/othello/maps.ts19
2 files changed, 28 insertions, 4 deletions
diff --git a/src/common/othello/core.ts b/src/common/othello/core.ts
index e7e725aaf0..3a181a3eb9 100644
--- a/src/common/othello/core.ts
+++ b/src/common/othello/core.ts
@@ -224,10 +224,15 @@ export default class Othello {
// 座標が指し示す位置がボード外に出たとき
if (this.opts.loopedBoard) {
- if (x < 0 ) x = this.mapWidth - (-x);
- if (y < 0 ) y = this.mapHeight - (-y);
- if (x >= this.mapWidth ) x = x - this.mapWidth;
- if (y >= this.mapHeight) y = y - this.mapHeight;
+ if (x < 0 ) x = this.mapWidth - ((-x) % this.mapWidth);
+ if (y < 0 ) y = this.mapHeight - ((-y) % this.mapHeight);
+ if (x >= this.mapWidth ) x = x % this.mapWidth;
+ if (y >= this.mapHeight) y = y % this.mapHeight;
+
+ // for debug
+ //if (x < 0 || y < 0 || x >= this.mapWidth || y >= this.mapHeight) {
+ // console.log(x, y);
+ //}
// 一周して自分に帰ってきたら
if (this.transformXyToPos(x, y) == initPos) break;
diff --git a/src/common/othello/maps.ts b/src/common/othello/maps.ts
index 3518259bba..81b9663c38 100644
--- a/src/common/othello/maps.ts
+++ b/src/common/othello/maps.ts
@@ -815,3 +815,22 @@ export const test2: Map = {
'-w--b-'
]
};
+
+export const test3: Map = {
+ name: 'Test3',
+ category: 'Test',
+ data: [
+ '-w-',
+ '--w',
+ 'w--',
+ '-w-',
+ '--w',
+ 'w--',
+ '-w-',
+ '--w',
+ 'w--',
+ '-w-',
+ '---',
+ 'b--',
+ ]
+};