Game coordinates store months' names, not their index so get the index first before comparing

This commit is contained in:
Tissevert 2020-01-30 21:00:40 +01:00
parent 313d91bcaf
commit 244215f09b

View file

@ -1,3 +1,4 @@
import Flower from Hanafuda;
import Messaging; import Messaging;
import player from Room; import player from Room;
import Save; import Save;
@ -62,9 +63,11 @@ function isAgainst(state, playerID) {
} }
function compare(gameCoordinatesA, gameCoordinatesB) { function compare(gameCoordinatesA, gameCoordinatesB) {
if(gameCoordinatesA.month < gameCoordinatesB.month) { var monthIndexA = Flower[gameCoordinatesA.month];
var monthIndexB = Flower[gameCoordinatesB.month];
if(monthNumberA < monthNumberB) {
return -1; return -1;
} else if(gameCoordinatesA.month > gameCoordinatesB.month) { } else if(monthIndexA > monthIndexB) {
return 1; return 1;
} else if(gameCoordinatesA.turn < gameCoordinatesB.turn) { } else if(gameCoordinatesA.turn < gameCoordinatesB.turn) {
return -1; return -1;