public void Start() { int topPlayerPoints, bottomPlayerPoints; bool keepPlaying = true; while (keepPlaying) { Play(); m_gameBoard.CalculatePointsOfPlayers(out topPlayerPoints, out bottomPlayerPoints); if (topPlayerPoints > bottomPlayerPoints) { ConsoleUI.DeclairWinnerMessege(m_topPlayer); m_topPlayer.Points = m_topPlayer.Points + topPlayerPoints - bottomPlayerPoints; } else if (topPlayerPoints < bottomPlayerPoints) { ConsoleUI.DeclairWinnerMessege(m_bottomPlayer); m_bottomPlayer.Points = m_bottomPlayer.Points + bottomPlayerPoints - topPlayerPoints; } else { ConsoleUI.DeclairTieMessege(); } ConsoleUI.LastRoundPointsMessege(m_topPlayer, topPlayerPoints, m_bottomPlayer, bottomPlayerPoints); ConsoleUI.SoFarTotalPointsMessege(m_topPlayer, m_bottomPlayer); keepPlaying = ConsoleUI.AskForAnotherGameDesire(); /*for automated start again and delay for cheking * DateTime dt = DateTime.Now + TimeSpan.FromSeconds(10); * do { } while (DateTime.Now < dt); * keepPlaying = true;*/ if (keepPlaying == true) { m_gameBoard = new Board(m_gameBoard.BoardSize); m_gameStatus = e_GameStatus.ActiveGame; } } ConsoleUI.GoodByeMessege(); }
// $G$ CSS-028 (0) method shouldn't include more then one return command. private static int CalculateDifferencePointsAfterChosenMovement(Board i_board, Movement i_movement, Player i_player) { Board tempBoard = new Board(i_board.BoardSize); tempBoard.Clone(i_board); tempBoard.ExcuteMovement(i_movement); int topPlayerPoints, bottomPlayerPoints; tempBoard.CalculatePointsOfPlayers(out topPlayerPoints, out bottomPlayerPoints); int deltaPoints = topPlayerPoints - bottomPlayerPoints; if (i_player.PlayerPosition == Player.e_PlayerPosition.Top) { return(deltaPoints); } else { return(-deltaPoints); } }