import { GameStatus } from './constants';

const hasGameEnded = game =>
  game.gameBoard.every(row => row.every(tile => tile.color !== 'white'));

export const getGameStatus = (game) => {
  if (!game.player2) {
    return GameStatus.WaitingForPlayerToJoin;
  }

  return hasGameEnded(game) ? GameStatus.Ended : GameStatus.WaitingForTurn;
};
