public void SetCurrentPlayer(Player player) { ConsolePlayer consolePlayer = player as ConsolePlayer; while (true) { Console.WriteLine("{0}, you're up - enter two-digit number: ", consolePlayer.Name); string response = Console.ReadLine(); int xycoord; if (int.TryParse(response, out xycoord)) { int x = xycoord/10; int y = xycoord%10; if( m_game.PlayerResponse(consolePlayer, x, y) ) { return; } } else { Console.WriteLine("Bad input, try again!"); } } }
public bool TryAddPlayer(Player player) { if (m_players.Count == m_maxPlayers) { return false; } m_players.Add(player); return true; }
public bool PlayerResponse(Player player, int x, int y) { if (player != m_players[m_currentPlayer]) { m_view.PlayerOutOfTurn(player); return false; } ISlot slot = m_board[y][x]; if( slot.Hidden ) { slot.Uncover(); if( slot.Mine ) { // Yay! Mine! Give point and continue player.AddPoint(); m_view.PointAdded(player); } else { // Not a mine, so hand over to next player m_currentPlayer = (m_currentPlayer + 1) % m_maxPlayers; } } else { // Umm... already uncovered - do nothing. } // This ends game after 6 turns just to demonstrate an ending condition. (Normally, someone would win or something) m_currentTurn++; if (m_currentTurn >= 6) { m_view.GameTied(); m_gameOver = true; } return true; }
public void SetCurrentPlayer(Player player) { throw new Exception("The method or operation is not implemented."); }
public void PointAdded(Player player) { throw new Exception("The method or operation is not implemented."); }
public void PlayerOutOfTurn(Player player) { throw new Exception("The method or operation is not implemented."); }
public void PointAdded(Player player) { ConsolePlayer consolePlayer = player as ConsolePlayer; Console.WriteLine("{0} got a point, score is now {1}", consolePlayer.Name, consolePlayer.Score ); }
public void PlayerOutOfTurn(Player player) { ConsolePlayer consolePlayer = player as ConsolePlayer; Console.WriteLine("{0}, it's not your turn!", consolePlayer.Name); }