X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FGameList.vue;h=39ad9bf2375a0eec596caeccbe414a54b08ac9cc;hp=6bf0e9ac4b04ba2fd17c25482b071569e95794cc;hb=db1f1f9adb920605c7a16b060a7737e54636ee08;hpb=e891730f77312340d68bb7ef72a4207541fa3914 diff --git a/client/src/components/GameList.vue b/client/src/components/GameList.vue index 6bf0e9ac..39ad9bf2 100644 --- a/client/src/components/GameList.vue +++ b/client/src/components/GameList.vue @@ -54,6 +54,13 @@ export default { // Show in order: games where it's my turn, my running games, my games, other games let minCreated = Number.MAX_SAFE_INTEGER; let maxCreated = 0; + const isMyTurn = (g, myColor) => { + const rem = g.movesCount % 2; + return ( + (rem == 0 && myColor == "w") || + (rem == 1 && myColor == "b") + ); + }; let augmentedGames = this.games .filter(g => !this.deleted[g.id]) .map(g => { @@ -72,11 +79,7 @@ export default { : "b"; if (g.score == "*") { priority++; - // I play in this game, so g.fen will be defined - // NOTE: this is a fragile way to detect turn, - // but since V isn't defined let's do that for now. (TODO:) - //if (V.ParseFen(g.fen).turn == myColor) - if (g.fen.match(" " + myColor + " ")) priority++; + if (isMyTurn(g, myColor)) priority++; } } if (g.created < minCreated) minCreated = g.created;