/// <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()); }
public override string Use(GarageRoom room) { if (BeenUsed) { return($"Sorry, {LongName} has already been used. And he's not happy about your continued advances."); } else { BeenUsed = true; if (room.WaterLevel > 6 && room.DoesItemExistInRoom("echidna")) { room.RoomContents.Add(room.GetHiddenRoomContentsByName("garagedooropener")); room.RoomContentsAsStringList.Add("Garage Door Opener"); room.CurrentScene = room.GarageScenes.ScenesDictionary["Water07_EchidnaAttacksShark"]; return("The echidna gives you a li'l kiss on the cheek then dives underwater and attacks the shark! The echidna is eating the shark! He eats a large hole in the shark's belly revealing a... garage door opener? "); } else { BeenUsed = false; return(ItemActionMessages["use"]); } } }
public override string Use(GarageRoom room) { if (BeenUsed) { return($"Sorry, {LongName} has already been used."); } else { BeenUsed = true; if (room.DoesItemExistInRoom("garagedooropener")) { return("You attempt to use the dead shark, but it bites off your fingers. Fool."); } else { BeenUsed = false; return(ItemActionMessages["use"]); } } }
public override string Use(GarageRoom room) { if (BeenUsed) { return($"You try to press the BUTTON again, but the water level keeps rising."); } else { BeenUsed = true; if (!room.DoesItemExistInRoom("echidna")) { room.CurrentScene = room.GarageScenes.ScenesDictionary["Water00_ButtonNoEchidna"]; } else { room.CurrentScene = room.GarageScenes.ScenesDictionary["Water00_EchidnaAndButton"]; } return(ItemActionMessages["use"]); } }
/// <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()); } }