Exemple #1
0
        /**
         * Drop an item to the room on the basis of second word
         */

        private void dropItem(Command command)
        {
            if (!command.hasSecondWord())
            {
                Console.WriteLine(GeneralDataLibrary.I() + "drop what?");
            }
            else
            {
                int  num;
                Item item = null;
                if (int.TryParse(command.getSecondWord(), out num))
                {
                    num--;

                    if (num > -1 && num < player.Inventory.Items.Count)
                    {
                        item = player.Inventory.sendItem(player.CurrentRoom.Inventory, num);
                    }
                    else
                    {
                        Console.WriteLine(GeneralDataLibrary.I() + "index is out of bounds!");
                    }
                }
                else
                {
                    item = player.Inventory.sendItem(player.CurrentRoom.Inventory, command.getSecondWord());
                }
                if (item != null)
                {
                    Console.WriteLine(GeneralDataLibrary.I(2) + "Dropped " + item.Name);
                }
            }
        }
        public void goRoom(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("Go where?");
                return;
            }

            String direction = command.getSecondWord();

            // Try to leave current room.

            Room nextRoom = this.getCurrentRoom().getExit(direction);



            if (nextRoom == null)
            {
                Console.WriteLine("There is no door!");
            }
            else
            {
                this.setCurrentRoom(nextRoom);
                Console.WriteLine(this.getCurrentRoom().getLongDescription());
                foreach (string key in currentRoom.Inventory.Items.Keys)
                {
                    Console.WriteLine("Items: " + (currentRoom.Inventory.Items[key].Name));
                    // Console.WriteLine(currentRoom.Inventory.Items[key].Name);
                }
                damage(10);
            }
        }
Exemple #3
0
        /**
         * Try to go to one direction. If there is an exit, enter the new
         * room, otherwise print an error message.
         */
        private void goRoom(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("Go where?");
                return;
            }

            string direction = command.getSecondWord();

            // Try to leave current room.
            Room nextRoom = player.currentRoom.getExit(direction);

            if (nextRoom == null)
            {
                Console.WriteLine("There is no door to " + direction + "!");
            }
            else
            {
                player.currentRoom = nextRoom;
                player.Damage(10);
                player.isAlive();
                Console.WriteLine(player.currentRoom.getLongDescription());
            }
        }
Exemple #4
0
        /**
         * Try to go to one direction. If there is an exit, enter the new
         * room, otherwise print an error message.
         */
        private void goRoom(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("Go where?");

                return;
            }

            string direction = command.getSecondWord();

            // Try to leave current room.
            Room nextRoom = player.Currentroom.getExit(direction);

            if (nextRoom == null)
            {
                Console.WriteLine("There is no door to " + direction + "!");
            }
            else if (nextRoom.isLocked == true)
            {
                Console.WriteLine("Looks like this door is locked... You need a key to enter here");
            }
            else
            {
                Console.Clear();
                player.Currentroom = nextRoom;
                Console.WriteLine(player.Currentroom.getLongDescription());
                player.damage(10);
            }
        }
Exemple #5
0
        /**
         * Try to go to one direction. If there is an exit, enter the new
         * room, otherwise print an error message.
         */
        private void goRoom(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("Go where?");
                return;
            }

            string direction = command.getSecondWord();

            // Try to leave current room.
            Room nextRoom = player.currentRoom.getExit(direction);

            if (nextRoom == null)
            {
                //If the room doesn't exist...
                Console.WriteLine("There is no door to " + direction + "!");
            }
            else if (nextRoom.isLocked == true)
            {
                //If the room is locked...
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("\n The room to the " + direction + " is locked! There should be a key somewhere...");
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine(player.currentRoom.getLongDescription());
            }
            else   //If the player is allowed to enter the room..
            {
                player.damage(5);

                player.currentRoom = nextRoom;
                Console.WriteLine(player.currentRoom.getLongDescription());
            }
        }
Exemple #6
0
        /**
         * Try to go to one direction. If there is an exit, enter the new
         * room, otherwise print an error message.
         */
        private void goRoom(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("Go where?");
                return;
            }

            string direction = command.getSecondWord();

            // Try to leave current room.
            Room nextRoom = player.CurrentRoom.getExit(direction);

            if (nextRoom == null)
            {
                Console.WriteLine("There is no door to " + direction + "!");
            }
            else if (nextRoom.locked)
            {
                Console.WriteLine("this room is locked");
            }
            else
            {
                player.CurrentRoom = nextRoom;
                player.damage(5);
                player.CurrentRoom.RoomInventory.GetItemsRoom();

                Console.WriteLine(player.CurrentRoom.getLongDescription());
            }
        }
