From 2ebdd6789550b4e4f35cb976464e28982cd5fb41 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 10 Mar 2018 22:30:38 +0900 Subject: [PATCH] =?UTF-8?q?othello/games/show=20=E3=81=AB=E3=83=9C?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=81=AE=E7=8A=B6=E6=85=8B=E3=82=84=E3=82=BF?= =?UTF-8?q?=E3=83=BC=E3=83=B3=E6=83=85=E5=A0=B1=E3=82=92=E5=90=AB=E3=82=81?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/endpoints/othello/games/show.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/api/endpoints/othello/games/show.ts b/src/api/endpoints/othello/games/show.ts index 9dc8f2490..2b0db4dd0 100644 --- a/src/api/endpoints/othello/games/show.ts +++ b/src/api/endpoints/othello/games/show.ts @@ -1,5 +1,6 @@ import $ from 'cafy'; import Game, { pack } from '../../../models/othello-game'; +import Othello from '../../../../common/othello/core'; module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'game_id' parameter @@ -12,5 +13,20 @@ module.exports = (params, user) => new Promise(async (res, rej) => { return rej('game not found'); } - res(await pack(game, user)); + const o = new Othello(game.settings.map, { + isLlotheo: game.settings.is_llotheo, + canPutEverywhere: game.settings.can_put_everywhere, + loopedBoard: game.settings.looped_board + }); + + game.logs.forEach(log => { + o.put(log.color, log.pos); + }); + + const packed = await pack(game, user); + + res(Object.assign({ + board: o.board, + turn: o.turn + }, packed)); });