Esempio n. 1
0
        /// <summary>
        /// Conditions to win or lose room level
        /// used within Parse class, ExecuteCommand method
        /// </summary>
        /// <returns>the command prompt after updating view with changes to the scene, room contents, and story text</returns>
        /// <param name="inputVerb">Parsed first part of user input</param>
        /// <param name="inputNoun">Parsed second part of user input</param>
        public string WinLoseLogic(string inputVerb, string inputNoun)
        {
            // Could continue on and win, but if user didn't type in 'use echidna' after shark appeared, game is over.
            if (currentRoom.DoesItemExistInRoom("echidna") && currentRoom.WaterLevel == 7 &&
                currentRoom.GetRoomContentsByName("honeybear").BeenUsed)
            {
                if (!(inputNoun == "echidna" && inputVerb == "use"))
                {
                    string scn = "Water0" + currentRoom.WaterLevel + "_EchidnaAndButton";
                    currentRoom.CurrentScene = currentRoom.GarageScenes.ScenesDictionary[scn];
                    GameState = GameState.Over;
                    view      = new View(currentRoom.CurrentScene, currentRoom.RoomContentsAsStringList, Display.Wrap("The shark eats you with a great passion. You are dead. Play again? Yes?", 60));
                }
                // if you made the correct move here, just return to get out of the method and move on to the switch case in Parse
                return(inputNoun);
            }

            // Lose logic in remaining else-if statements
            else if (!currentRoom.DoesItemExistInRoom("echidna") && currentRoom.WaterLevel == 7)
            {
                GameState = GameState.Over;
                string scn = "Water0" + currentRoom.WaterLevel + "_NoEchidna";
                currentRoom.CurrentScene = currentRoom.GarageScenes.ScenesDictionary[scn];
                view = new View(currentRoom.CurrentScene, currentRoom.RoomContentsAsStringList, Display.Wrap("The shark eats you with a great passion. You are dead. Play again? Yes?", 60));
            }
            else if (currentRoom.DoesItemExistInRoom("echidna") && currentRoom.WaterLevel == 7 &&
                     !currentRoom.GetRoomContentsByName("honeybear").BeenUsed)
            {
                GameState = GameState.Over;
                string scn = "Water0" + currentRoom.WaterLevel + "_EchidnaAndButton";
                currentRoom.CurrentScene = currentRoom.GarageScenes.ScenesDictionary[scn];
                view = new View(currentRoom.CurrentScene, currentRoom.RoomContentsAsStringList, Display.Wrap("The shark eats you with a great passion. You are dead. Play again? Yes?", 60));
            }

            else if (currentRoom.WaterLevel >= 8 &&
                     !(inputNoun == "garagedooropener" &&
                       (inputVerb == "use" || inputVerb == "push" || inputVerb == "take" || inputVerb == "touch")))
            {
                GameState = GameState.Over;
                currentRoom.CurrentScene = currentRoom.GarageScenes.ScenesDictionary["Water08_EchidnaAttackedShark"];
                view = new View(currentRoom.CurrentScene, currentRoom.RoomContentsAsStringList, Display.Wrap("The water fills the room and you and the echidna drown. Play again? Yes?", 60));
            }
            else
            {
                return(inputNoun);
            }

            return(view.UpdateScreenAndGetInput());
        }
