Follow «Coordinates» change in protocol

This commit is contained in:
Tissevert 2020-01-18 09:35:51 +01:00
parent 421b91c0ff
commit 97b0bc0cc8
2 changed files with 8 additions and 8 deletions

View file

@ -52,8 +52,8 @@ function fail(errorCode) {
} }
function getSavedState(gameID) { function getSavedState(gameID) {
var gameState = Save.get('games.message.Game#' + gameID); var coordinates = Save.get('games.message.Game#' + gameID);
return gameState != undefined ? Async.wrap(gameState) : fail('gameNotFound'); return coordinates != undefined ? Async.wrap(coordinates) : fail('gameNotFound');
} }
function startSession() { function startSession() {
@ -79,7 +79,7 @@ function initMessageHandlers() {
} }
function handleGameMessage(o) { 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 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 return Async.sequence(applyDiff(o), setGame(o)); // so play the diff, then set the new round
} else { } else {
@ -125,7 +125,7 @@ function handleTurnedCard(o, f) {
setTurned(o.state.public.step.contents); setTurned(o.state.public.step.contents);
} else { } else {
if(state.step == "ToPlay" && o.state.public.playing == o.state.public.oyake) { 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") { if(deck.lastChild.id != "rest") {
deck.removeChild(deck.lastChild); deck.removeChild(deck.lastChild);
@ -179,8 +179,8 @@ function setStatus(game) {
Dom.clear(dom.status); Dom.clear(dom.status);
state.game = game; state.game = game;
state.step = game.public.step.tag; state.step = game.public.step.tag;
if(game.public.month != state.month) { if(game.public.coordinates.month != state.month) {
state.month = game.public.month; state.month = game.public.coordinates.month;
} }
dom.status.appendChild( dom.status.appendChild(
Dom.make('li', {textContent: I18n.get('monthFlower')(I18n.get(state.month))}) Dom.make('li', {textContent: I18n.get('monthFlower')(I18n.get(state.month))})
@ -226,7 +226,7 @@ function setCardSet(set, cardNames, constructor) {
function setTheirCards(game) { function setTheirCards(game) {
var turnsTheyPlayed = Math.floor( 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); Dom.clear(sets.them.hand.dom);
for(var i = 0; i < 8 - turnsTheyPlayed; i++) { for(var i = 0; i < 8 - turnsTheyPlayed; i++) {

View file

@ -31,7 +31,7 @@ function proposal(playerID, yourTurn) {
function initMessageHandlers() { function initMessageHandlers() {
Messaging.addEventListener(["Game"], function(o) { Messaging.addEventListener(["Game"], function(o) {
var gameID = o.state.public.gameState.gameID; var gameID = o.state.public.coordinates.gameID;
var entry = makeEntry(o.state); var entry = makeEntry(o.state);
Save.set("games.message." + gameID, o); Save.set("games.message." + gameID, o);
Save.set("games.entry." + gameID, entry); Save.set("games.entry." + gameID, entry);