private void SetState(GoGameStatus status, decimal margin) { Status = status; var humanPlayer = Player1.PlayerType == PlayerType.Human ? Player1 : Player2; var aiPlayer = Player1.PlayerType == PlayerType.Human ? Player2 : Player1; switch (Status) { case GoGameStatus.BlackWon: if (humanPlayer.Color == GoColor.Black) { MessageText = "You win by " + margin + " points!"; } else { MessageText = aiPlayer.Name + " wins by " + margin + " points."; } break; case GoGameStatus.WhiteWon: if (humanPlayer.Color == GoColor.White) { MessageText = "You win by " + margin + " points!"; } else { MessageText = aiPlayer.Name + " wins by " + margin + " points."; } break; case GoGameStatus.BlackWonDueToResignation: if (humanPlayer.Color == GoColor.Black) { MessageText = aiPlayer.Name + " resigned. You win!"; } else { MessageText = "You resigned. " + aiPlayer.Name + " wins."; } break; case GoGameStatus.WhiteWonDueToResignation: if (humanPlayer.Color == GoColor.White) { MessageText = aiPlayer.Name + " resigned. You win!"; } else { MessageText = "You resigned. " + aiPlayer.Name + " wins."; } break; } }
public GoGameState(Guid gameId, byte size, GoPlayer player1, GoPlayer player2, GoGameStatus status, GoColor whoseTurn, string blackPositions, string whitePositions, List <GoMoveHistoryItem> goMoveHistory, decimal winMargin) { GameId = gameId; Size = size; Player1 = player1; Player2 = player2; Status = status; WhoseTurn = whoseTurn; BlackPositions = blackPositions; WhitePositions = whitePositions; GoMoveHistory = goMoveHistory; WinMargin = winMargin; }
public GoGame( byte size, GoPlayer player1, GoPlayer player2, GoGameStatus status, GoColor whoseTurn, string blackPositions, string whitePositions, List <GoMoveHistoryItem> goMoveHistory)//, decimal winMargin) : this() { Size = size; Player1 = player1; Player2 = player2; Status = status; WhoseTurn = whoseTurn; BlackPositions = blackPositions; WhitePositions = whitePositions; GoMoveHistory = goMoveHistory; Id = Guid.NewGuid(); }