Exemple #7
0
 private void getItem(Command command)
 {
     if (!command.hasSecondWord())
     {
         // if there is no second word, we don't know where to go...
         Console.WriteLine("Get what?");
         return;
     }
     if (player.currentweight < player.maxweight)
     {
         string item = command.getSecondWord();
         if (player.currentRoom.roomItems.ContainsKey(item))
         {
             Item myItem = player.currentRoom.GetRoomInventory()[command.getSecondWord()];
             player.playerWeightPlus(myItem);
             player.transferItems(item, myItem);
             player.currentRoom.removeFromRoom(item);
         }
         else
         {
             Console.WriteLine("The item you are describing is non existant.");
         }
     }
     else
     {
         Console.WriteLine("You are to heavy.");
     }
 }
Exemple #8
0
        private void dropItem(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know what to take
                Console.WriteLine("Drop what?");
                return;
            }
            //if the second word is in place, then we can search in the room's inventory for the given word
            string itemtodrop = command.getSecondWord();

            //However, first we need to check if the given command actually corresponds to an existing item which is in the room's inventory
            if (player.getInventory().checkItem(itemtodrop))
            {
                Item item = player.getInventory().getItems()[command.getSecondWord()];
                item.weight -= player.currentweight;
                //if the item given does correspond to an item in the room's inventory, then we can give it to the player
                player.currentRoom.GetInventory().Additem(itemtodrop, item);
                player.getInventory().Removeitem(itemtodrop, item);
                Console.WriteLine("Dropped " + itemtodrop);
            }
            else
            {
                //Speaks for itself honestly
                Console.WriteLine("That item doesn't seem to exist. Did you write it correctly?");
            }
        }
Exemple #9
0
        private void Use(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("Use what?");
                return;
            }

            string item = command.getSecondWord();

            // Try to leave current room.
            Item toUse = player.GetInventory().GetItem(item);

            if (item == null)
            {
                Console.WriteLine("There is no item with this name: " + item + "!");
            }
            else
            {
                if (player.IsAlive())
                {
                    player.GetInventory().UseItem(toUse, player);
                }
                else
                {
                    Console.WriteLine("you died " + player.GetCurrentRoom().getLongDescription());
                }
            }
        }
Exemple #10
0
        private void Unlock(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("Which room do you want to unlock?");
                Console.WriteLine("Use the command like this 'Unlock' 'exit' 'the item that is a key'.");
                return;
            }
            if (!command.hasThirdWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("Which key do you want to use?");
                return;
            }

            string door = command.getSecondWord();
            string key  = command.getThirdWord();
            Room   toOpen;
            Key    toUse;

            // Try to leave current room.
            if (door == null)
            {
                Console.WriteLine("There is no door with this name: " + door + "!");
            }
            toOpen = player.GetCurrentRoom().getExit(door);
            if (player.GetInventory().GetItem(key) is Key)
            {
                toUse = (Key)player.GetInventory().GetItem(key);
                if (player.IsAlive())
                {
                    if (player.GetCurrentRoom().GetTier() > toUse.GetTier())
                    {
                        Console.WriteLine("That Key is not strong enough for this door");
                    }
                    else
                    {
                        player.GetInventory().UseKey(player, toUse, toOpen);
                    }
                }
                else
                {
                    Console.WriteLine("you died " + player.GetCurrentRoom().getLongDescription());
                }
            }
            else
            {
                if (player.IsAlive())
                {
                    Console.WriteLine("That's not a key");
                }
                else
                {
                    Console.WriteLine("you died " + player.GetCurrentRoom().getLongDescription());
                }
            }
        }
Exemple #11
0
        /**
         * Try to go to one direction. If there is an exit, enter the new
         * room, otherwise print an error message.
         */
        private void goRoom(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("Go where?");
                return;
            }

            string direction = command.getSecondWord();

            if (direction == "quit")
            {
                finished = true;
                player.Heal(-10000);
                Console.WriteLine("the game ended use the command quit to exit the game. Thank you for playing");
            }
            else
            {
                Room nextRoom = player.GetCurrentRoom().getExit(direction);

                if (nextRoom == null)
                {
                    Console.WriteLine("There is no door to " + direction + "!");
                }
                else
                {
                    if (player.IsAlive())
                    {
                        if (!nextRoom.isLocked())
                        {
                            if (player.Bleeding)
                            {
                                player.Damage(5);
                                player.SetCurrentRoom(nextRoom);
                                Console.WriteLine(player.GetCurrentRoom().getLongDescription());
                            }
                            else
                            {
                                player.SetCurrentRoom(nextRoom);
                                Console.WriteLine(player.GetCurrentRoom().getLongDescription());
                            }
                        }
                        else
                        {
                            Console.WriteLine("the door " + direction + " is locked");
                        }
                    }
                    else
                    {
                        Console.WriteLine("you died " + player.GetCurrentRoom().getLongDescription());
                    }
                }
            }
        }
Exemple #12
0
 public void takeItem(Command command)
 {
     if (!command.hasSecondWord())
     {
         if (player.currentRoom.Inventory.Items.Count < 0)
         {
             Item currentItem = player.currentRoom.Inventory.Items;
             player.currentRoom.Inventory.addItem(player.Inventory, currentItem.name);
         }
     }
 }
