- getCurrentScore() {
- const c = this.turn,
- oppCol = V.GetOppCol(this.turn);
- let facingKings = false;
- if (
- this.kingPos[c][0] == this.kingPos[oppCol][0] ||
- this.kingPos[c][1] == this.kingPos[oppCol][1]
- ) {
- facingKings = true;
- let step = [
- this.kingPos[oppCol][0] - this.kingPos[c][0],
- this.kingPos[oppCol][1] - this.kingPos[c][1]
- ];
- if (step[0] != 0) step[0] /= Math.abs(step[0]);
- else step[1] /= Math.abs(step[1]);
- let [x, y] =
- [ this.kingPos[c][0] + step[0], this.kingPos[c][1] + step[1] ];
- while (x != this.kingPos[oppCol][0] || y != this.kingPos[oppCol][1]) {
- if (this.board[x][y] != V.EMPTY) {
- facingKings = false;
- break;
- }
- x += step[0];
- y += step[1];
- }
- }
- if (facingKings) return (c == "w" ? "1-0" : "0-1");
- if (!this.atLeastOneMove()) return (c == "w" ? "0-1" : "1-0");
- return "*";
- }
-