Exemplo n.º 1
0
        private static Room Move(Room room)
        {
            Room nextRoom = room;

            if (!CurrentRoom.IsLit() && !room.Light)
            {
                room = Rooms.Get <Darkness>();
            }

            Context.Story.Location = room;

            if (!room.Visited)
            {
                CurrentRoom.Look(true);

                room.Initial?.Invoke();
            }
            else
            {
                if (!CurrentRoom.IsLit() && room.Visited)
                {
                    nextRoom.DarkToDark();
                }

                CurrentRoom.Look(false);
            }


            room.Visited = true;

            return(nextRoom);
        }
Exemplo n.º 2
0
 public Player(GameState gameState, Room startRoom, Stats stats = null) : base(gameState, startRoom, stats)
 {
     this.GameState.Player = this;
     Commands.Add("GO", i =>
     {
         string x = i[1][0].ToString();
         if (!CurrentRoom.Doors.TryGetValue(x, out Door door))
         {
             return("There is no door in that direction, is it spelled right?");
         }
         return(ChangeRooms(door.To));
     });
     Commands.Add("CHECK", i =>
     {
         char c = i[1][0];
         List <string> things = new List <string>();
         string slot          = "";
         if (c == 'I')
         {
             if (Inventory.Count() == 0)
             {
                 return("Your inventory has no items.");
             }
             Inventory.ForEach(j => things.Add(j.Name.ToUpper()));
             slot = "in your inventory";
         }
         if (c == 'E')
         {
             if (Equipment.Where(k => k != null).Count() == 0)
             {
                 return("You have no items equipped.");
             }
             Equipment.ToList().ForEach(j => things.Add(j.Name.ToUpper()));
             slot = "equipped";
         }
         if (slot != "")
         {
             return($"You have {Stringify(things)} {slot}.");
         }
         return("That is not something you can check");
     });
     Commands.Add("TAKE", i => GetItem(i[1], "TAKE"));
     Commands.Add("TOUCH", i => GetItem(i[1], "TOUCH"));
     Commands.Add("INSPECT", i => GetItem(i[1], "LOOK"));
     Commands.Add("LOOK", i => GetItem(i[2], "LOOK"));
     Commands.Add("PUSH", i => GetItem(i[1], "PUSH"));
     Commands.Add("PULL", i => GetItem(i[1], "PULL"));
     Commands.Add("USE", i => GetItem(i[1], "USE"));
     SingleCommands.Add("LOOK", () => CurrentRoom.Look(this));
 }
Exemplo n.º 3
0
        public Game GetDirection(Game game)
        {
            Game   ThisGame  = game;
            string userInput = "";

            Console.SetCursorPosition(19, 16);
            userInput = Console.ReadLine();
            userInput = userInput.ToLower();
            string[] UserInput = userInput.Split();

            foreach (string word in UserInput)
            {
                if (word == "go")
                {
                    foreach (string word2 in UserInput)
                    {
                        if (word2 == "north")
                        {
                            ThisGame.Direction = "north";
                            ThisGame           = ThisGame.CurrentRoom.Navigator(ThisGame);
                            break;
                        }
                        if (word2 == "east")
                        {
                            ThisGame.Direction = "east";
                            ThisGame           = ThisGame.CurrentRoom.Navigator(ThisGame);
                            break;
                        }
                        if (word2 == "south")
                        {
                            ThisGame.Direction = "south";
                            ThisGame           = ThisGame.CurrentRoom.Navigator(ThisGame);
                            break;
                        }
                        if (word2 == "west")
                        {
                            ThisGame.Direction = "west";
                            ThisGame           = ThisGame.CurrentRoom.Navigator(ThisGame);
                            break;
                        }
                    }
                }
                if (word == "look")
                {
                    CurrentRoom.Look(ThisGame);
                    break;
                }
                if (word == "take")
                {
                    foreach (string word2 in UserInput)
                    {
                        foreach (Item item in ThisGame.CurrentRoom.Inventory)
                        {
                            if (item.Name.ToLower() == "poison")
                            {
                                ThisGame.CurrentRoom.Inventory.Remove(item);
                                ThisGame.Player.PoisonRate++;
                                return(ThisGame);
                            }
                            if (item.Name.ToLower() == "antidote")
                            {
                                ThisGame.CurrentRoom.Inventory.Remove(item);
                                ThisGame.Player.PoisonRate--;
                                return(ThisGame);
                            }
                            if (item.Name.ToLower() != "poison" && item.Name.ToLower() != "antidote")
                            {
                                ThisGame.Player.Inventory.Add(item);
                                ThisGame.CurrentRoom.Inventory.Remove(item);
                                return(ThisGame);
                            }
                        }
                    }
                }
                if (word == "inventory")
                {
                    ThisGame.Player.Inventory = Inventory(ThisGame.Player.Inventory);
                    return(ThisGame);
                }

                if (word == "quit")
                {
                    Player.Health = 0;
                    Death();
                    Environment.Exit(0);
                    break;
                }
                if (word == "help")
                {
                    Help();
                }
                return(ThisGame);
            }

            return(ThisGame);
        }
Exemplo n.º 4
0
 public bool Expects()
 {
     CurrentRoom.Look(true);
     return(true);
 }