Exemple #13
0
        /**
         * Try to go to one direction. If there is an exit, enter the new
         * room, otherwise print an error message.
         */

        private void ClearConsole(Command command)
        {
            if (!command.hasSecondWord())
            {
                Console.Clear();
                Console.WriteLine(player.CurrentRoom.getLongDescription());
            }
            else
            {
                Console.WriteLine(GeneralDataLibrary.I() + "The clear function does not use a second word!");
            }
        }
Exemple #14
0
        // implementations of user commands:
        private void use(Command command)
        {
            Item i = null;

            if (command.hasSecondWord())
            {
                for (int e = player.Inventory.List.Count - 1; e >= 0; e--)
                {
                    if (command.getSecondWord() == player.Inventory.List[e].name)
                    {
                        i = player.Inventory.List[e];
                    }
                }

                if (command.hasThirdWord())
                {
                    Room roomToUnlock = player.Currentroom.getExit(command.getThirdWord());

                    if (roomToUnlock == null)
                    {
                        Console.WriteLine("There is no door to unlock in that direction!");
                        return;
                    }
                    else
                    {
                        if (i == null)
                        {
                            Console.WriteLine("This item does not exist in your inventory!");
                            return;
                        }
                        else
                        {
                            i.use(roomToUnlock);
                            return;
                        }
                    }
                }

                if (i == null)
                {
                    Console.WriteLine("The item you're trying to use does not exist!");
                }
                else
                {
                    i.use(player);
                }
            }
            else
            {
                Console.WriteLine("Please specify an item to use!");
            }
        }
Exemple #15
0
 private void takeItem(Command command)
 {
     if (!command.hasSecondWord())
     {
         Console.WriteLine("You take all the items in the room and put them away");
         for (int i = player.currentRoom.Inventory.Items.Count - 1; i >= 0; i--)
         {
             Item currentItem = player.currentRoom.Inventory.Items[i];
             Console.WriteLine("Added" + currentItem.getName);
             player.currentRoom.Inventory.transferItem(player.Inventory, currentItem.getName);
         }
     }
 }
Exemple #16
0
        private void useItem(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("Use what?");
                return;
            }
            string item = command.getSecondWord();

            if (!command.hasThirdWord() && item is "key")
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("Which room?");
                return;
            }

            if (player.inventory.getPlayerItems().ContainsKey(item)) //Checkt of item in inv zit.
            {
                if (item is "key")
                {
                    string direction = command.getThirdWord();
                    Room   r         = player.currentRoom.getExit(direction);
                    key.Use(r);
                }

                Item useThis = player.inventory.getPlayerItems()[command.getSecondWord()];

                if (item is "key")
                {
                }
                else
                {
                    Console.WriteLine("You used: " + item);
                    player.inventory.OutInv(item);
                    player.usedItem(useThis);
                    player.playerWeightMin(useThis);
                }
                Console.ForegroundColor = ConsoleColor.DarkRed;
                if (useThis.damage > 0)
                {
                    Console.WriteLine("You took: " + useThis.damage + " Damage.");
                }
                Console.ForegroundColor = ConsoleColor.White;
            }
            else
            {
                Console.WriteLine("The item you are describing is non existant.");
            }
        }
Exemple #17
0
        /**
         * Go to another room check for status effect triggers that are triggered by that and let all enemies attack
         */

        private void goRoom(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine(GeneralDataLibrary.I() + "Go where?");
                return;
            }

            string direction = command.getSecondWord();

            // Try to leave current room.
            Room nextRoom = player.CurrentRoom.getExit(direction);

            if (nextRoom == null)
            {
                Console.WriteLine(GeneralDataLibrary.I() + "You can not go there '" + direction + "' doesn't exist!");
            }
            else
            {
                if (nextRoom.IsTutorialLocked)
                {
                    Console.WriteLine(nextRoom.TutorialDescription);
                }
                else if (nextRoom.IsBarred)
                {
                    Console.WriteLine(nextRoom.BarredDescription);
                }
                else if (nextRoom.IsCutable)
                {
                    Console.WriteLine(nextRoom.CutableDescription);
                }
                else if (nextRoom.IsLocked)
                {
                    Console.WriteLine("You will need a '" + nextRoom.KeyToUnlock + "' key!");
                }
                else
                {
                    if (player.CurrentRoom.ExitEvents.ContainsKey(direction))
                    {
                        Console.WriteLine(player.CurrentRoom.ExitEvents[direction]);
                        GeneralDataLibrary.Break();
                    }

                    player.CurrentRoom = nextRoom;
                    Console.WriteLine(player.CurrentRoom.getLongDescription());
                    player.CheckTriggers(0);
                }
            }
        }
