From 244215f09bfe101fea8e8254aa46d26f736d6219 Mon Sep 17 00:00:00 2001 From: Tissevert Date: Thu, 30 Jan 2020 21:00:40 +0100 Subject: [PATCH] Game coordinates store months' names, not their index so get the index first before comparing --- js/Games.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/Games.js b/js/Games.js index 078fa5c..369cd19 100644 --- a/js/Games.js +++ b/js/Games.js @@ -1,3 +1,4 @@ +import Flower from Hanafuda; import Messaging; import player from Room; import Save; @@ -62,9 +63,11 @@ function isAgainst(state, playerID) { } function compare(gameCoordinatesA, gameCoordinatesB) { - if(gameCoordinatesA.month < gameCoordinatesB.month) { + var monthIndexA = Flower[gameCoordinatesA.month]; + var monthIndexB = Flower[gameCoordinatesB.month]; + if(monthNumberA < monthNumberB) { return -1; - } else if(gameCoordinatesA.month > gameCoordinatesB.month) { + } else if(monthIndexA > monthIndexB) { return 1; } else if(gameCoordinatesA.turn < gameCoordinatesB.turn) { return -1;