Beispiel #1
0
        void Heal()
        {
            DungeonMaster.Say("You meet an old lady cooking a fragrant soup. She offers you a bowl of the soup for " +
                              Player.Level * 100 / 3 + " gold mentioning that it's prepared using healing herbs. Are you interested? (y/n)");
            bool choice = Answer();

            if (choice)
            {
                if (CheckIfEnoughGold(Player.Level * 100 / 3))
                {
                    int heal = (int)(0.4 * Player.MaxHealth);
                    Player.CurrentHealth += heal;
                    if (Player.CurrentHealth > Player.MaxHealth)
                    {
                        heal = Player.MaxHealth - (Player.CurrentHealth - heal);
                        Player.CurrentHealth = Player.MaxHealth;
                    }
                    DungeonMaster.Say("You feel warm spreading through your whole body. You feel energized and ready to continue your " +
                                      "adventure. You've got healed for " + heal + " healthpoints");
                }
            }
            else
            {
                DungeonMaster.Say("The woman starts blending the soup and seems to ignore you");
            }
        }
Beispiel #2
0
 bool CheckIfEnoughGold(int price)
 {
     if (price > Player.Gold)
     {
         DungeonMaster.Say("You don't have this much gold");
         return(false);
     }
     return(true);
 }
Beispiel #3
0
        void Steal()
        {
            DungeonMaster.Say("You enter a dark cave. After a few steps you hear feel that your puch has gone. Suddenly you hear " +
                              "a clink of coins somewhere on front of you. You rush rapidly and hit something, it runs away dropping coins. You " +
                              "see that chase doesn't make sense since you can barely see so you focus on collecting the dropped coins");
            Random random = new Random();

            Player.Gold = (random.Next(2, 5) * Player.Gold / 10);
            DungeonMaster.Say("After some time you've collected all of the coins laying on the ground. Now you have " + Player.Gold + " gold");
        }
Beispiel #4
0
 private void Help()
 {
     DungeonMaster.Say("map -> displays the map");
     DungeonMaster.Say("resetmap -> creates a new map");
     DungeonMaster.Say("gold -> displays how much gold you have");
     DungeonMaster.Say("north -> move up on the map");
     DungeonMaster.Say("east -> move right on the map");
     DungeonMaster.Say("south -> move down on the map");
     DungeonMaster.Say("west -> move left on the map");
 }
Beispiel #5
0
 public void FieldAction()
 {
     if (Enemy)
     {
         DungeonMaster.Fight(new Enemy(false));
     }
     if (Boss)
     {
         DungeonMaster.Fight(new Enemy(true));
     }
     if (NPC)
     {
         NPC npc = new NPC();
     }
 }
Beispiel #6
0
 public void Buy()
 {
     Player.Gold -= Price;
     DungeonMaster.Say("The ginger hair dwarf gives you the " + Name);
     if (Attribute == "dmg")
     {
         Player.MinAttack += AttributeValue;
         Player.MaxAttack += AttributeValue;
         DungeonMaster.Say("You feel much stronger now");
     }
     if (Attribute == "hp ")
     {
         Player.MaxHealth     += AttributeValue;
         Player.CurrentHealth += AttributeValue;
         DungeonMaster.Say("You feel that your durability has improved");
     }
 }
        public void Loot()
        {
            Random random     = new Random();
            int    value      = random.Next(0, 10);
            int    multiplier = 25;

            if (Boss)
            {
                multiplier = 75;
            }
            int exp  = Globals.Map(value, 0, 10, multiplier * Player.Level, 4 * multiplier * Player.Level);
            int gold = Globals.Map(value, 0, 10, multiplier * Player.Level, (int)(2.5 * multiplier * Player.Level));

            Player.Exp  += exp;
            Player.Gold += gold;
            DungeonMaster.Say("You gained " + exp + "exp and " + gold + "gold");
        }
Beispiel #8
0
 public void Move(int[] direction)
 {
     if (CheckIfFieldExists(direction))
     {
         Player.Position[0] += direction[0];
         Player.Position[1] += direction[1];
         MapFields[Player.Position[0], Player.Position[1]].FieldAction();
         if (!MapFields[Player.Position[0], Player.Position[1]].Door)
         {
             Visit();
         }
     }
     else
     {
         DungeonMaster.Say("There is an enormous hole that you are not able to overcome");
     }
 }
Beispiel #9
0
 public static void LevelUp(bool initialize)
 {
     while (Exp > NextLevelExp || initialize)
     {
         Level++;
         Exp          -= NextLevelExp;
         NextLevelExp  = 100 * Level;
         MaxHealth     = 100 * Level;
         CurrentHealth = MaxHealth;
         MinAttack     = 5 * Level;
         MaxAttack     = 15 * Level;
         if (!initialize)
         {
             DungeonMaster.Say("You leveled up!");
         }
         initialize = false;
     }
 }