Exemple #18
0
        private void goRoom(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("Go where?");
                return;
            }

            string direction = command.getSecondWord();

            // Try to leave current room.
            Room nextRoom = player.currentRoom.getExit(direction);

            if (nextRoom == null)
            {
                Console.WriteLine("There is no door to " + direction + "!");
            }
            else if (nextRoom.locked == true)
            {
                Console.WriteLine("Room is locked in " + direction + " direction.");
                Console.BackgroundColor = ConsoleColor.Red;
                Console.WriteLine("\n");
                Console.WriteLine("████████████████████");
                Console.WriteLine("█    mmmmmmmmmm    █");
                Console.WriteLine("█   mm        mm   █");
                Console.WriteLine("█  mm          mm  █");
                Console.WriteLine("█ mm            mm █");
                Console.WriteLine("█ mm            mm █");
                Console.WriteLine("█ mm            mm █");
                Console.WriteLine("█ UUUUUUUUUUUUUUUU █");
                Console.WriteLine("█ UUUUUU   UUUUUUU █");
                Console.WriteLine("█ UUUUU     UUUUUU █");
                Console.WriteLine("█ UUUUUU   UUUUUUU █");
                Console.WriteLine("█ UUUUUU   UUUUUUU █");
                Console.WriteLine("█ UUUUUU   UUUUUUU █");
                Console.WriteLine("█ UUUUUUUUUUUUUUUU █");
                Console.WriteLine("█   UUUUUUUUUUUU   █");
                Console.WriteLine("████████████████████");
                Console.BackgroundColor = ConsoleColor.Black;
            }
            else
            {
                player.currentRoom = nextRoom;
                player.health     -= 10;
                Console.Clear();
                Console.WriteLine(player.currentRoom.getLongDescription());
            }
        }
Exemple #19
0
        /**
         * Try to go to one direction. If there is an exit, enter the new
         * room, otherwise print an error message.
         */
        private void goRoom(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...

                Console.WriteLine("Go where?");
                Console.WriteLine("*************************************************************");
                return;
            }

            string direction = command.getSecondWord();

            // Try to leave current room.
            Room nextRoom = player.currentroom.getExit(direction);

            if (nextRoom == null)
            {
                Console.WriteLine("There is no way to " + direction + "!");
                Console.WriteLine("*************************************************************");
            }
            else
            {
                if (nextRoom.Locked == true)
                {
                    //use key
                    if (player.NumberOFitems > maxItem)
                    {
                        key.use(nextRoom);
                        player.currentroom = nextRoom;
                        Console.WriteLine(player.currentroom.getLongDescription());
                    }
                    //no key
                    else
                    {
                        Console.WriteLine("*************************************************************");
                        Console.WriteLine("this room is locked");
                        Console.WriteLine("u don't have a key");
                        Console.WriteLine("*************************************************************");
                    }
                }
                else
                {
                    player.currentroom = nextRoom;
                    Console.WriteLine(player.currentroom.getLongDescription());
                }
            }
        }
Exemple #20
0
        /**
         * Try to go to one direction. If there is an exit, enter the new
         * room, otherwise print an error message.
         */
        private void goRoom(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("");
                Console.WriteLine("00111110 00100111 10101101 00001101 11111010 10001010 ");
                Console.WriteLine("");
                Console.WriteLine(" # Go where?");
                Console.WriteLine("");
                Console.WriteLine("10001000 11010110 11100100 10101011 11110000 10111110 ");
                Console.WriteLine("");
                return;
            }

            string direction = command.getSecondWord();

            // Try to leave current room.
            Room nextRoom = player.currentRoom.getExit(direction);

            if (nextRoom == null)
            {
                Console.WriteLine("");
                Console.WriteLine("10111110 11010000 11101000 00000111 11001001 11100001 ");
                Console.WriteLine("");
                Console.WriteLine(" # There is no door to " + direction + "!");
                Console.WriteLine("");
                Console.WriteLine("11111100 00010100 11000111 01000110 01100000 00001001 ");
                Console.WriteLine("");
            }
            else
            {
                player.currentRoom = nextRoom;
                player.damage(1);
                Console.WriteLine("");
                Console.WriteLine("11101100 00110011 01100110 00110010 01000111 01101010 ");
                Console.WriteLine("");
                Console.WriteLine(" # " + player.currentRoom.getLongDescription());
                Console.WriteLine(" # you have " + player.getHealth + " health left");
                Console.WriteLine("");
                Console.WriteLine("10111110 11010000 11101000 00000111 11001001 11100001 ");
                Console.WriteLine("");
            }
        }
Exemple #21
0
        private void pickupItem(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("Pick up what?");
                Console.WriteLine("\n");
                return;
            }

            string nameFlower = command.getSecondWord();
            //Console.WriteLine(miep); //outcome = good flower name

            Item flowerr = player.currentroom.Inventory.getItem(nameFlower);


            if (flowerr == null)
            {
                Console.WriteLine("*************************************************************");
                Console.WriteLine("There is no  flower with the name: " + nameFlower + " here!");
                Console.WriteLine("*************************************************************");
                Console.WriteLine("\n");
            }
            else
            {
                //Flower Flower = player.currentroom.Inventory.remove("flower", flowerr);
                player.currentroom.Inventory.remove(nameFlower, flowerr);
                player.setItem(nameFlower, flowerr);
                player.NumberOFitems += 1;

                Console.WriteLine("you have in you inventory: " + player.Inventory.getItemList());
                //Console.WriteLine(player.NumberOFitems);
                Console.WriteLine("*************************************************************" + "\n");


                //if all flowers are in player inventory
                if (player.NumberOFitems == maxItem)
                {
                    garden.Inventory.addItem("key", key);
                    Console.WriteLine("a key apeared in the begin of the garden");
                }
            }
        }
