summaryrefslogtreecommitdiff
path: root/src/games
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2019-04-13 01:43:22 +0900
committerGitHub <noreply@github.com>2019-04-13 01:43:22 +0900
commit987168b863c52d0548050ffbac569782bb9a8cef (patch)
treec9aa2243dcdcbd044688d201a51c601574bff259 /src/games
parentFix bug (diff)
downloadmisskey-987168b863c52d0548050ffbac569782bb9a8cef.tar.gz
misskey-987168b863c52d0548050ffbac569782bb9a8cef.tar.bz2
misskey-987168b863c52d0548050ffbac569782bb9a8cef.zip
strictNullChecks (#4666)
* wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip
Diffstat (limited to 'src/games')
-rw-r--r--src/games/reversi/core.ts16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/games/reversi/core.ts b/src/games/reversi/core.ts
index bb27d6f803..cf8986263b 100644
--- a/src/games/reversi/core.ts
+++ b/src/games/reversi/core.ts
@@ -37,7 +37,7 @@ export type Undo = {
/**
* ターン
*/
- turn: Color;
+ turn: Color | null;
};
/**
@@ -47,12 +47,12 @@ export default class Reversi {
public map: MapPixel[];
public mapWidth: number;
public mapHeight: number;
- public board: Color[];
- public turn: Color = BLACK;
+ public board: (Color | null | undefined)[];
+ public turn: Color | null = BLACK;
public opts: Options;
public prevPos = -1;
- public prevColor: Color = null;
+ public prevColor: Color | null = null;
private logs: Undo[] = [];
@@ -145,12 +145,12 @@ export default class Reversi {
// ターン計算
this.turn =
this.canPutSomewhere(!this.prevColor) ? !this.prevColor :
- this.canPutSomewhere(this.prevColor) ? this.prevColor :
+ this.canPutSomewhere(this.prevColor!) ? this.prevColor :
null;
}
public undo() {
- const undo = this.logs.pop();
+ const undo = this.logs.pop()!;
this.prevColor = undo.color;
this.prevPos = undo.pos;
this.board[undo.pos] = null;
@@ -254,10 +254,10 @@ export default class Reversi {
/**
* ゲームの勝者 (null = 引き分け)
*/
- public get winner(): Color {
+ public get winner(): Color | null {
return this.isEnded ?
this.blackCount == this.whiteCount ? null :
this.opts.isLlotheo === this.blackCount > this.whiteCount ? WHITE : BLACK :
- undefined;
+ undefined as never;
}
}