Example #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);
                }
            }
        }
Example #2
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.");
     }
 }
Example #3
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?");
            }
        }
Example #4
0
        /**
         * Given a command, process (that is: execute) the command.
         * If this command ends the game, true is returned, otherwise false is
         * returned.
         */
        private bool processCommand(Command command)
        {
            bool wantToQuit = false;

            if (command.isUnknown())
            {
                Console.WriteLine("I don't know what you mean...");
                return(false);
            }

            string commandWord = command.getCommandWord();

            switch (commandWord)
            {
            case "help":
                printHelp();
                break;

            case "go":
                goRoom(command);
                if (player.Health <= 0)
                {
                    wantToQuit = true;
                }
                break;

            case "ragequit":
                wantToQuit = true;
                break;

            case "look":
                Console.WriteLine(player.Currentroom.getLongDescription());
                player.Currentroom.Inventory.GetItemsRoom();
                break;

            case "take":
                player.Currentroom.Inventory.Take(player.Inventory, command.getSecondWord());
                break;

            case "drop":
                player.Inventory.Drop(player.Currentroom.Inventory, command.getSecondWord());
                break;

            case "use":
                use(command);
                if (player.Health <= 0)
                {
                    wantToQuit = true;
                }
                break;

            case "inventory":
                player.Inventory.GetItemsPlayer();
                break;
            }

            return(wantToQuit);
        }
Example #5
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.");
            }
        }
Example #6
0
        /**
         * Used to trigger the attack on the enemy
         */

        private void attackEnemy(Command command)
        {
            if (player.CurrentRoom.Enemies != null)
            {
                if (command.getSecondWord() != null)
                {
                    for (int i = player.CurrentRoom.Enemies.Count - 1; i >= 0; i--)
                    {
                        if (player.CurrentRoom.Enemies[i].Name == command.getSecondWord())
                        {
                            if (player.attack(player, player.CurrentRoom.Enemies[i]))
                            {
                                Console.WriteLine(GeneralDataLibrary.I() + player.CurrentRoom.Enemies[i].Name + " has died!");

                                if (player.CurrentRoom.Enemies[i].FirstHand != null)
                                {
                                    player.CurrentRoom.Inventory.addItem(player.CurrentRoom.Enemies[i].FirstHand);
                                }

                                if (player.CurrentRoom.Enemies[i].SecondHand != null)
                                {
                                    player.CurrentRoom.Inventory.addItem(player.CurrentRoom.Enemies[i].SecondHand);
                                }

                                if (player.CurrentRoom.Enemies[i].Armor != null)
                                {
                                    player.CurrentRoom.Inventory.addItem(player.CurrentRoom.Enemies[i].Armor);
                                }

                                if (player.CurrentRoom.Enemies[i].Special != null)
                                {
                                    player.CurrentRoom.Inventory.addItem(player.CurrentRoom.Enemies[i].Special);
                                }

                                player.CurrentRoom.Enemies.RemoveAt(i);
                            }
                            else
                            {
                                Console.WriteLine(GeneralDataLibrary.I() + player.CurrentRoom.Enemies[i].Name + " has: " + player.CurrentRoom.Enemies[i].Health + " health left!");
                            }

                            GeneralDataLibrary.Break();
                            break;
                        }
                    }
                }
            }
        }
Example #7
0
        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);
            }
        }
Example #8
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());
            }
        }
Example #9
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);
            }
        }
Example #10
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());
                }
            }
        }
Example #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();

            // 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());
            }
        }
Example #12
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());
            }
        }
Example #13
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());
                }
            }
        }
Example #14
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());
                    }
                }
            }
        }
Example #15
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();
            }
        }
Example #16
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!");
            }
        }
Example #17
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?");
            }
        }
Example #18
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);
            }
        }
Example #19
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);
                }
            }
        }
Example #20
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());
            }
        }
Example #21
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());
                }
            }
        }
Example #22
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("");
            }
        }
Example #23
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");
                }
            }
        }
Example #24
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.");
            }
        }
Example #25
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!");
            }
        }