Exemple #22
0
        public void useItem(Command command)
        {
            if (!command.hasSecondWord())
            {
                Console.WriteLine("Use what?");
                return;
            }

            string itemstring = command.getSecondWord();

            //If the item in question is in the player's inventory...
            if (player.getInventory().checkItem(itemstring))
            {
                player.getInventory().getItems()[itemstring].Use(player, this, command);
            }
            else
            {
                Console.WriteLine("Can't find the item to use in your inventory.");
            }
        }
Exemple #23
0
        // implementations of user commands:

        /**
         * Print out some help information.
         * Here we print some stupid, cryptic message and a list of the
         * command words.
         */
        private void printHelp(Command command)
        {
            if (command.hasSecondWord())
            {
                if (parser.Commands.CommandData.ContainsKey(command.getSecondWord()))
                {
                    Console.Write(parser.Commands.CommandData[command.getSecondWord()]);
                    GeneralDataLibrary.Break(2);
                    GeneralDataLibrary.LongLine();
                }
            }
            else
            {
                Console.WriteLine("Type: 'help <command>' to show more information on a command.");
                Console.WriteLine("Your command words are:");
                GeneralDataLibrary.Break();
                parser.showCommands();
                GeneralDataLibrary.Break();
            }
        }
Exemple #24
0
        public void useItem(Command command)
        {
            Item i = null;

            if (command.hasSecondWord())
            {
                for (int y = player.PlayerInventory.Items.Count - 1; y >= 0; y--)
                {
                    if (command.getSecondWord() == player.PlayerInventory.Items[y].name)
                    {
                        i = player.PlayerInventory.Items[y];
                    }
                }
            }
            if (command.hasThirdWord())
            {
                Room unlockableRoom = player.CurrentRoom.getExit(command.getThirdWord());
                if (unlockableRoom == null)
                {
                    Console.WriteLine("this room might be already unlocked or it doesn't exist. Feels bad man");
                }
                else
                {
                    if (i == null)
                    {
                        Console.WriteLine("I don't think you have that item");
                        return;
                    }
                    else
                    {
                        i.use(unlockableRoom);
                        return;
                    }
                }
            }

            else
            {
                Console.WriteLine("I think you don't have that item. Can't help you sorry!");
            }
        }
Exemple #25
0
        private void takeItem(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know what to take
                Console.WriteLine("Take what?");
                return;
            }
            //if the second word is in place, then we can search in the room's inventory for the given word
            string itemtotake = command.getSecondWord();

            //However, first we need to check if the given command actually corresponds to an existing item which is in the room's inventory
            if (player.currentRoom.GetInventory().checkItem(itemtotake))
            {
                //Check if the player actually specifically said what they wanted
                Item item = player.currentRoom.GetInventory().getItems()[command.getSecondWord()];

                //Add the weight of the item in the inventory
                player.currentweight += item.weight;

                if (player.currentweight >= player.getMaxWeight())
                {
                    Console.WriteLine("Your inventory is full, you can't pick this up.");
                    item.weight -= player.currentweight;
                }
                else
                {
                    //if the item given does correspond to an item in the room's inventory, then we can give it to the player
                    player.getInventory().Additem(itemtotake, item);
                    player.currentRoom.GetInventory().Removeitem(itemtotake, item);
                    Console.WriteLine("Took " + itemtotake);
                }
            }
            else
            {
                //Speaks for itself honestly
                Console.WriteLine("That item doesn't seem to exist. Did you write it correctly?");
            }
        }
Exemple #26
0
        /**
         * Try to go to one direction. If there is an exit, enter the new
         * room, otherwise print an error message.
         */

        private void dropItem(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("Drop what?");
                return;
            }
            string drop = command.getSecondWord();

            if (player.inventory.getPlayerItems().ContainsKey(drop))
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine("You dropped: " + drop);
                Console.ForegroundColor = ConsoleColor.White;

                Item myDrop = player.inventory.getPlayerItems()[command.getSecondWord()];
                player.currentRoom.spawnItem(drop, myDrop);
                player.inventory.OutInv(drop);
                player.playerWeightMin(myDrop);
            }
        }
