mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-14 22:17:30 -07:00
✌️
This commit is contained in:
parent
49dcfb7c1d
commit
b23e533d70
1 changed files with 14 additions and 11 deletions
|
@ -38,49 +38,49 @@ export default class Othello extends EventEmitter {
|
||||||
switch (r[0]) {
|
switch (r[0]) {
|
||||||
case 0: // 上
|
case 0: // 上
|
||||||
for (let c = 0, _y = y - 1; c < r[1]; c++, _y--) {
|
for (let c = 0, _y = y - 1; c < r[1]; c++, _y--) {
|
||||||
this.board[x][_y] = color;
|
this.board[_y][x] = color;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: // 右上
|
case 1: // 右上
|
||||||
for (let c = 0, i = 1; c < r[1]; c++, i++) {
|
for (let c = 0, i = 1; c < r[1]; c++, i++) {
|
||||||
this.board[x + i][y - i] = color;
|
this.board[y - i][x + i] = color;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: // 右
|
case 2: // 右
|
||||||
for (let c = 0, _x = x + 1; c < r[1]; c++, _x++) {
|
for (let c = 0, _x = x + 1; c < r[1]; c++, _x++) {
|
||||||
this.board[_x][y] = color;
|
this.board[y][_x] = color;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: // 右下
|
case 3: // 右下
|
||||||
for (let c = 0, i = 1; c < r[1]; c++, i++) {
|
for (let c = 0, i = 1; c < r[1]; c++, i++) {
|
||||||
this.board[x + i][y + i] = color;
|
this.board[y + i][x + i] = color;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4: // 下
|
case 4: // 下
|
||||||
for (let c = 0, _y = y + 1; c < r[1]; c++, _y++) {
|
for (let c = 0, _y = y + 1; c < r[1]; c++, _y++) {
|
||||||
this.board[x][_y] = color;
|
this.board[_y][x] = color;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5: // 左下
|
case 5: // 左下
|
||||||
for (let c = 0, i = 1; c < r[1]; c++, i++) {
|
for (let c = 0, i = 1; c < r[1]; c++, i++) {
|
||||||
this.board[x - i][y + i] = color;
|
this.board[y + i][x - i] = color;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6: // 左
|
case 6: // 左
|
||||||
for (let c = 0, _x = x - 1; c < r[1]; c++, _x--) {
|
for (let c = 0, _x = x - 1; c < r[1]; c++, _x--) {
|
||||||
this.board[_x][y] = color;
|
this.board[y][_x] = color;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7: // 左上
|
case 7: // 左上
|
||||||
for (let c = 0, i = 1; c < r[1]; c++, i++) {
|
for (let c = 0, i = 1; c < r[1]; c++, i++) {
|
||||||
this.board[x - i][y - i] = color;
|
this.board[y - i][x - i] = color;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -117,11 +117,11 @@ export default class Othello extends EventEmitter {
|
||||||
return (x, y): any => {
|
return (x, y): any => {
|
||||||
if (breaked) {
|
if (breaked) {
|
||||||
return;
|
return;
|
||||||
} else if (this.board[x][y] == myColor && opponentStoneFound) {
|
} else if (this.board[y][x] == myColor && opponentStoneFound) {
|
||||||
return true;
|
return true;
|
||||||
} else if (this.board[x][y] == myColor && !opponentStoneFound) {
|
} else if (this.board[y][x] == myColor && !opponentStoneFound) {
|
||||||
breaked = true;
|
breaked = true;
|
||||||
} else if (this.board[x][y] == opponentColor) {
|
} else if (this.board[y][x] == opponentColor) {
|
||||||
opponentStoneFound = true;
|
opponentStoneFound = true;
|
||||||
} else {
|
} else {
|
||||||
breaked = true;
|
breaked = true;
|
||||||
|
@ -209,16 +209,19 @@ export default class Othello extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public toString(): string {
|
public toString(): string {
|
||||||
|
//return this.board.map(row => row.map(state => state === 'black' ? '●' : state === 'white' ? '○' : '┼').join('')).join('\n');
|
||||||
return this.board.map(row => row.map(state => state === 'black' ? '⚫️' : state === 'white' ? '⚪️' : '🔹').join('')).join('\n');
|
return this.board.map(row => row.map(state => state === 'black' ? '⚫️' : state === 'white' ? '⚪️' : '🔹').join('')).join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
public toPatternString(color): string {
|
public toPatternString(color): string {
|
||||||
|
//const num = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
||||||
const num = ['0️⃣', '1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣', '🔟'];
|
const num = ['0️⃣', '1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣', '🔟'];
|
||||||
|
|
||||||
const pattern = this.getPattern(color);
|
const pattern = this.getPattern(color);
|
||||||
|
|
||||||
return this.board.map((row, y) => row.map((state, x) => {
|
return this.board.map((row, y) => row.map((state, x) => {
|
||||||
const i = pattern.findIndex(p => p[0] == x && p[1] == y);
|
const i = pattern.findIndex(p => p[0] == x && p[1] == y);
|
||||||
|
//return state === 'black' ? '●' : state === 'white' ? '○' : i != -1 ? num[i] : '┼';
|
||||||
return state === 'black' ? '⚫️' : state === 'white' ? '⚪️' : i != -1 ? num[i] : '🔹';
|
return state === 'black' ? '⚫️' : state === 'white' ? '⚪️' : i != -1 ? num[i] : '🔹';
|
||||||
}).join('')).join('\n');
|
}).join('')).join('\n');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue