Exemple #1
0
        /**
         * Show all items in the players bag, equip slots and tell them how much space they have left
         */

        private void displayBag()
        {
            int    iC  = player.Inventory.Items.Count;
            string str = "";

            if (iC > 1 || iC <= 0)
            {
                str = "s";
            }
            Console.WriteLine(GeneralDataLibrary.I() + iC + " Item" + str + " found in bag.");
            if (iC > 0)
            {
                GeneralDataLibrary.ShortLine(GeneralDataLibrary.I());
                GeneralDataLibrary.Break();
                for (int i = 0; i < iC; i++)
                {
                    Console.WriteLine(GeneralDataLibrary.I(2) + (i + 1) + ": " + player.Inventory.Items[i].Name);
                }
            }
            GeneralDataLibrary.Break();
            Console.WriteLine(GeneralDataLibrary.I() + player.Inventory.SpaceLeft + " space left in bag.");
            GeneralDataLibrary.Break();

            if (player.FirstHand != null)
            {
                Console.WriteLine(GeneralDataLibrary.I() + "hand: " + player.FirstHand.Name + " - " + player.FirstHand.Description);
            }
            else
            {
                Console.WriteLine(GeneralDataLibrary.I() + "hand: " + "<empty>");
            }

            if (player.SecondHand != null)
            {
                Console.WriteLine(GeneralDataLibrary.I() + "offhand: " + player.SecondHand.Name + " - " + player.SecondHand.Description);
            }
            else
            {
                Console.WriteLine(GeneralDataLibrary.I() + "offhand: " + "<empty>");
            }

            if (player.Armor != null)
            {
                Console.WriteLine(GeneralDataLibrary.I() + "armor: " + player.Armor.Name + " - " + player.Armor.Description);
            }
            else
            {
                Console.WriteLine(GeneralDataLibrary.I() + "armor: " + "<empty>");
            }

            if (player.Special != null)
            {
                Console.WriteLine(GeneralDataLibrary.I() + "special: " + player.Special.Name + " - " + player.Special.Description);
            }
            else
            {
                Console.WriteLine(GeneralDataLibrary.I() + "special: " + "<empty>");
            }
        }
Exemple #2
0
 /**
  * Print out the opening message for the player.
  */
 private void printWelcome()
 {
     GeneralDataLibrary.Break();
     Console.WriteLine("Welcome to Dynasty!");
     Console.WriteLine("You wake up with a headache looking around you seem to be in a tower of sorts.");
     Console.WriteLine("Type 'help' if you need help.");
     GeneralDataLibrary.Break();
     Console.WriteLine(player.CurrentRoom.getLongDescription());
     GeneralDataLibrary.Break();
     GeneralDataLibrary.LongLine();
     GeneralDataLibrary.Break();
 }
Exemple #3
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 #4
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;
                        }
                    }
                }
            }
        }
Exemple #5
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 #6
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 #7
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 #8
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(GeneralDataLibrary.I() + "I don't know what you mean...");
                Console.WriteLine(GeneralDataLibrary.I() + "Type: 'help' if you need help.");
                return(false);
            }

            string commandWord = command.getCommandWord();

            GeneralDataLibrary.Break();

            switch (commandWord)
            {
            case "help":

                printHelp(command);

                break;

            case "go":

                triggerCharacterAI();
                GeneralDataLibrary.Break();
                GeneralDataLibrary.LongLine();
                GeneralDataLibrary.Break();
                goRoom(command);

                break;

            case "quit":

                wantToQuit = true;

                break;

            case "look":

                lookAround(command);

                break;

            case "clear":

                ClearConsole(command);

                break;

            case "take":

                triggerCharacterAI();
                GeneralDataLibrary.Break();
                GeneralDataLibrary.LongLine();
                GeneralDataLibrary.Break();
                takeItem(command);

                break;

            case "drop":

                triggerCharacterAI();
                GeneralDataLibrary.Break();
                GeneralDataLibrary.LongLine();
                GeneralDataLibrary.Break();
                dropItem(command);

                break;

            case "bag":

                displayBag();

                break;

            case "use":

                triggerCharacterAI();
                GeneralDataLibrary.Break();
                GeneralDataLibrary.LongLine();
                GeneralDataLibrary.Break();
                useItem(command);

                break;

            case "equip":

                triggerCharacterAI();
                GeneralDataLibrary.Break();
                GeneralDataLibrary.LongLine();
                GeneralDataLibrary.Break();
                equipItem(command);

                break;

            case "unequip":

                triggerCharacterAI();
                GeneralDataLibrary.Break();
                GeneralDataLibrary.LongLine();
                GeneralDataLibrary.Break();
                unequipItem(command);

                break;

            case "attack":

                triggerCharacterAI();
                GeneralDataLibrary.Break();
                GeneralDataLibrary.LongLine();
                GeneralDataLibrary.Break();
                attackEnemy(command);

                break;
            }

            GeneralDataLibrary.Break();
            GeneralDataLibrary.LongLine();
            GeneralDataLibrary.Break();

            return(wantToQuit);
        }