lint fixes

This commit is contained in:
syuilo 2024-01-20 09:59:04 +09:00
parent bc7b2f1876
commit e2985cf122
2 changed files with 95 additions and 97 deletions

View file

@ -67,8 +67,7 @@ export class Game {
//#endregion //#endregion
// ゲームが始まった時点で片方の色の石しかないか、始まった時点で勝敗が決定するようなマップの場合がある // ゲームが始まった時点で片方の色の石しかないか、始まった時点で勝敗が決定するようなマップの場合がある
if (!this.canPutSomewhere(BLACK)) if (!this.canPutSomewhere(BLACK)) this.turn = this.canPutSomewhere(WHITE) ? WHITE : null;
this.turn = this.canPutSomewhere(WHITE) ? WHITE : null;
} }
public get blackCount() { public get blackCount() {
@ -109,7 +108,7 @@ export class Game {
color, color,
pos, pos,
effects, effects,
turn turn,
}); });
this.calcTurn(); this.calcTurn();
@ -151,7 +150,7 @@ export class Game {
public canPut(color: Color, pos: number): boolean { public canPut(color: Color, pos: number): boolean {
return ( return (
this.board[pos] !== null ? false : // 既に石が置いてある場所には打てない this.board[pos] !== null ? false : // 既に石が置いてある場所には打てない
this.opts.canPutEverywhere ? this.mapDataGet(pos) == 'empty' : // 挟んでなくても置けるモード this.opts.canPutEverywhere ? this.mapDataGet(pos) === 'empty' : // 挟んでなくても置けるモード
this.effects(color, pos).length !== 0); // 相手の石を1つでも反転させられるか this.effects(color, pos).length !== 0); // 相手の石を1つでも反転させられるか
} }
@ -171,7 +170,7 @@ export class Game {
[0, +1], // 下 [0, +1], // 下
[-1, +1], // 左下 [-1, +1], // 左下
[-1, 0], // 左 [-1, 0], // 左
[-1, -1] // 左上 [-1, -1], // 左上
]; ];
const effectsInLine = ([dx, dy]: [number, number]): number[] => { const effectsInLine = ([dx, dy]: [number, number]): number[] => {
@ -185,11 +184,10 @@ export class Game {
// 座標が指し示す位置がボード外に出たとき // 座標が指し示す位置がボード外に出たとき
if (this.opts.loopedBoard && this.xyToPos( if (this.opts.loopedBoard && this.xyToPos(
(x = ((x % this.mapWidth) + this.mapWidth) % this.mapWidth), (x = ((x % this.mapWidth) + this.mapWidth) % this.mapWidth),
(y = ((y % this.mapHeight) + this.mapHeight) % this.mapHeight)) === initPos) (y = ((y % this.mapHeight) + this.mapHeight) % this.mapHeight)) === initPos) {
// 盤面の境界でループし、自分が石を置く位置に戻ってきたとき、挟めるようにしている (ref: Test4のマップ) // 盤面の境界でループし、自分が石を置く位置に戻ってきたとき、挟めるようにしている (ref: Test4のマップ)
return found; return found;
else if (x === -1 || y === -1 || x === this.mapWidth || y === this.mapHeight) } else if (x === -1 || y === -1 || x === this.mapWidth || y === this.mapHeight) return []; // 挟めないことが確定 (盤面外に到達)
return []; // 挟めないことが確定 (盤面外に到達)
const pos = this.xyToPos(x, y); const pos = this.xyToPos(x, y);
if (this.mapDataGet(pos) === 'null') return []; // 挟めないことが確定 (配置不可能なマスに到達) if (this.mapDataGet(pos) === 'null') return []; // 挟めないことが確定 (配置不可能なマスに到達)
@ -209,7 +207,7 @@ export class Game {
public get winner(): Color | null { public get winner(): Color | null {
return this.isEnded ? return this.isEnded ?
this.blackCount == this.whiteCount ? null : this.blackCount === this.whiteCount ? null :
this.opts.isLlotheo === this.blackCount > this.whiteCount ? WHITE : BLACK : this.opts.isLlotheo === this.blackCount > this.whiteCount ? WHITE : BLACK :
undefined as never; undefined as never;
} }

View file

@ -27,8 +27,8 @@ export const fourfour: Map = {
'----', '----',
'-wb-', '-wb-',
'-bw-', '-bw-',
'----' '----',
] ],
}; };
export const sixsix: Map = { export const sixsix: Map = {
@ -40,8 +40,8 @@ export const sixsix: Map = {
'--wb--', '--wb--',
'--bw--', '--bw--',
'------', '------',
'------' '------',
] ],
}; };
export const roundedSixsix: Map = { export const roundedSixsix: Map = {
@ -54,8 +54,8 @@ export const roundedSixsix: Map = {
'--wb--', '--wb--',
'--bw--', '--bw--',
'------', '------',
' ---- ' ' ---- ',
] ],
}; };
export const roundedSixsix2: Map = { export const roundedSixsix2: Map = {
@ -68,8 +68,8 @@ export const roundedSixsix2: Map = {
'--wb--', '--wb--',
'--bw--', '--bw--',
' ---- ', ' ---- ',
' -- ' ' -- ',
] ],
}; };
export const eighteight: Map = { export const eighteight: Map = {
@ -83,8 +83,8 @@ export const eighteight: Map = {
'---bw---', '---bw---',
'--------', '--------',
'--------', '--------',
'--------' '--------',
] ],
}; };
export const eighteightH28: Map = { export const eighteightH28: Map = {
@ -98,8 +98,8 @@ export const eighteightH28: Map = {
'b--bw--b', 'b--bw--b',
'b------b', 'b------b',
'b------b', 'b------b',
'bbbbbbbb' 'bbbbbbbb',
] ],
}; };
export const roundedEighteight: Map = { export const roundedEighteight: Map = {
@ -114,8 +114,8 @@ export const roundedEighteight: Map = {
'---bw---', '---bw---',
'--------', '--------',
'--------', '--------',
' ------ ' ' ------ ',
] ],
}; };
export const roundedEighteight2: Map = { export const roundedEighteight2: Map = {
@ -130,8 +130,8 @@ export const roundedEighteight2: Map = {
'---bw---', '---bw---',
'--------', '--------',
' ------ ', ' ------ ',
' ---- ' ' ---- ',
] ],
}; };
export const roundedEighteight3: Map = { export const roundedEighteight3: Map = {
@ -146,8 +146,8 @@ export const roundedEighteight3: Map = {
'---bw---', '---bw---',
' ------ ', ' ------ ',
' ---- ', ' ---- ',
' -- ' ' -- ',
] ],
}; };
export const eighteightWithNotch: Map = { export const eighteightWithNotch: Map = {
@ -162,8 +162,8 @@ export const eighteightWithNotch: Map = {
' --bw-- ', ' --bw-- ',
'--------', '--------',
'--------', '--------',
'--- ---' '--- ---',
] ],
}; };
export const eighteightWithSomeHoles: Map = { export const eighteightWithSomeHoles: Map = {
@ -178,8 +178,8 @@ export const eighteightWithSomeHoles: Map = {
'---bw- -', '---bw- -',
' -------', ' -------',
'--- ----', '--- ----',
'--------' '--------',
] ],
}; };
export const circle: Map = { export const circle: Map = {
@ -194,8 +194,8 @@ export const circle: Map = {
'---bw---', '---bw---',
' ------ ', ' ------ ',
' ------ ', ' ------ ',
' -- ' ' -- ',
] ],
}; };
export const smile: Map = { export const smile: Map = {
@ -210,8 +210,8 @@ export const smile: Map = {
'-- bw --', '-- bw --',
'--- ---', '--- ---',
'--------', '--------',
' ------ ' ' ------ ',
] ],
}; };
export const window: Map = { export const window: Map = {
@ -226,8 +226,8 @@ export const window: Map = {
'---bw---', '---bw---',
'- -- -', '- -- -',
'- -- -', '- -- -',
'--------' '--------',
] ],
}; };
export const reserved: Map = { export const reserved: Map = {
@ -242,8 +242,8 @@ export const reserved: Map = {
'---bw---', '---bw---',
'--------', '--------',
'--------', '--------',
'b------w' 'b------w',
] ],
}; };
export const x: Map = { export const x: Map = {
@ -258,8 +258,8 @@ export const x: Map = {
'---bw---', '---bw---',
'--b--w--', '--b--w--',
'-b----w-', '-b----w-',
'b------w' 'b------w',
] ],
}; };
export const parallel: Map = { export const parallel: Map = {
@ -274,8 +274,8 @@ export const parallel: Map = {
'---ww---', '---ww---',
'--------', '--------',
'--------', '--------',
'--------' '--------',
] ],
}; };
export const lackOfBlack: Map = { export const lackOfBlack: Map = {
@ -289,8 +289,8 @@ export const lackOfBlack: Map = {
'---bw---', '---bw---',
'--------', '--------',
'--------', '--------',
'--------' '--------',
] ],
}; };
export const squareParty: Map = { export const squareParty: Map = {
@ -305,8 +305,8 @@ export const squareParty: Map = {
'-bbbwww-', '-bbbwww-',
'-b-bw-w-', '-b-bw-w-',
'-bbbwww-', '-bbbwww-',
'--------' '--------',
] ],
}; };
export const minesweeper: Map = { export const minesweeper: Map = {
@ -321,8 +321,8 @@ export const minesweeper: Map = {
'-w-bw-b-', '-w-bw-b-',
'b-w--b-w', 'b-w--b-w',
'-b-bw-w-', '-b-bw-w-',
'w-w--b-b' 'w-w--b-b',
] ],
}; };
export const tenthtenth: Map = { export const tenthtenth: Map = {
@ -338,8 +338,8 @@ export const tenthtenth: Map = {
'----------', '----------',
'----------', '----------',
'----------', '----------',
'----------' '----------',
] ],
}; };
export const hole: Map = { export const hole: Map = {
@ -356,8 +356,8 @@ export const hole: Map = {
'--wb--wb--', '--wb--wb--',
'--bw--bw--', '--bw--bw--',
'----------', '----------',
'----------' '----------',
] ],
}; };
export const grid: Map = { export const grid: Map = {
@ -374,8 +374,8 @@ export const grid: Map = {
'- - -- - -', '- - -- - -',
'----------', '----------',
'- - -- - -', '- - -- - -',
'----------' '----------',
] ],
}; };
export const cross: Map = { export const cross: Map = {
@ -392,8 +392,8 @@ export const cross: Map = {
'----------', '----------',
' ---- ', ' ---- ',
' ---- ', ' ---- ',
' ---- ' ' ---- ',
] ],
}; };
export const charX: Map = { export const charX: Map = {
@ -410,8 +410,8 @@ export const charX: Map = {
' -------- ', ' -------- ',
'----------', '----------',
'---- ----', '---- ----',
'--- ---' '--- ---',
] ],
}; };
export const charY: Map = { export const charY: Map = {
@ -428,8 +428,8 @@ export const charY: Map = {
' ------ ', ' ------ ',
' ------ ', ' ------ ',
' ------ ', ' ------ ',
' ------ ' ' ------ ',
] ],
}; };
export const walls: Map = { export const walls: Map = {
@ -446,8 +446,8 @@ export const walls: Map = {
'w--------w', 'w--------w',
'w--------w', 'w--------w',
'w--------w', 'w--------w',
' bbbbbbbb ' ' bbbbbbbb ',
] ],
}; };
export const cpu: Map = { export const cpu: Map = {
@ -464,8 +464,8 @@ export const cpu: Map = {
'w--------w', 'w--------w',
' -------- ', ' -------- ',
'w--------w', 'w--------w',
' b b b b ' ' b b b b ',
] ],
}; };
export const checker: Map = { export const checker: Map = {
@ -482,8 +482,8 @@ export const checker: Map = {
'---bwbw---', '---bwbw---',
'----------', '----------',
'----------', '----------',
'----------' '----------',
] ],
}; };
export const japaneseCurry: Map = { export const japaneseCurry: Map = {
@ -500,8 +500,8 @@ export const japaneseCurry: Map = {
'w-w-w-b-b-', 'w-w-w-b-b-',
'-w-w-w-b-b', '-w-w-w-b-b',
'w-w-w-w-b-', 'w-w-w-w-b-',
'-w-w-w-w-b' '-w-w-w-w-b',
] ],
}; };
export const mosaic: Map = { export const mosaic: Map = {
@ -519,7 +519,7 @@ export const mosaic: Map = {
' - - - - -', ' - - - - -',
'- - - - - ', '- - - - - ',
' - - - - -', ' - - - - -',
] ],
}; };
export const arena: Map = { export const arena: Map = {
@ -536,8 +536,8 @@ export const arena: Map = {
' -------- ', ' -------- ',
'- ------ -', '- ------ -',
' - - - - ', ' - - - - ',
'- - -- - -' '- - -- - -',
] ],
}; };
export const reactor: Map = { export const reactor: Map = {
@ -554,8 +554,8 @@ export const reactor: Map = {
'---w b---', '---w b---',
'- --bw-- -', '- --bw-- -',
'w- - - -b', 'w- - - -b',
'-b------w-' '-b------w-',
] ],
}; };
export const sixeight: Map = { export const sixeight: Map = {
@ -569,8 +569,8 @@ export const sixeight: Map = {
'--bw--', '--bw--',
'------', '------',
'------', '------',
'------' '------',
] ],
}; };
export const spark: Map = { export const spark: Map = {
@ -587,8 +587,8 @@ export const spark: Map = {
' -------- ', ' -------- ',
' -------- ', ' -------- ',
'----------', '----------',
' - - ' ' - - ',
] ],
}; };
export const islands: Map = { export const islands: Map = {
@ -605,8 +605,8 @@ export const islands: Map = {
' --------', ' --------',
' --------', ' --------',
' --------', ' --------',
' --------' ' --------',
] ],
}; };
export const galaxy: Map = { export const galaxy: Map = {
@ -625,8 +625,8 @@ export const galaxy: Map = {
'---w--bbb---', '---w--bbb---',
' ---w------ ', ' ---w------ ',
' ---www-- ', ' ---www-- ',
' ------ ' ' ------ ',
] ],
}; };
export const triangle: Map = { export const triangle: Map = {
@ -643,8 +643,8 @@ export const triangle: Map = {
' -------- ', ' -------- ',
' -------- ', ' -------- ',
'----------', '----------',
'----------' '----------',
] ],
}; };
export const iphonex: Map = { export const iphonex: Map = {
@ -663,8 +663,8 @@ export const iphonex: Map = {
'--------', '--------',
'--------', '--------',
'--------', '--------',
' ------ ' ' ------ ',
] ],
}; };
export const dealWithIt: Map = { export const dealWithIt: Map = {
@ -676,8 +676,8 @@ export const dealWithIt: Map = {
'--w-b-------', '--w-b-------',
' --b-w------', ' --b-w------',
' --w-b---- ', ' --w-b---- ',
' ------- ' ' ------- ',
] ],
}; };
export const bigBoard: Map = { export const bigBoard: Map = {
@ -699,8 +699,8 @@ export const bigBoard: Map = {
'----------------', '----------------',
'----------------', '----------------',
'----------------', '----------------',
'----------------' '----------------',
] ],
}; };
export const twoBoard: Map = { export const twoBoard: Map = {
@ -715,6 +715,6 @@ export const twoBoard: Map = {
'---bw--- ---bw---', '---bw--- ---bw---',
'-------- --------', '-------- --------',
'-------- --------', '-------- --------',
'-------- --------' '-------- --------',
] ],
}; };