Exemple #27
0
        /**
         * Unequip an item from on of the player's equip slot
         */

        private void unequipItem(Command command)
        {
            if (command.hasSecondWord())
            {
                switch (command.getSecondWord())
                {
                case "hand":
                    if (player.FirstHand != null)
                    {
                        if (player.Inventory.addItem(player.FirstHand))
                        {
                            Console.WriteLine("Unequiped: " + player.FirstHand.Name);
                            player.FirstHand = null;
                        }
                    }
                    else
                    {
                        Console.WriteLine(GeneralDataLibrary.Note() + "No item to unequip!");
                    }

                    break;

                case "offhand":
                    if (player.SecondHand != null)
                    {
                        if (player.Inventory.addItem(player.SecondHand))
                        {
                            Console.WriteLine("Unequiped: " + player.SecondHand.Name);
                            player.SecondHand = null;
                        }
                    }
                    else
                    {
                        Console.WriteLine(GeneralDataLibrary.Note() + "No item to unequip!");
                    }
                    break;

                case "armor":
                    if (player.Armor != null)
                    {
                        if (player.Inventory.addItem(player.Armor))
                        {
                            Console.WriteLine("Unequiped: " + player.Armor.Name);
                            player.Armor = null;
                        }
                    }
                    else
                    {
                        Console.WriteLine(GeneralDataLibrary.Note() + "No item to unequip!");
                    }

                    break;

                case "special":
                    if (player.Special != null)
                    {
                        if (player.Inventory.addItem(player.Special))
                        {
                            Console.WriteLine("Unequiped: " + player.Special.Name);
                            player.Special = null;
                        }
                    }
                    else
                    {
                        Console.WriteLine(GeneralDataLibrary.Note() + "No item to unequip!");
                    }

                    break;

                default:
                    Console.WriteLine("Can't find item slot.");
                    break;
                }
            }
        }
