Follow «Coordinates» change in protocol
This commit is contained in:
parent
421b91c0ff
commit
97b0bc0cc8
2 changed files with 8 additions and 8 deletions
|
@ -52,8 +52,8 @@ function fail(errorCode) {
|
|||
}
|
||||
|
||||
function getSavedState(gameID) {
|
||||
var gameState = Save.get('games.message.Game#' + gameID);
|
||||
return gameState != undefined ? Async.wrap(gameState) : fail('gameNotFound');
|
||||
var coordinates = Save.get('games.message.Game#' + gameID);
|
||||
return coordinates != undefined ? Async.wrap(coordinates) : fail('gameNotFound');
|
||||
}
|
||||
|
||||
function startSession() {
|
||||
|
@ -79,7 +79,7 @@ function initMessageHandlers() {
|
|||
}
|
||||
|
||||
function handleGameMessage(o) {
|
||||
if(o.state.public.gameState.turns == 0 || state.game == null) {
|
||||
if(o.state.public.coordinates.turn == 0 || state.game == null) {
|
||||
if(o.logs.length > 0) { // but still some logs, from the previous round
|
||||
return Async.sequence(applyDiff(o), setGame(o)); // so play the diff, then set the new round
|
||||
} else {
|
||||
|
@ -125,7 +125,7 @@ function handleTurnedCard(o, f) {
|
|||
setTurned(o.state.public.step.contents);
|
||||
} else {
|
||||
if(state.step == "ToPlay" && o.state.public.playing == o.state.public.oyake) {
|
||||
rest.className = ["card", "turn" + o.state.public.gameState.turns].join(' ');
|
||||
rest.className = ["card", "turn" + o.state.public.coordinates.turn].join(' ');
|
||||
}
|
||||
if(deck.lastChild.id != "rest") {
|
||||
deck.removeChild(deck.lastChild);
|
||||
|
@ -179,8 +179,8 @@ function setStatus(game) {
|
|||
Dom.clear(dom.status);
|
||||
state.game = game;
|
||||
state.step = game.public.step.tag;
|
||||
if(game.public.month != state.month) {
|
||||
state.month = game.public.month;
|
||||
if(game.public.coordinates.month != state.month) {
|
||||
state.month = game.public.coordinates.month;
|
||||
}
|
||||
dom.status.appendChild(
|
||||
Dom.make('li', {textContent: I18n.get('monthFlower')(I18n.get(state.month))})
|
||||
|
@ -226,7 +226,7 @@ function setCardSet(set, cardNames, constructor) {
|
|||
|
||||
function setTheirCards(game) {
|
||||
var turnsTheyPlayed = Math.floor(
|
||||
(game.public.gameState.turns + (Session.is(game.public.oyake) ? 0 : 1)) / 2
|
||||
(game.public.coordinates.turn + (Session.is(game.public.oyake) ? 0 : 1)) / 2
|
||||
);
|
||||
Dom.clear(sets.them.hand.dom);
|
||||
for(var i = 0; i < 8 - turnsTheyPlayed; i++) {
|
||||
|
|
|
@ -31,7 +31,7 @@ function proposal(playerID, yourTurn) {
|
|||
|
||||
function initMessageHandlers() {
|
||||
Messaging.addEventListener(["Game"], function(o) {
|
||||
var gameID = o.state.public.gameState.gameID;
|
||||
var gameID = o.state.public.coordinates.gameID;
|
||||
var entry = makeEntry(o.state);
|
||||
Save.set("games.message." + gameID, o);
|
||||
Save.set("games.entry." + gameID, entry);
|
||||
|
|
Loading…
Reference in a new issue