Esempio n. 1
0
        public void RemoveWeapon()
        {
            if (!(this.EquippedWeapon.Name is null))
            {
                Console.WriteLine($"\nYou currently have {EquippedWeapon.Name} of {EquippedWeapon.Strength} strength equipped");
                Console.WriteLine($"Would you like to remove {EquippedWeapon.Name} of {EquippedWeapon.Strength} Strength?");

                Console.Write("\nYes (y) or No (n): ");
                var input = Console.ReadLine();

                switch (input.ToLower())
                {
                case "yes":
                case "y":
                    this.Strength -= EquippedWeapon.Strength;
                    WeaponsBag.Add(EquippedWeapon);
                    Console.WriteLine($"\nYour {EquippedWeapon.Name} of {EquippedWeapon.Strength} strength has been removed.");
                    Console.WriteLine($"You are now weaker, loosing {EquippedWeapon.Strength} strength, and now have a stgrength of {this.Strength}");
                    EquippedWeapon = new Weapon();

                    Console.WriteLine("\nPress any key to continue.");
                    Console.ReadKey();
                    Console.Clear();
                    break;

                case "no":
                case "n":
                    break;

                default:
                    Console.WriteLine($"\nYou have chosen an invalid option try again");
                    this.RemoveWeapon();
                    break;
                }
            }
 public void EquipWeapon(int selectedIndex)
 {
     if (WeaponsBag.Any())
     {
         this.EquippedWeapon = this.WeaponsBag[selectedIndex];
     }
 }
Esempio n. 3
0
 public void EquipWeapon()
 {
     if (WeaponsBag.Any())
     {
         this.EquippedWeapon = this.WeaponsBag[0];
     }
 }
Esempio n. 4
0
 public void EquipWeapon(int inputNumber)
 {
     if (WeaponsBag.Any())
     {
         this.EquippedWeapon = this.WeaponsBag[inputNumber];
         this.TotalStrength += this.WeaponsBag[inputNumber].Strength;
     }
 }
Esempio n. 5
0
        public void AddWeapons(string name, int power, int price)
        {
            Weapon weapon = new Weapon();

            weapon.ItemName = name;
            weapon.Power    = power;
            weapon.Price    = price;
            WeaponsBag.Add(weapon);
        }
Esempio n. 6
0
        public void Sell()
        {
            if (UserItemCatalog.Count == 0)
            {
                Console.WriteLine("");
                Console.WriteLine("You have no items to sell");
                Console.ReadKey();
                Shop.Menu();
            }

            var selection = "";

            while (string.IsNullOrEmpty(selection))
            {
                Console.WriteLine("");
                Console.Write("What would you like to sell? ");

                selection = Console.ReadLine();
            }

            if (!UserItemCatalog.ContainsKey(selection))
            {
                Console.WriteLine("");
                Console.WriteLine("Please provide a valid selection.");
                Sell();
            }
            //I need to know what type of object the user has selected so I will look
            //at the first letter of the key (a, w, p)

            switch (selection.Substring(0, 1))
            {
            case "a":
                var armor = (Armor)UserItemCatalog[selection];
                ArmorsBag.Remove(armor);
                Gold += armor.ResellValue;
                Shop.ArmorsList.Add(armor);
                break;

            case "w":
                var weapon = (Weapon)UserItemCatalog[selection];
                WeaponsBag.Remove(weapon);
                Gold += weapon.ResellValue;
                Shop.WeaponsList.Add(weapon);
                break;

            case "p":
                var potion = (Potion)UserItemCatalog[selection];
                PotionsBag.Remove(potion);
                Gold += potion.ResellValue;
                Shop.PotionsList.Add(potion);
                break;

            default:
                Shop.Menu();
                break;
            }
        }
Esempio n. 7
0
        public Weapon EquipWeapon(List <Weapon> weaponsList)
        {
            Random random        = new Random();
            int    weapon        = random.Next(weaponsList.Count);
            Weapon spawnedWeapon = weaponsList[weapon];

            WeaponsBag.Remove(weaponsList[weapon]);
            return(spawnedWeapon);
        }
Esempio n. 8
0
        public void UnEquipWeapon(Weapon EquippedWeapon)
        {
            WeaponsBag.Add(EquippedWeapon);
            Strength -= EquippedWeapon.Strength;
            Console.WriteLine($"You Are Now Longer Weilding a {EquippedWeapon.Name} For + {EquippedWeapon.Strength} Strength");
            this.EquippedWeapon = null;

            Console.WriteLine();
            ShowInventory();
        }
Esempio n. 9
0
 public void EquipWeapon()
 {
     if (WeaponsBag.Any())
     {
         {
             if (this.EquippedWeapon != null)
             {
                 ;
             }
         }
         this.EquippedWeapon = this.WeaponsBag[0];
         this.Strength      += this.EquippedWeapon.Strength;
     }
 }
Esempio n. 10
0
        public void EquipWeapon()
        {
            UserItemCatalog.Clear();
            Console.WriteLine("");
            Console.WriteLine("*****Weapons*****");
            var count = 1;

            foreach (var weapon in this.WeaponsBag)
            {
                Console.WriteLine($"{count}: {weapon.Name} with {weapon.Strength} strength");

                UserItemCatalog.Add($"{count}", weapon);
                count++;
            }

            if (UserItemCatalog.Count == 0)
            {
                Console.WriteLine("You have no weapons to use");
                Console.ReadKey();
                Shop.Menu();
            }

            var selection = "";

            while (string.IsNullOrEmpty(selection))
            {
                Console.WriteLine("");
                Console.Write("Make a selection: ");

                selection = Console.ReadLine();
            }

            var intselection = Convert.ToInt32(selection);

            if (intselection < 1 || intselection > UserItemCatalog.Count)
            {
                Console.WriteLine("Please make a valid selection");
                EquipWeapon();
                Console.ReadKey();
            }
            else
            {
                var weapon = (Weapon)UserItemCatalog[selection];
                WeaponsBag.Remove(weapon);
                EquippedWeapon = weapon;
                Strength      += weapon.Strength;
                Game.Main();
            }
        }
Esempio n. 11
0
 public void SellBackWeapon(int inputNumber)
 {
     if (WeaponsBag.Any())
     {
         if (this.EquippedWeapon != null && (this.EquippedWeapon.Name == this.WeaponsBag[inputNumber].Name))
         {
             Console.WriteLine("Item equipped, please unequip it from the inventory first and try again");
         }
         else
         {
             this.Gold += (this.WeaponsBag[inputNumber].Price - 1);
             this.WeaponsBag.RemoveAt(inputNumber);
         }
     }
 }
Esempio n. 12
0
 public void EquipWeapon()
 {
     if (WeaponsBag.Any())
     {
         this.EquippedWeapon = this.WeaponsBag[0];
         this.Strength      += EquippedWeapon.Strength;
         Console.WriteLine($"{this.EquippedWeapon.Name} is equiped!");
     }
     else if (ArmorsBag.Any())
     {
         this.EquippedArmor = this.ArmorsBag[0];
         this.Defense      += EquippedArmor.Defense;
         Console.WriteLine($"{this.EquippedArmor.Name} is equiped!");
     }
     Console.WriteLine("Now, you become stonger!\nPress any key to return to main menu.");
 }
Esempio n. 13
0
 public void EquipWeapon()
 {
     if (WeaponsBag.Any())
     {
         if (WeaponsBag[0] != null)
         {
             this.EquippedWeapon = this.WeaponsBag[0];
             this.Strength       = this.EquippedWeapon.Strength + this.Strength;
             Console.WriteLine($"You get {this.EquippedWeapon.Strength} strength.");
             Console.WriteLine($"Your Strength is {this.Strength} now.");
         }
         else
         {
             this.Strength = 10;
         }
     }
 }
Esempio n. 14
0
 public void EquipWeapon(int WeaponIndex)
 {
     if (WeaponsBag.Any())
     {
         if (this.EquippedWeapon == null)
         {
             this.EquippedWeapon = this.WeaponsBag[WeaponIndex];
             this.Strength      += this.EquippedWeapon.Strength;
             this.WeaponsBag.RemoveAt(WeaponIndex);
         }
         else
         {
             this.Strength -= this.EquippedWeapon.Strength;
             this.WeaponsBag.Add(this.EquippedWeapon);
             this.EquippedWeapon = this.WeaponsBag[WeaponIndex];
             this.Strength      += this.EquippedWeapon.Strength;
             this.WeaponsBag.RemoveAt(WeaponIndex);
         }
     }
 }
Esempio n. 15
0
        public void GetWeapon()
        {
            if (WeaponsBag.Count == 0)
            {
                Console.WriteLine("You don't have weapon in your bag.");
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("You have the following weapons in your bag.");

                foreach (Weapon weapon in WeaponsBag)
                {
                    int num = WeaponsBag.IndexOf(weapon) + 1;
                    Console.WriteLine("Number {0}:", num);
                    Console.WriteLine(weapon);
                }
                Console.WriteLine("Press the number to choose the weapon:");

                string inputValue = Console.ReadLine();
                Console.WriteLine();

                int    inputresult  = checkInputValue(inputValue, WeaponsBag.Count);
                Weapon chosenWeapon = WeaponsBag[inputresult - 1];
                Console.WriteLine("You choose the number of {0} weapon in your bag.", inputresult);
                Console.WriteLine(chosenWeapon);
                Console.WriteLine("-----------------------------------");
                Console.WriteLine();
                if (EquippedWeapon == null)
                {
                    EquippedWeapon = chosenWeapon;
                }
                else
                {
                    WeaponsBag.Add(EquippedWeapon);
                    EquippedWeapon = chosenWeapon;
                    WeaponsBag.Remove(chosenWeapon);
                }
            }
        }
Esempio n. 16
0
        public void EquipWeapon(Weapon weapon)
        {
            if (EquippedWeapon == null)
            {
                this.EquippedWeapon = weapon;
                WeaponsBag.Remove(weapon);
                Strength += weapon.Strength;
                Console.WriteLine($"You Are Now Weilding a {weapon.Name} For + {weapon.OriginalValue} Strength");
                Console.WriteLine();
                ShowInventory();
            }
            else
            {
                Console.WriteLine("You already have a weapon equipped.");
                Console.WriteLine();
                Console.WriteLine("What would you like to do?");
                Console.WriteLine("1. Back to Inventory.");
                Console.WriteLine("2. Continue Adventure.");
                Console.WriteLine("3. Back To Town.");

                var input = Console.ReadLine();
                if (input == "1")
                {
                    this.ShowInventory();
                }
                else if (input == "2")
                {
                    var explore = new Explore(this, Game);
                    explore.Start();
                }
                else if (input == "3")
                {
                    Console.WriteLine("Press any key to return to main menu.");
                    Console.ReadKey();
                    this.Game.Main();
                }
            }
        }
Esempio n. 17
0
        public void EquipWeapon()
        {
            if (EquippedWeapon != null)
            {
                Console.WriteLine("You're already equip a weapon");
                Console.ReadKey();
                ShowInventory();
            }
            MakeYouStrong.Clear();
            Console.WriteLine("");
            Console.WriteLine("*****Weapons*****");
            var countWeapon = 1;

            foreach (var w in this.WeaponsBag)
            {
                Console.WriteLine($"{countWeapon}: {w.Name} with {w.Strength} strength");
                MakeYouStrong.Add($"{countWeapon}", w);
                countWeapon++;
                Console.WriteLine("Do you like to equip this weapon ? Press 1. to equip");
            }

            if (MakeYouStrong.Count == 0)
            {
                Console.WriteLine("You don't any weapons to equip");
            }
            else
            {
                var selection = Console.ReadLine();
                var weapon    = (Weapon)MakeYouStrong[selection];
                WeaponsBag.Remove(weapon);
                EquippedWeapon = weapon;
                Strength      += weapon.Strength;
                Console.WriteLine("");
                Console.WriteLine("You are successful to equip this weapon");
            }
        }
Esempio n. 18
0
        public void ShowInventory()
        {
            Console.WriteLine("The current equipments of the hero:");
            if (EquippedWeapon == null)
            {
                Console.WriteLine("No equiped weapon of the hero.");
                Console.WriteLine("------------------------------");
            }
            else
            {
                Console.WriteLine(EquippedWeapon);
            }
            if (WeaponsBag.Count == 0)
            {
                Console.WriteLine("You don't have weapon in your bag.");
                Console.WriteLine("------------------------------");
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("You have the following weapons in your bag.");
                foreach (Weapon weapon in WeaponsBag)
                {
                    int num = WeaponsBag.IndexOf(weapon) + 1;
                    Console.WriteLine("Number {0}:", num);
                    Console.WriteLine(weapon);
                    Console.WriteLine();
                }
            }

            if (EquippedArmor == null)
            {
                Console.WriteLine("No Armor of the hero.");
                Console.WriteLine("------------------------------");
            }
            else
            {
                Console.WriteLine(EquippedArmor);
            }

            if (ArmorsBag.Count == 0)
            {
                Console.WriteLine("You don't have armor in your bag.");
                Console.WriteLine("------------------------------");
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("You have the following weapons in your bag.");

                foreach (Armor armor in ArmorsBag)
                {
                    int num = ArmorsBag.IndexOf(armor) + 1;
                    Console.WriteLine("Number {0}:", num);
                    Console.WriteLine(armor);
                    Console.WriteLine();
                }
            }
            Console.WriteLine("----------------------------");
            Console.WriteLine();
        }
Esempio n. 19
0
        public void EquipWeapon()
        {
            if (this.EquippedWeapon.Name is null)
            {
                if (WeaponsBag.Any())
                {
                    var count = 1;

                    foreach (var w in this.WeaponsBag)
                    {
                        Console.WriteLine($"{count}. {w.Name} of {w.Strength} Strength");
                        count++;
                    }
                    Console.WriteLine($"Which weapon would you like to equip?");

                    var select      = Console.ReadLine();
                    var bagLocation = 0;

                    if (Int32.TryParse(select, out bagLocation))
                    {
                        if (this.WeaponsBag[bagLocation - 1] != null)
                        {
                            this.EquippedWeapon = this.WeaponsBag[bagLocation - 1];
                            this.WeaponsBag.Remove(this.WeaponsBag[bagLocation - 1]);
                            this.Strength += this.EquippedWeapon.Strength;
                        }
                        else
                        {
                            Console.WriteLine($"There is nothing in this part of your bag!");

                            Console.WriteLine("\nPress any key to continue.");
                            Console.ReadKey();

                            Console.ReadKey();
                            this.HeroMenu();
                        }
                    }
                    else
                    {
                        Console.WriteLine($"There was an error!");

                        Console.WriteLine("\nPress any key to continue.");
                        Console.ReadKey();

                        Console.ReadKey();
                        this.HeroMenu();
                    }
                }
                else
                {
                    Console.WriteLine($"\nYou currently have no Weapons in your inventory\nTime to get some gold and go to the store.");

                    Console.WriteLine("\nPress any key to continue.");
                    Console.ReadKey();
                    Console.Clear();
                    this.HeroMenu();
                }
            }
            else
            {
                Console.WriteLine($"\nYou currently have {EquippedWeapon.Name} equipped and will have to remove it to equip a new weapon.");

                Console.WriteLine("\nPress any key to continue.");
                Console.ReadKey();
                Console.Clear();
                this.HeroMenu();
            }
        }
Esempio n. 20
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);
                }
            }
        }