Exemple #28
0
        /**
         * Pick up an item from a room on the basis of second word
         */

        private void takeItem(Command command)
        {
            if (!command.hasSecondWord())
            {
                if (player.CurrentRoom.Inventory.Items.Count < player.Inventory.SpaceLeft)
                {
                    if (player.CurrentRoom.Inventory.Items.Count > 0)
                    {
                        Console.WriteLine(GeneralDataLibrary.I() + "You take all items on the ground and put them in your bag.");
                        GeneralDataLibrary.Break();
                        for (int i = player.CurrentRoom.Inventory.Items.Count - 1; i >= 0; i--)
                        {
                            Item currentItem = player.CurrentRoom.Inventory.Items[i];
                            Console.WriteLine(GeneralDataLibrary.I(2) + "Added " + currentItem.Name);
                            player.CurrentRoom.Inventory.sendItem(player.Inventory, currentItem.Name);

                            if (currentItem.HasPickupTutorialEvent)
                            {
                                currentItem.progressTutorial();
                            }

                            if (player.checkBadItem(currentItem, 0))
                            {
                                player.Inventory.Items.RemoveAt(i);
                                currentItem = null;
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine(GeneralDataLibrary.I() + "Despite your hard work you find no item to pick up!");
                    }
                }
                else
                {
                    Console.WriteLine(GeneralDataLibrary.I() + "Not enough space in inventory to take item(s)!");
                }
            }
            else
            {
                if (player.Inventory.SpaceLeft > 0)
                {
                    int  num;
                    Item item = null;
                    if (int.TryParse(command.getSecondWord(), out num))
                    {
                        num--;

                        if (num > -1 && num < player.CurrentRoom.Inventory.Items.Count)
                        {
                            item = player.CurrentRoom.Inventory.sendItem(player.Inventory, num);
                        }
                        else
                        {
                            Console.WriteLine(GeneralDataLibrary.I() + "index is out of bounds!");
                        }
                    }
                    else
                    {
                        item = player.CurrentRoom.Inventory.sendItem(player.Inventory, command.getSecondWord());
                    }

                    if (item != null)
                    {
                        Console.WriteLine(GeneralDataLibrary.I(2) + "Added " + item.Name);
                        player.checkBadItem(item, 0);

                        if (item.HasPickupTutorialEvent)
                        {
                            item.progressTutorial();
                        }
                    }
                }
                else
                {
                    Console.WriteLine(GeneralDataLibrary.I() + "Not enough space in inventory to take item!");
                }
            }
        }
Exemple #29
0
        /**
         * Display information for the look command. displays player info, room info and enemies in room
         */

        private void lookAround(Command command)
        {
            if (command.hasSecondWord())
            {
                bool showDesc = true;

                if (player.CurrentRoom.getExit(command.getSecondWord()) != null)
                {
                    if (player.CurrentRoom.getExit(command.getSecondWord()).IsBarred)
                    {
                        Console.WriteLine(player.CurrentRoom.getExit(command.getSecondWord()).BarredDescription);
                        showDesc = false;
                    }

                    if (player.CurrentRoom.getExit(command.getSecondWord()).IsCutable)
                    {
                        Console.WriteLine(player.CurrentRoom.getExit(command.getSecondWord()).CutableDescription);
                        showDesc = false;
                    }

                    if (player.CurrentRoom.getExit(command.getSecondWord()).IsLocked)
                    {
                        Console.WriteLine(GeneralDataLibrary.I() + "This room is locked!");
                        Console.WriteLine(player.CurrentRoom.getExit(command.getSecondWord()).KeyToUnlock);
                        showDesc = false;
                    }

                    if (player.CurrentRoom.getExit(command.getSecondWord()).IsTutorialLocked)
                    {
                        Console.WriteLine(player.CurrentRoom.getExit(command.getSecondWord()).TutorialDescription);
                        showDesc = false;
                    }

                    if (showDesc)
                    {
                        GeneralDataLibrary.Break();
                        Console.WriteLine(GeneralDataLibrary.I() + "There is nothing blocking the entrance to " + command.getSecondWord());
                    }
                }
                else
                {
                    Console.WriteLine(GeneralDataLibrary.Note() + "Could not find exit!");
                }
            }
            else
            {
                Console.WriteLine(player.CurrentRoom.getLongDescription());
                GeneralDataLibrary.Break();
                if (player.CurrentRoom.Inventory.Items.Count > 0)
                {
                    Console.WriteLine(GeneralDataLibrary.I() + player.CurrentRoom.Inventory.Items.Count + " Item(s) in the room!");
                    GeneralDataLibrary.Break();
                    for (int i = 0; i < player.CurrentRoom.Inventory.Items.Count; i++)
                    {
                        Console.WriteLine(GeneralDataLibrary.I(2) + (i + 1) + " | " + player.CurrentRoom.Inventory.Items[i].Name + ": " + player.CurrentRoom.Inventory.Items[i].Description);
                    }
                    GeneralDataLibrary.Break(2);
                }
                Console.WriteLine(GeneralDataLibrary.I() + "health: " + player.Health.ToString());
                Console.WriteLine(GeneralDataLibrary.I() + "room in bag: " + player.Inventory.SpaceLeft);
            }
        }
Exemple #30
0
        /**
         * Equips an item to a player equip slot so these can later be used for certain actions
         */

        private void equipItem(Command command)
        {
            int num;

            if (command.hasSecondWord())
            {
                if (command.hasThirdWord())
                {
                    if (int.TryParse(command.getSecondWord(), out num))
                    {
                        num++;

                        if (num > 0 && num < player.Inventory.Items.Count)
                        {
                            Item i = player.Inventory.Items[num];

                            switch (command.getThirdWord())
                            {
                            case "hand":

                                if (i is Armor || i is Special)
                                {
                                    Console.WriteLine("You cannot equip armor or special items to your hand!");
                                }
                                else
                                {
                                    if (player.FirstHand == null)
                                    {
                                        player.Inventory.Items.RemoveAt(num);
                                        player.FirstHand = i;
                                        Console.WriteLine("Equipped: " + i.Name + " to hand.");
                                    }
                                    else
                                    {
                                        Item ii = player.FirstHand;
                                        player.Inventory.Items.RemoveAt(num);
                                        player.Inventory.addItem(ii);
                                        player.FirstHand = i;
                                        Console.WriteLine("Unequiped: " + ii.Name + " from hand.");
                                        Console.WriteLine("Equipped: " + i.Name + " to hand.");
                                    }
                                }

                                break;

                            case "offhand":

                                if (i is Armor || i is Special)
                                {
                                    Console.WriteLine("You cannot equip armor or special items to your second hand!");
                                }
                                else
                                {
                                    if (player.SecondHand == null)
                                    {
                                        player.Inventory.Items.RemoveAt(num);
                                        player.SecondHand = i;
                                        Console.WriteLine("Equipped: " + i.Name + " to second hand.");
                                    }
                                    else
                                    {
                                        Item ii = player.SecondHand;
                                        player.Inventory.Items.RemoveAt(num);
                                        player.Inventory.addItem(ii);
                                        player.SecondHand = i;
                                        Console.WriteLine("Unequiped: " + ii.Name + " from second hand.");
                                        Console.WriteLine("Equipped: " + i.Name + " to second hand.");
                                    }
                                }

                                break;

                            case "armor":

                                if (i is Armor)
                                {
                                    if (player.Armor == null)
                                    {
                                        player.Inventory.Items.RemoveAt(num);
                                        player.Armor = i;
                                        Console.WriteLine("Equipped: " + i.Name + " to armor slot.");
                                    }
                                    else
                                    {
                                        Item ii = player.Armor;
                                        player.Inventory.Items.RemoveAt(num);
                                        player.Inventory.addItem(ii);
                                        player.Armor = i;
                                        Console.WriteLine("Unequiped: " + ii.Name + " from armor slot.");
                                        Console.WriteLine("Equipped: " + i.Name + " to armor slot.");
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("You cannot equip anything but armors to the armor slot.");
                                }

                                break;

                            case "special":

                                if (i is Special)
                                {
                                    if (player.Special == null)
                                    {
                                        player.Inventory.Items.RemoveAt(num);
                                        player.Special = i;
                                        Console.WriteLine("Equipped: " + i.Name + " to special slot.");
                                    }
                                    else
                                    {
                                        Item ii = player.Special;
                                        player.Inventory.Items.RemoveAt(num);
                                        player.Inventory.addItem(ii);
                                        player.Special = i;
                                        Console.WriteLine("Unequiped: " + ii.Name + " from special slot.");
                                        Console.WriteLine("Equipped: " + i.Name + " to special slot.");
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("You can only equip specials to this slot");
                                }

                                break;

                            default:
                                Console.WriteLine("That is not an equip slot.");
                                break;
                            }
                        }
                    }
                    else
                    {
                        bool completed = false;
                        for (int i = player.Inventory.Items.Count - 1; i >= 0; i--)
                        {
                            if (completed)
                            {
                                break;
                            }

                            Item ii = player.Inventory.Items[i];

                            if (ii.Name == command.getSecondWord())
                            {
                                switch (command.getThirdWord())
                                {
                                case "hand":

                                    if (ii is Armor || ii is Special)
                                    {
                                        Console.WriteLine("You cannot equip armor or special items to your hand!");
                                    }
                                    else
                                    {
                                        if (player.FirstHand == null)
                                        {
                                            player.Inventory.Items.RemoveAt(i);
                                            player.FirstHand = ii;
                                            Console.WriteLine("Equipped: " + ii.Name + " to hand.");
                                            completed = true;
                                        }
                                        else
                                        {
                                            Item ir = player.FirstHand;
                                            player.Inventory.Items.RemoveAt(i);
                                            player.Inventory.addItem(ir);
                                            player.FirstHand = ii;
                                            Console.WriteLine("Unequiped: " + ir.Name + " from hand.");
                                            Console.WriteLine("Equipped: " + ii.Name + " to hand.");
                                            completed = true;
                                        }
                                    }

                                    break;

                                case "offhand":

                                    if (ii is Armor || ii is Special)
                                    {
                                        Console.WriteLine("You cannot equip armor or special items to your second hand!");
                                    }
                                    else
                                    {
                                        if (player.SecondHand == null)
                                        {
                                            player.Inventory.Items.RemoveAt(i);
                                            player.SecondHand = ii;
                                            Console.WriteLine("Equipped: " + ii.Name + " to second hand.");
                                            completed = true;
                                        }
                                        else
                                        {
                                            Item ir = player.SecondHand;
                                            player.Inventory.Items.RemoveAt(i);
                                            player.Inventory.addItem(ir);
                                            player.SecondHand = ii;
                                            Console.WriteLine("Unequiped: " + ir.Name + " from second hand.");
                                            Console.WriteLine("Equipped: " + ir.Name + " to second hand.");
                                            completed = true;
                                        }
                                    }

                                    break;

                                case "armor":

                                    if (ii is Armor)
                                    {
                                        if (player.Armor == null)
                                        {
                                            player.Inventory.Items.RemoveAt(i);
                                            player.Special = ii;
                                            Console.WriteLine("Equipped: " + ii.Name + " to armor slot.");
                                            completed = true;
                                        }
                                        else
                                        {
                                            Item ir = player.Armor;
                                            player.Inventory.Items.RemoveAt(i);
                                            player.Inventory.addItem(ir);
                                            player.Special = ii;
                                            Console.WriteLine("Unequiped: " + ir.Name + " from armor slot.");
                                            Console.WriteLine("Equipped: " + ir.Name + " to armor slot.");
                                            completed = true;
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine("You cannot equip anything but armors to the armor slot.");
                                    }

                                    break;

                                case "special":

                                    if (ii is Special)
                                    {
                                        if (player.Special == null)
                                        {
                                            player.Inventory.Items.RemoveAt(i);
                                            player.Armor = ii;
                                            Console.WriteLine("Equipped: " + ii.Name + " to special slot.");
                                            completed = true;
                                        }
                                        else
                                        {
                                            Item ir = player.Special;
                                            player.Inventory.Items.RemoveAt(i);
                                            player.Inventory.addItem(ir);
                                            player.Armor = ii;
                                            Console.WriteLine("Unequiped: " + ir.Name + " from special slot.");
                                            Console.WriteLine("Equipped: " + ir.Name + " to special slot.");
                                            completed = true;
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine("You can only equip specials to this slot");
                                    }

                                    break;

                                default:
                                    Console.WriteLine("That is not an equip slot.");
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    for (int i = player.Inventory.Items.Count - 1; i >= 0; i--)
                    {
                        Item ii = player.Inventory.Items[i];

                        if (ii.Name == command.getSecondWord())
                        {
                            if (ii is Armor || ii is Special)
                            {
                                Console.WriteLine("You cannot equip armor or special items to your hand!");
                            }
                            else
                            {
                                if (player.FirstHand == null)
                                {
                                    player.Inventory.Items.RemoveAt(i);
                                    player.FirstHand = ii;
                                    Console.WriteLine("Equipped: " + ii.Name + " to hand.");
                                }
                                else
                                {
                                    Item ir = player.FirstHand;
                                    player.Inventory.Items.RemoveAt(i);
                                    player.Inventory.addItem(ir);
                                    player.FirstHand = ii;
                                    Console.WriteLine("Unequiped: " + ir.Name + " from hand.");
                                    Console.WriteLine("Equipped: " + ii.Name + " to hand.");
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("No item to equip given.");
            }
        }