Exemplo n.º 1
0
        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);
        }