Exemple #1
0
 public void SellBackPotion(int inputNumber)
 {
     if (PotionBag.Any())
     {
         this.Gold += (this.PotionBag[inputNumber].Price - 1);
         this.PotionBag.RemoveAt(inputNumber);
     }
 }
Exemple #2
0
        public void UseHealthPotion(int inputNumber)
        {
            if (PotionBag.Any())
            {
                int roundHP;
                roundHP = this.CurrentHP + this.PotionBag[inputNumber].HealthRestored;
                if (roundHP <= this.OriginalHP)
                {
                    this.CurrentHP = roundHP;
                }
                else
                {
                    this.CurrentHP = this.OriginalHP;
                }

                this.PotionBag.RemoveAt(inputNumber);
            }
        }
Exemple #3
0
        public void ShowInventory()
        {
            int num1  = 1;
            int num2  = 1;
            var input = "0";

            while (input != "9")
            {
                Console.WriteLine("*****  INVENTORY ******");
                Console.WriteLine("Weapons: ");

                foreach (var weapon in this.WeaponsBag)
                {
                    Console.WriteLine(num1 + " " + weapon.Name + " of " + weapon.Strength + " Strength");
                    num1++;
                }

                Console.WriteLine("Armor: ");

                foreach (var armor in this.ArmorsBag)
                {
                    Console.WriteLine(num2 + " " + armor.Name + " of " + armor.Defense + " Defense");
                    num2++;
                }
                ;

                Console.WriteLine("Shield: ");

                foreach (var shield in this.ShieldBag)
                {
                    Console.WriteLine(num2 + " " + shield.Name + " of " + shield.Defense + " Defense");
                    num2++;
                }
                ;

                Console.WriteLine("Potions: ");

                foreach (var potion in this.PotionBag)
                {
                    Console.WriteLine(num1 + " " + potion.Name + " of " + potion.HealthRestored + " Health");
                    num1++;
                }
                if (EquippedWeapon != null)
                {
                    Console.WriteLine("Equipped Weapon: " + EquippedWeapon.Name);
                }
                else
                {
                    Console.WriteLine("Equipped Weapon: None");
                };

                if (EquippedArmor != null)
                {
                    Console.WriteLine("Equipped Armor: " + EquippedArmor.Name);
                }
                else
                {
                    Console.WriteLine("Equipped Armor: None");
                };

                if (EquippedShield != null)
                {
                    Console.WriteLine("Equipped Shield: " + EquippedShield.Name);
                }
                else
                {
                    Console.WriteLine("Equipped Shield: None");
                };

                Console.WriteLine("Gold: " + Gold);
                Console.WriteLine("Please choose an option by entering a number.");
                Console.WriteLine("1. Equip Armor");
                Console.WriteLine("2. Equip Weapon");
                Console.WriteLine("3. UnEquip Armor");
                Console.WriteLine("4. UnEquip Weapon");
                Console.WriteLine("5. Heal");
                Console.WriteLine("6. Sell");
                Console.WriteLine("7. Equip Shield");
                Console.WriteLine("8. UnEquip Shield");
                Console.WriteLine("9. Return to Main Menu");


                input = Console.ReadLine();
                int inputNumber = Int32.Parse(input) - 1;

                if (input == "1")
                {
                    int num3 = 1;
                    Console.WriteLine("Please choose the armor to equip by entering a number.");
                    foreach (var armor in this.ArmorsBag)
                    {
                        Console.WriteLine(num3 + " " + armor.Name + " of " + armor.Defense + " Defense");
                        num3++;
                    }
                    ;
                    input       = Console.ReadLine();
                    inputNumber = Int32.Parse(input) - 1;
                    this.EquipArmor(inputNumber);
                }
                else if (input == "2")
                {
                    int num4 = 1;
                    Console.WriteLine("Please choose the weapon to equip by entering a number.");
                    foreach (var weapon in this.WeaponsBag)
                    {
                        Console.WriteLine(num4 + " " + weapon.Name + " of " + weapon.Strength + " Strength");
                        num4++;
                    }
                    input       = Console.ReadLine();
                    inputNumber = Int32.Parse(input) - 1;
                    this.EquipWeapon(inputNumber);
                }
                else if (input == "3")
                {
                    this.TotalDefense -= this.EquippedArmor.Defense;
                    this.EquippedArmor = null;
                }
                else if (input == "4")
                {
                    this.TotalStrength -= this.EquippedWeapon.Strength;
                    this.EquippedWeapon = null;
                }
                else if (input == "8")
                {
                    this.TotalDefense  -= this.EquippedShield.Defense;
                    this.EquippedShield = null;
                }
                else if (input == "5")
                {
                    Console.WriteLine("Please choose the potion to heal with by entering a number.");
                    int i;
                    for (i = 0; i < this.PotionBag.Count(); i++)
                    {
                        Console.WriteLine($"{i + 1} {this.PotionBag[i].Name} of {this.PotionBag[i].HealthRestored} Health");
                    }

                    input       = Console.ReadLine();
                    inputNumber = Int32.Parse(input) - 1;
                    this.UseHealthPotion(inputNumber);
                }
                else if (input == "6")
                {
                    var inputKey = "0";
                    while (inputKey != "4")
                    {
                        Console.WriteLine("Please chose which item type to sell by entering a number.");
                        Console.WriteLine("1. Armor");
                        Console.WriteLine("2. Weapon");
                        Console.WriteLine("3. Potion");
                        Console.WriteLine("4. Return");
                        inputKey = Console.ReadLine();
                        var inputNumber2 = Int32.Parse(inputKey) - 1;

                        if (inputKey == "1")
                        {
                            if (ArmorsBag.Any())
                            {
                                Console.WriteLine("Please choose the Armor to sell with by entering a number.");
                                int i;
                                for (i = 0; i < this.ArmorsBag.Count(); i++)
                                {
                                    Console.WriteLine($"{i + 1} {this.ArmorsBag[i].Name} of {this.ArmorsBag[i].Defense} Defence for {this.ArmorsBag[i].Price - 1} Gold");
                                }
                                inputKey     = Console.ReadLine();
                                inputNumber2 = Int32.Parse(inputKey) - 1;
                                SellBackArmor(inputNumber2);
                            }
                            else
                            {
                                Console.WriteLine("Armor Bag Empty");
                            }
                        }
                        else if (inputKey == "2")
                        {
                            if (WeaponsBag.Any())
                            {
                                Console.WriteLine("Please choose the Weapon to sell by entering a number.");
                                int i;
                                for (i = 0; i < this.WeaponsBag.Count(); i++)
                                {
                                    Console.WriteLine($"{i + 1} {this.WeaponsBag[i].Name} of {this.WeaponsBag[i].Strength} Strength, Selling Price: {this.WeaponsBag[i].Price - 1}");
                                }
                                inputKey     = Console.ReadLine();
                                inputNumber2 = Int32.Parse(inputKey) - 1;
                                SellBackWeapon(inputNumber2);
                            }
                            else
                            {
                                Console.WriteLine("Weapon Bag Empty");
                            }
                        }
                        else if (inputKey == "3")
                        {
                            if (PotionBag.Any())
                            {
                                Console.WriteLine("Please choose the Potion to sell by entering a number.");
                                int i;
                                for (i = 0; i < this.PotionBag.Count(); i++)
                                {
                                    Console.WriteLine($"{i + 1} {this.PotionBag[i].Name} of {this.PotionBag[i].HealthRestored} Health for {this.PotionBag[i].Price - 1} Gold");
                                }
                                inputKey     = Console.ReadLine();
                                inputNumber2 = Int32.Parse(inputKey) - 1;
                                SellBackPotion(inputNumber2);
                            }
                            else
                            {
                                Console.WriteLine("Potion Bag Empty");
                            }
                        }
                    }
                }
                if (input == "7")
                {
                    int num3 = 1;
                    Console.WriteLine("Please choose the shield to equip by entering a number.");
                    foreach (var shield in this.ShieldBag)
                    {
                        Console.WriteLine(num3 + " " + shield.Name + " of " + shield.Defense + " Defense");
                        num3++;
                    }
                    ;
                    input       = Console.ReadLine();
                    inputNumber = Int32.Parse(input) - 1;
                    this.EquipShield(inputNumber);
                }
            }
        }