Example #26
0
        public void UnlockDoor(Command command)
        {
            string direction = command.getSecondWord();

            player.currentRoom.CheckForLockedExits(direction);

            /*string direction = command.getSecondWord();
             *
             *  if (player.currentRoom.CheckForLockedExits(direction))
             *  {
             *      player.currentRoom.
             *  }
             *  else
             *  {
             *      Console.WriteLine("The room isn't locked.");
             *  }
             * } else
             * {
             *  Console.WriteLine("Nextroom = null");
             * }
             */
        }
Example #27
0
        /**
         * Use an item can have a lto of different targets and a can take an item index or and equip slot for the item to use
         */

        private void useItem(Command command)
        {
            Item i = null;

            switch (command.getSecondWord())
            {
            case "hand":
                i = player.FirstHand;
                break;

            case "offhand":
                i = player.SecondHand;
                break;

            default:
                int num;
                if (int.TryParse(command.getSecondWord(), out num))
                {
                    if (num > 0 && num < player.Inventory.Items.Count - 1)
                    {
                        i = player.Inventory.Items[num];
                    }
                }
                else
                {
                    for (int ii = player.Inventory.Items.Count - 1; ii >= 0; ii--)
                    {
                        if (player.Inventory.Items[ii].Name == command.getSecondWord())
                        {
                            i = player.Inventory.Items[ii];
                            break;
                        }
                    }
                }
                break;
            }

            if (i == null)
            {
                Console.WriteLine("No item found on index, name or slot!");
                return;
            }

            else
            {
                if (command.hasThirdWord())
                {
                    if (player.CurrentRoom.getExit(command.getThirdWord()) != null)
                    {
                        if (i.use(player.CurrentRoom.getExit(command.getThirdWord())))
                        {
                            destroyItem(command.getSecondWord());
                        }
                    }
                    else
                    {
                        Console.WriteLine(GeneralDataLibrary.Note() + "That exit doesn't exist!");
                    }
                }
                else
                {
                    if (i.use(player))
                    {
                        destroyItem(command.getSecondWord());
                    }
                }
            }
        }
Example #28
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);
            }
        }
Example #29
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.");
            }
        }
Example #30
0
        /* public InventoryItem usable(string name)
         * {
         *    foreach(InventoryItem item in player.PlayerItems)
         *    {
         *        if(item.name == name && item.healing == true)
         *        {
         *            return item;
         *        }
         *    }
         *    return null;
         * }*/


        /**
         * Given a command, process (that is: execute) the command.
         * If this command ends the game, true is returned, otherwise false is
         * returned.
         */
        private bool processCommand(Command command)
        {
            bool wantToQuit = false;

            if (command.isUnknown())
            {
                Console.WriteLine("I don't know what you mean...");
                return(false);
            }

            if (player.isAlive() == true)
            {
                //inv.lookAtItmes();
                string commandWord = command.getCommandWord();
                switch (commandWord)
                {
                case "help":
                    printHelp();
                    break;

                case "go":
                    goRoom(command);

                    break;

                case "quit":
                    wantToQuit = true;
                    break;

                case "look":
                    Console.WriteLine(player.CurrentRoom.getLongDescription());
                    player.CurrentRoom.RoomInventory.GetItemsRoom();
                    break;

                case "take":
                    player.CurrentRoom.RoomInventory.Take(player.PlayerInventory, command.getSecondWord());
                    break;

                case "drop":
                    player.PlayerInventory.Drop(player.CurrentRoom.RoomInventory, command.getSecondWord());
                    break;

                case "inventory":
                    foreach (Item item in player.PlayerInventory.Items)
                    {
                        Console.WriteLine(item.name);
                    }
                    break;

                case "use":
                    useItem(command);
                    //Item itemToUse = player.PlayerInventory.GetFirstPlayerItem(command.getSecondWord());
                    //itemToUse.use(player);


                    // Item keyToUse = player.PlayerInventory.GetKey(command.getThirdWord());
                    // keyToUse.use(player);


                    // player.PlayerInventory.Drop(itemToUse);
                    break;
                }
            }
            else
            {
                Console.WriteLine("you are dead");

                wantToQuit = true;
            }


            return(wantToQuit);
        }