Beispiel #1
0
        // Player is moved, set new room player is in
        public void playerMovedRooms(int cR)
        {
            // Hide bats
            _PlayGame.hideBats();

            // Set new player location
            _Player.setLocation(cR);

            // If Wumpus is there, display WUmpus message
            if (_Map.wumpusMet(cR) && _Map.wumpusChangesRoom()) // Met Wumpus! Wumpus changed rooms
            {
                _PlayGame.setMessages("You ran into the Wumpus! But it decided to flee.");
            }
            else if (_Map.wumpusMet(cR)) // Met Wumpus! Wumpus doesnt change rooms
            {
                _PlayGame.showWumpus();
                _Trivia.newRoundofTrivia(caveNumber, 5); // Ask trivia questions
                _PlayGame.setMessages("You ran into the Wumpus! You have to defeat the Wumpus!");
                if (_Trivia.getNumQsRight() >= 3)        // If answered more than 3 questions correct, escape Wupmpus
                {
                    _PlayGame.setMessages("You've successfully escaped the Wumpus!");
                    _PlayGame.hideWumpus();
                }
                else // Failed to answer more than 3 questions correct, end game
                {
                    _PlayGame.setMessages("You've died! :(");
                    _PlayGame.Hide();
                }
            }

            // If there are bats, display bat message
            if (_Map.areThereBats(cR))
            {
                _PlayGame.setMessages("You ran into bats!");
                _PlayGame.showBats();
                _Player.changeLocation();
                //_PlayGame.refresh();
            }

            // If there are pits
            if (_Map.isTherePit(cR))
            {
                _PlayGame.setMessages("You ran into a bottomless pit!");
                _Trivia.newRoundofTrivia(caveNumber, 3); // Ask trivia questions
                if (_Trivia.getNumQsRight() >= 2)        // If answered more than 2 questions correct, escape Wupmpus
                {
                    _PlayGame.setMessages("You've successfully escaped the pit!");
                    _Player.increaseArrows();
                    _PlayGame.hideWumpus();
                }
                else  // Failed to answer more than 2 questions correct, end game
                {
                    _PlayGame.setMessages("You've died! :(");
                    _PlayGame.Hide();
                }
            }

            // If there are pits, display bottomless pit message
            if (_Map.isPitNearby(getConnectedRooms(cR)))
            {
                _PlayGame.setMessages("I feel a breeze");
            }

            // If bats nearby
            if (_Map.isBatNearby(getConnectedRooms(cR)))
            {
                _PlayGame.setMessages("I hear bats");
            }
        }