diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-03-13 01:49:54 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-03-13 01:49:54 +0900 |
| commit | e6f68e0b9e7f97f0a7f1c9c98c5a3839c843a100 (patch) | |
| tree | 29a782cd5b7529a7de7cc5d1462a6997e99a9ba8 /src/api | |
| parent | v4114 (diff) | |
| download | sharkey-e6f68e0b9e7f97f0a7f1c9c98c5a3839c843a100.tar.gz sharkey-e6f68e0b9e7f97f0a7f1c9c98c5a3839c843a100.tar.bz2 sharkey-e6f68e0b9e7f97f0a7f1c9c98c5a3839c843a100.zip | |
オセロで黒白を真理値で表現するように
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/models/othello-game.ts | 6 | ||||
| -rw-r--r-- | src/api/stream/othello-game.ts | 12 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/api/models/othello-game.ts b/src/api/models/othello-game.ts index 788fb5cba6..01c6ca6c00 100644 --- a/src/api/models/othello-game.ts +++ b/src/api/models/othello-game.ts @@ -25,7 +25,11 @@ export interface IGame { is_started: boolean; is_ended: boolean; winner_id: mongo.ObjectID; - logs: any[]; + logs: Array<{ + at: Date; + color: boolean; + pos: number; + }>; settings: { map: string[]; bw: string | number; diff --git a/src/api/stream/othello-game.ts b/src/api/stream/othello-game.ts index 87d26e2419..368baa2cb6 100644 --- a/src/api/stream/othello-game.ts +++ b/src/api/stream/othello-game.ts @@ -214,9 +214,9 @@ export default function(request: websocket.request, connection: websocket.connec if (o.isEnded) { let winner; - if (o.winner == 'black') { + if (o.winner === true) { winner = freshGame.black == 1 ? freshGame.user1_id : freshGame.user2_id; - } else if (o.winner == 'white') { + } else if (o.winner === false) { winner = freshGame.black == 1 ? freshGame.user2_id : freshGame.user1_id; } else { winner = null; @@ -263,17 +263,17 @@ export default function(request: websocket.request, connection: websocket.connec const myColor = (game.user1_id.equals(user._id) && game.black == 1) || (game.user2_id.equals(user._id) && game.black == 2) - ? 'black' - : 'white'; + ? true + : false; if (!o.canPut(myColor, pos)) return; o.put(myColor, pos); let winner; if (o.isEnded) { - if (o.winner == 'black') { + if (o.winner === true) { winner = game.black == 1 ? game.user1_id : game.user2_id; - } else if (o.winner == 'white') { + } else if (o.winner === false) { winner = game.black == 1 ? game.user2_id : game.user1_id; } else { winner = null; |