Exemplo n.º 1
0
        // method to view a speciic weapon and asks to purchase
        static public void ViewAndBuyWeapon(List <Weapon.WeaponStruct> weaponList, List <Weapon.WeaponStruct> myWeaps, int indexNum)
        {
            Weapon.WeaponStruct tmpWeap = weaponList[indexNum - 1];


            Prompt($"____________________\n- {tmpWeap.Name} -\n" +
                   $"Type: {tmpWeap.Type}\n" +
                   $"Description:\n{tmpWeap.Info}\n" +
                   $"Damage: {tmpWeap.AttackPwr} pts\n" +
                   $"Rarity: {tmpWeap.Rarity}\n" +
                   $"Cost: {tmpWeap.Price} units\n");

            if (playerBank <= 0)
            {
                playerBank = 0;
                Prompt($"Uh oh! You don't have any units left..\nPlease sell something or come back when you have some more units!");
                return;
            }
            Prompt($"Would you like to buy this weapon? ('y' or 'n')");
            string input = Console.ReadLine();

            if (input == "n" || input == "N")
            {
                return;
            }
            if (input != "y")
            {
                Prompt($"Oops! Looks like you entered and invalid response. \nPlease select your desired weapon and try again\n" +
                       $"*Remember*: \nenter 'y' or 'Y' to buy item\nenter 'n' or 'N' to decline\n___________________");
                return;
            }
            if (input == "y" || input == "Y")
            {
                if (playerBank < tmpWeap.Price)
                {
                    Prompt($"Hey! You dont have any enough units left to purchase that!");
                    Prompt($"You have {playerBank} units and this item is {tmpWeap.Price}");
                    return;
                }
                else
                {
                    weaponList.Remove(tmpWeap);
                    myWeaps.Add(tmpWeap);

                    playerBank -= tmpWeap.Price;
                    shopBank   += tmpWeap.Price;


                    Prompt($"You now own {tmpWeap.Name}!\n" +
                           $"You currently have {playerBank} units left in your bank\n________________");
                    return;
                }
            }
        }
Exemplo n.º 2
0
        // method to sell a weapon
        static public void SellWeap(List <Weapon.WeaponStruct> myWeapInv, List <Weapon.WeaponStruct> weaponList, int indexNum)
        {
            Weapon.WeaponStruct tmpWeap = weaponList[indexNum - 1];

            Prompt($"____________________\n- {tmpWeap.Name} -\n" +
                   $"Type: {tmpWeap.Type}\n" +
                   $"Description:\n{tmpWeap.Info}\n" +
                   $"Damage: {tmpWeap.AttackPwr} pts\n" +
                   $"Rarity: {tmpWeap.Rarity}\n" +
                   $"Cost: {tmpWeap.Price} units\n");

            Prompt($"Would you like to sell this item? ('y' or 'n')");
            string input = Console.ReadLine();

            if (input == "n" || input == "N")
            {
                Prompt($"You declined to sell this weapon\n");
                return;
            }
            if (input != "y")
            {
                Prompt($"Oops! Looks like you entered and invalid response. \nPlease try again\n" +
                       $"*Remember*: \nenter 'y' or 'Y' to sell selected item\nenter 'n' or 'N' to decline\n___________________\n");
                return;
            }
            if (input == "y" || input == "Y")
            {
                if (shopBank < tmpWeap.Price)
                {
                    Prompt($"Yikes. I dont have enough units to buy that back.");
                    Prompt($"The item is {tmpWeap.Price} units and I have only have {shopBank} units");
                    Prompt($"Sorry! Maybe if you buy something from me, I will have enough units then");
                    return;
                }
                else
                {
                    myWeapInv.Remove(tmpWeap);
                    weaponList.Add(tmpWeap);

                    playerBank += tmpWeap.Price;
                    shopBank   -= tmpWeap.Price;

                    Prompt($"You sold {tmpWeap.Name} for {tmpWeap.Price} units!\n" +
                           $"You now have {playerBank} units in your bank\n___________________\n");
                    Prompt($"The shop bank is now at {shopBank}");
                }
            }
        }