public void DropTheKeyThenPickItUpAgain()
        {
            SimpleGameController controller = new SimpleGameController();

            controller.InitializeGame();

            Assert.AreEqual("Outside", controller.Game.CurrentRoom.Name);
            Assert.AreEqual(controller.RetrieveContentItem("DoorMat"), controller.ProcessCommand("look at doormat").Reply);

            Assert.AreEqual(controller.RetrieveContentItem("DoorLocked"), controller.ProcessCommand("open door").Reply);
            Assert.AreEqual(controller.RetrieveContentItem("DoorLocked"), controller.ProcessCommand("unlock door").Reply);

            Assert.AreEqual(controller.RetrieveContentItem("MovePlantPot"), controller.ProcessCommand("look at plant pot").Reply);
            Assert.AreEqual(controller.RetrieveContentItem("GrabKey"), controller.ProcessCommand("pick up the key").Reply);

            Assert.IsTrue(controller.Game.Player.Inventory.Exists("Key"));

            Assert.AreEqual("You drop the key.", controller.ProcessCommand("drop the key").Reply);

            Assert.IsFalse(controller.Game.Player.Inventory.Exists("Key"));

            Assert.AreEqual(controller.RetrieveContentItem("GrabKey"), controller.ProcessCommand("pick up the key").Reply);

            Assert.AreEqual(controller.RetrieveContentItem("TurnKey"), controller.ProcessCommand("unlock the door").Reply);
            Assert.AreEqual(controller.RetrieveContentItem("HallwayLightsOff"), controller.ProcessCommand("go north").Reply);
            Assert.AreEqual("Hallway", controller.Game.CurrentRoom.Name);
        }
        public void LookAtTheFridge()
        {
            SimpleGameController controller = new SimpleGameController();

            controller.InitializeGame();

            controller.Game.LoadGame(CompleteOutsideAndHallWaySection());

            Assert.AreEqual(controller.RetrieveContentItem("ItsAFridge"), controller.ProcessCommand("look at the fridge.").Reply);
        }
        public void LookAtTheFirePlace()
        {
            SimpleGameController controller = new SimpleGameController();

            controller.InitializeGame();

            controller.Game.LoadGame(CompleteOutsideAndHallWaySection());

            Assert.AreEqual(controller.RetrieveContentItem("MentlePieceDescription"), controller.ProcessCommand("look at fire place.").Reply);
        }
        public void StartInHallWay()
        {
            SimpleGameController controller = new SimpleGameController();

            controller.InitializeGame();

            controller.Game.LoadGame(CompleteOutsideSection());

            Assert.AreEqual("Hallway", controller.Game.CurrentRoom.Name);
            Assert.AreEqual(controller.RetrieveContentItem("HallwayLightsOff"), controller.Game.CurrentRoom.Description);
        }
        public void OpenTheFridge()
        {
            SimpleGameController controller = new SimpleGameController();

            controller.InitializeGame();

            controller.Game.LoadGame(CompleteOutsideAndHallWaySection());

            Assert.AreEqual(controller.RetrieveContentItem("ItsAFridge"), controller.ProcessCommand("look at the fridge.").Reply);
            Assert.IsTrue(controller.ProcessCommand("open the fridge.").Reply.StartsWith(controller.RetrieveContentItem("LookedAtFridge"), System.StringComparison.Ordinal));
        }
        public void StartInKitchen()
        {
            SimpleGameController controller = new SimpleGameController();

            controller.InitializeGame();

            controller.Game.LoadGame(CompleteOutsideAndHallWaySection());

            Assert.AreEqual("Kitchen", controller.Game.CurrentRoom.Name);
            Assert.AreEqual(controller.RetrieveContentItem("KitchenDescription"), controller.Game.CurrentRoom.Description);
        }
        public void TurnOnTheLights()
        {
            SimpleGameController controller = new SimpleGameController();

            controller.InitializeGame();

            controller.Game.LoadGame(CompleteOutsideSection());

            Assert.AreEqual("Hallway", controller.Game.CurrentRoom.Name);
            Assert.AreEqual(controller.RetrieveContentItem("HallwayLightsOff"), controller.Game.CurrentRoom.Description);

            Assert.IsTrue(controller.ProcessCommand("flip light switch").Reply.StartsWith(controller.RetrieveContentItem("FlipLightSwitch"), System.StringComparison.Ordinal));
        }
    void Awake( )
    {
        if (_instance == null)
        {
            _instance = this;
        }
        else if (_instance != this)
        {
            Destroy(this.gameObject);
        }

        DontDestroyOnLoad(this);
    }
        public void CanExitToHallway()
        {
            SimpleGameController controller = new SimpleGameController();

            controller.InitializeGame();

            controller.Game.LoadGame(CompleteOutsideAndHallWaySection());

            Assert.AreEqual("Kitchen", controller.Game.CurrentRoom.Name);

            Assert.AreEqual(controller.RetrieveContentItem("HallwayDescription"), controller.ProcessCommand("go south").Reply);
            Assert.AreEqual("Hallway", controller.Game.CurrentRoom.Name);
        }
        private ReadOnlyCollection <ICommand> CompleteOutsideSection()
        {
            SimpleGameController controller = new SimpleGameController();

            controller.InitializeGame();

            controller.ProcessCommand("look at doormat");
            controller.ProcessCommand("look at plant pot");
            controller.ProcessCommand("pick up the key");
            controller.ProcessCommand("unlock the door");
            controller.ProcessCommand("go north");

            return(controller.Game.SaveGame());
        }
        public void GetTheLetter()
        {
            SimpleGameController controller = new SimpleGameController();

            controller.InitializeGame();

            controller.Game.LoadGame(CompleteOutsideAndHallWaySection());

            Assert.AreEqual(controller.RetrieveContentItem("MentlePieceDescription"), controller.ProcessCommand("look at fire place.").Reply);
            Assert.AreEqual(controller.RetrieveContentItem("LetterDescription"), controller.ProcessCommand("read the letter.").Reply);

            Assert.IsFalse(controller.Game.Player.Inventory.Exists("Letter"));
            Assert.AreEqual("You pick up the letter.", controller.ProcessCommand("pick up the letter.").Reply);
            Assert.IsTrue(controller.Game.Player.Inventory.Exists("Letter"));
        }
        public void CanExitToKitchenAndGoBackToHallWay()
        {
            SimpleGameController controller = new SimpleGameController();

            controller.InitializeGame();

            controller.Game.LoadGame(CompleteOutsideSection());

            Assert.AreEqual("Hallway", controller.Game.CurrentRoom.Name);
            Assert.AreEqual(controller.RetrieveContentItem("HallwayLightsOff"), controller.Game.CurrentRoom.Description);

            Assert.IsTrue(controller.ProcessCommand("flip light switch").Reply.StartsWith(controller.RetrieveContentItem("FlipLightSwitch"), System.StringComparison.Ordinal));

            Assert.AreEqual(controller.RetrieveContentItem("KitchenDescription"), controller.ProcessCommand("go north").Reply);
            Assert.AreEqual("Kitchen", controller.Game.CurrentRoom.Name);

            Assert.AreEqual(controller.RetrieveContentItem("HallwayDescription"), controller.ProcessCommand("go south").Reply);
            Assert.AreEqual("Hallway", controller.Game.CurrentRoom.Name);
        }
        public void TryToPickUpKeyTwice()
        {
            SimpleGameController controller = new SimpleGameController();

            controller.InitializeGame();

            Assert.AreEqual("Outside", controller.Game.CurrentRoom.Name);
            Assert.AreEqual(controller.RetrieveContentItem("DoorMat"), controller.ProcessCommand("look at doormat").Reply);

            Assert.AreEqual(controller.RetrieveContentItem("MovePlantPot"), controller.ProcessCommand("look at plant pot").Reply);
            Assert.AreEqual(controller.RetrieveContentItem("GrabKey"), controller.ProcessCommand("pick up the key").Reply);

            Assert.IsTrue(controller.Game.Player.Inventory.Exists("Key"));

            Assert.AreEqual(controller.RetrieveContentItem("AlreadyHaveKey"), controller.ProcessCommand("pick up the key").Reply);
            Assert.AreEqual(controller.RetrieveContentItem("TurnKey"), controller.ProcessCommand("unlock the door").Reply);
            Assert.AreEqual(controller.RetrieveContentItem("HallwayLightsOff"), controller.ProcessCommand("go north").Reply);
            Assert.AreEqual("Hallway", controller.Game.CurrentRoom.Name);
        }
        public void DropAndPickUpKey()
        {
            SimpleGameController controller = new SimpleGameController();

            controller.InitializeGame();

            controller.Game.LoadGame(CompleteOutsideSection());

            Assert.AreEqual("Hallway", controller.Game.CurrentRoom.Name);
            Assert.AreEqual(controller.RetrieveContentItem("HallwayLightsOff"), controller.Game.CurrentRoom.Description);

            Assert.IsTrue(controller.ProcessCommand("flip light switch").Reply.StartsWith(controller.RetrieveContentItem("FlipLightSwitch"), System.StringComparison.Ordinal));

            Assert.IsTrue(controller.Game.Player.Inventory.Exists("Key"));

            Assert.AreEqual("You drop the key.", controller.ProcessCommand("drop the key").Reply);

            Assert.IsFalse(controller.Game.Player.Inventory.Exists("Key"));

            Assert.AreEqual(controller.RetrieveContentItem("GrabKey"), controller.ProcessCommand("pick up the key").Reply);

            Assert.IsTrue(controller.Game.Player.Inventory.Exists("Key"));
        }
        public static void Main()
        {
            SimpleGameController simpleGame = new SimpleGameController();

            Console.Clear();
            simpleGame.InitializeGame();

            ConsoleEx.WordWrap(simpleGame.Prologue);
            Console.WriteLine();

            ConsoleEx.WordWrap(simpleGame.CurrentRoomDescription);
            Console.WriteLine();

            while (true)
            {
                Console.Write("> ");
                var reply = simpleGame.ProcessCommand(Console.ReadLine());

                switch (reply.State)
                {
                case GameStateEnum.Playing:
                    if (!string.IsNullOrEmpty(reply.Reply))
                    {
                        Console.WriteLine();
                        ConsoleEx.WordWrap(reply.Reply);
                    }
                    continue;

                case GameStateEnum.Clearscreen:
                    Console.Clear();
                    continue;

                case GameStateEnum.Exit:
                    Console.WriteLine();
                    Console.Write(simpleGame.RetrieveContentItem("AreYouSure"));
                    var response = Console.ReadLine();

                    if (response != null && response.ToLower() == "y")
                    {
                        Console.WriteLine();
                        ConsoleEx.WordWrap(simpleGame.RetrieveContentItem("ExitMessage"));

                        Environment.Exit(0);
                    }
                    continue;

                case GameStateEnum.Score:
                    Console.WriteLine();
                    Console.WriteLine("You have made " + simpleGame.NumberOfMoves + " so far.");
                    Console.WriteLine("You score is " + simpleGame.Score);
                    Console.WriteLine();
                    continue;

                case GameStateEnum.Inventory:
                    if (simpleGame.GetInventory().Count == 0)
                    {
                        Console.WriteLine();
                        Console.WriteLine("Your inventory is empty.");
                        Console.WriteLine();
                    }
                    else
                    {
                        Console.WriteLine();
                        Console.WriteLine("Inventory");
                        Console.WriteLine("---------");

                        foreach (var i in simpleGame.GetInventory())
                        {
                            Console.WriteLine("   " + i);
                        }

                        Console.WriteLine();
                    }
                    continue;

                case GameStateEnum.Visited:
                    Console.WriteLine();
                    Console.WriteLine("Visited Locations");
                    Console.WriteLine("-----------------");
                    Console.WriteLine();
                    Console.WriteLine("You have visited the following locations.");
                    Console.WriteLine();

                    foreach (var location in simpleGame.GetVisitedRooms())
                    {
                        Console.WriteLine("    " + location.name);
                    }

                    Console.WriteLine();
                    Console.WriteLine("To visit an already visited location type goto or visit and then the location name.");
                    continue;

                case GameStateEnum.Help:
                    Console.WriteLine();
                    Console.WriteLine("Game Manual");
                    Console.WriteLine("-----------");
                    Console.WriteLine();
                    ConsoleEx.WordWrap(simpleGame.Help);
                    continue;
                }
            }
        }