public static bool IsGameOver(this GameMoveResultType result) { return(result == GameMoveResultType.AttackerOutOfPieces || result == GameMoveResultType.BothOutOfPieces || result == GameMoveResultType.DefenderOutOfPieces || result == GameMoveResultType.FlagCapturedByAttacker); }
public static GameStatus CreateForMove(GameStatus status, GameMove move, GameMoveResultType result, Token attacker, Token defender) { var active = !result.IsGameOver(); var winner = result.GetWinner(status.CurrentPlayer, status.OtherPlayer); // switch current player var currentPlayer = status.OtherPlayer; var otherPlayer = status.CurrentPlayer; return(new GameStatus(currentPlayer, otherPlayer, winner, active, move, result, attacker, defender)); }
public static GameStatus CreateForMove(GameStatus status, GameMove move, GameMoveResultType result, Token attacker, Token defender) { var active = !result.IsGameOver(); var winner = result.GetWinner(status.CurrentPlayer, status.OtherPlayer); // switch current player var currentPlayer = status.OtherPlayer; var otherPlayer = status.CurrentPlayer; return new GameStatus(currentPlayer, otherPlayer, winner, active, move, result, attacker, defender); }
public static Player GetWinner(this GameMoveResultType result, Player attacker, Player defender) { switch (result) { case GameMoveResultType.AttackerOutOfPieces: return(defender); case GameMoveResultType.DefenderOutOfPieces: return(attacker); case GameMoveResultType.FlagCapturedByAttacker: return(attacker); default: return(null); } }
public GameStatus( Player currentPlayer, Player otherPlayer, Player winner, bool gameActive, GameMove currentMove, GameMoveResultType currentMoveResult, Token attackerToken, Token defenderToken) { this.CurrentPlayer = currentPlayer; this.OtherPlayer = otherPlayer; this.Winner = winner; this.GameActive = gameActive; this.CurrentMove = currentMove; this.CurrentMoveResult = currentMoveResult; this.AttackerToken = attackerToken; this.DefenderToken = defenderToken; }
public GameStatus( Player currentPlayer, Player otherPlayer, Player winner, bool gameActive, GameMove currentMove, GameMoveResultType currentMoveResult, Token attackerToken, Token defenderToken) { this.CurrentPlayer = currentPlayer; this.OtherPlayer = otherPlayer; this.Winner = winner; this.GameActive = gameActive; this.CurrentMove = currentMove; this.CurrentMoveResult = currentMoveResult; this.AttackerToken = attackerToken; this.DefenderToken = defenderToken; }