Esempio n. 2
0
        public override string Use(GarageRoom room)
        {
            if (BeenUsed)
            {
                return($"Sorry, {LongName} has already been used.");
            }
            else
            {
                BeenUsed = true;

                Item echidna = room.GetHiddenRoomContentsByName("echidna");
                room.RoomContents.Add(echidna);
                room.RoomContentsAsStringList.Add("Echidna");

                if (room.WaterLevel == 0)
                {
                    room.CurrentScene = room.GarageScenes.ScenesDictionary["Water00_EchidnaNotButton"];
                }
                else if (room.WaterLevel > 0)
                {
                    string scn = "Water0" + room.WaterLevel + "_EchidnaAndButton";
                    room.CurrentScene = room.GarageScenes.ScenesDictionary[scn];
                }

                if (room.GetRoomContentsByName("honeybear").BeenUsed)
                {
                    return(ItemActionMessages["use"] + "\nThe echidna scampers to slurp up the ants. The happy echidna is now your buddy.");
                }
                else
                {
                    return(ItemActionMessages["use"]);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Executes the command provided by the user. But first...
        ///     Increments water-level if button has been pressed
        ///     Determines which scene should be shown based on state of the room and
        ///     Updates the Screen
        /// </summary>
        /// <returns>the command prompt for next user entry</returns>
        public string ExecuteCommand(GarageRoom currentRoom)
        {
            // Water level tracks the number of moves made
            if (room.GetRoomContentsByName("button").BeenUsed)
            {
                room.WaterLevel++;
            }

            if (room.WaterLevel > 0 && room.WaterLevel < 7)
            {
                // If waterlevel is at a certain height (6) then shark gets added to the room contents
                if (room.WaterLevel == 6)
                {
                    room.RoomContents.Add(room.GetHiddenRoomContentsByName("shark"));
                    room.RoomContentsAsStringList.Add("Shark");
                }

                if (room.DoesItemExistInRoom("echidna"))
                {
                    string scn = "Water0" + room.WaterLevel + "_EchidnaAndButton";
                    room.CurrentScene = room.GarageScenes.ScenesDictionary[scn];
                }
                else if (!room.DoesItemExistInRoom("echidna"))
                {
                    string scn = "Water0" + room.WaterLevel + "_NoEchidna";
                    room.CurrentScene = room.GarageScenes.ScenesDictionary[scn];
                }
            }
            else if (room.WaterLevel >= 7)
            {
                game.WinLoseLogic(InputVerb, InputNoun);
            }

            // provides default message if item is not in room
            if (!room.DoesItemExistInRoom(InputNoun) && InputNoun != "")
            {
                if (InputNoun == "water")
                {
                    view = new View(room.CurrentScene, room.RoomContentsAsStringList, Display.Wrap($"The WATER tastes like partially digested ants, like echidna poop.", 60));
                }
                else
                {
                    view = new View(room.CurrentScene, room.RoomContentsAsStringList, Display.Wrap($"I'm sorry, {InputNoun.ToUpper()} is not available in the room!", 60));
                }
                return(view.UpdateScreenAndGetInput());
            }

            switch (InputVerb)
            {
            case "intro":
                view = new View(room.CurrentScene, room.RoomContentsAsStringList, Display.Wrap(room.IntroMessage, 60));
                return(view.UpdateScreenAndGetInput());

            case "inspect":
            case "examine":
                view = new View(room.CurrentScene, room.RoomContentsAsStringList, Display.Wrap(room.GetRoomContentsByName(InputNoun).Examine(), 60));
                return(view.UpdateScreenAndGetInput());

            case "take":
            case "use":
            case "push":
            case "touch":
                string UseItemSceneUpdate = room.GetRoomContentsByName(InputNoun).Use(room);
                if (!room.ExitClosed)
                {
                    game.GameState = GameState.Over;
                }
                view = new View(room.CurrentScene, room.RoomContentsAsStringList, Display.Wrap(UseItemSceneUpdate, 60));
                return(view.UpdateScreenAndGetInput());

            case "help":
                view = new View(room.CurrentScene, room.RoomContentsAsStringList, Display.Wrap("Try different actions with the items in the room. For example: EXAMINE BUTTON.", 60));
                return(view.UpdateScreenAndGetInput());

            default:
                view = new View(room.CurrentScene, room.RoomContentsAsStringList, Display.Wrap("Command not found. Type 'help' for a list of commands.", 60));
                return(view.UpdateScreenAndGetInput());
            }
        }