Beispiel #10
0
 bool Answer()
 {
     do
     {
         Player.DisplayStatus();
         char input = Console.ReadKey().KeyChar;
         Console.WriteLine();
         if (input == 'y')
         {
             return(true);
         }
         else if (input == 'n')
         {
             return(false);
         }
         else
         {
             DungeonMaster.Say("Answer with either 'y' or 'n'");
         }
     } while (true);
 }
Beispiel #11
0
        void Trade()
        {
            DungeonMaster.Say("You hear many low voices talking about forging, food and mining. As you peek out from behind a giant " +
                              "you see a group of five dwarves consuming a boar and drinking beer. They seem confused for the first couple of seconds " +
                              "but they quickly find you as a potential client. They present you their goods");
            List <Item> Items = new List <Item>();

            // Dmg items
            Items.Add(new Item("Dagger", 1, "dmg"));
            Items.Add(new Item("Light sword", 2, "dmg"));
            Items.Add(new Item("Rapier", 3, "dmg"));
            Items.Add(new Item("Strong sword", 4, "dmg"));
            Items.Add(new Item("Massive hammer", 13, "dmg"));
            Items.Add(new Item("Berserk's sword", 20, "dmg"));
            // HP items
            Items.Add(new Item("Leather coat", 1, "hp "));
            Items.Add(new Item("Paper armor", 2, "hp "));
            Items.Add(new Item("Chain mail", 4, "hp "));
            Items.Add(new Item("Plate armor", 6, "hp "));
            Items.Add(new Item("Ancient magic armor", 12, "hp "));
            int maxLength = 0;
            int maxAttributeValueLength = 0;
            int maxPriceLength          = 0;

            foreach (Item item in Items)
            {
                if (item.Name.Length + item.AttributeValue.ToString().Length + item.Attribute.Length > maxLength)
                {
                    maxLength = item.Name.Length;
                }
                if (item.AttributeValue.ToString().Length > maxAttributeValueLength)
                {
                    maxAttributeValueLength = item.AttributeValue.ToString().Length;
                }
                if (item.Price.ToString().Length > maxPriceLength)
                {
                    maxPriceLength = item.Price.ToString().Length;
                }
            }
            foreach (Item item in Items)
            {
                item.DisplayItem(maxLength, maxAttributeValueLength, maxPriceLength);
            }
            DungeonMaster.Say("You have " + Player.Gold + " gold. Do you want to buy something? (y/n)");
            while (Answer())
            {
                DungeonMaster.Say("Go ahead, choose something");
                while (true)
                {
                    Player.DisplayStatus();
                    string input = Console.ReadLine();
                    if (input.StartsWith("buy "))
                    {
                        input = input.Remove(0, 4);
                        int id;
                        try { id = int.Parse(input); }
                        catch (StackOverflowException)
                        { DungeonMaster.Say("The dwarves don't have such an item for sell"); continue; }
                        catch (FormatException)
                        {
                            DungeonMaster.Say("Just tell me what's the number of the item on the list. Don't forget that " +
                                              "dwarves count from 0.");
                            continue;
                        }
                        try
                        {
                            if (CheckIfEnoughGold(Items[id].Price))
                            {
                                Items[id].Buy();
                            }
                            break;
                        }
                        catch (IndexOutOfRangeException)
                        { DungeonMaster.Say("The dwarves don't have such an item for sell"); }
                    }
                    else
                    {
                        DungeonMaster.Say("The dwarves don't have such an item for sell");
                    }
                }
            }
            DungeonMaster.Say("You greet the dwarves and continue the adventure, they go back to feasting");
        }
Beispiel #12
0
        public void Play()
        {
            string input;

            DungeonMaster.Say("I created a map for today's session");
            DungeonMaster.Say("If you feel confused ask me about help");
            DungeonMaster.Say("If you don't like it use the resetmap command");
            _Map.Show();
            while (Player.IsAlive)
            {
                Player.DisplayStatus();
                input = Console.ReadLine();
                switch (input.ToLower())
                {
                case "help":
                    Help();
                    break;

                case "map":
                    _Map.Show();
                    break;

                case "resetmap":
                    DungeonMaster.Say("This is the new map, I hope you like it");
                    _Map = new Map();
                    _Map.Show();
                    break;

                case "gold":
                    DungeonMaster.Say("You have " + Player.Gold + " gold");
                    break;

                case "north":
                    _Map.Move(new int[2] {
                        0, -1
                    });
                    break;

                case "east":
                    _Map.Move(new int[2] {
                        1, 0
                    });
                    break;

                case "south":
                    _Map.Move(new int[2] {
                        0, 1
                    });
                    break;

                case "west":
                    _Map.Move(new int[2] {
                        -1, 0
                    });
                    break;

                default:
                    Console.WriteLine("Unknown command used");
                    break;
                }
                // Check if player reached the door to the next level
                if (_Map.MapFields[Player.Position[0], Player.Position[1]].Door)
                {
                    DungeonMaster.Say("Congratulations, you've reached The Door. Good luck on another level of this dungeon");
                    _Map = new Map();
                    DungeonMaster.Say("This is the new level, if you don't like it use the resetmap command");
                    _Map.Show();
                }
            }
        }