othello/games/show にボードの状態やターン情報を含めるように

This commit is contained in:
syuilo 2018-03-10 22:30:38 +09:00
parent 1dc8ad6d0c
commit 2ebdd67895

View file

@ -1,5 +1,6 @@
import $ from 'cafy'; import $ from 'cafy';
import Game, { pack } from '../../../models/othello-game'; import Game, { pack } from '../../../models/othello-game';
import Othello from '../../../../common/othello/core';
module.exports = (params, user) => new Promise(async (res, rej) => { module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'game_id' parameter // Get 'game_id' parameter
@ -12,5 +13,20 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
return rej('game not found'); 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));
}); });