예제 #1
0
        // method to view a speciic armor and asks to purchase
        static public void ViewAndBuyArmor(List <Armor.ArmorStruct> armorList, List <Armor.ArmorStruct> myArmors, int indexNum)
        {
            Armor.ArmorStruct tmpArmor = armorList[indexNum - 1];
            Prompt($"____________________\n- {tmpArmor.Name} -\n" +
                   $"Type: {tmpArmor.Type}\n" +
                   $"Description:\n{tmpArmor.Info}\n" +
                   $"Defense: {tmpArmor.Defense} pts\n" +
                   $"Rarity: {tmpArmor.Rarity}\n" +
                   $"Cost: {tmpArmor.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 for protection? ('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 method of defense and try again\n" +
                       $"*Remember*: \nenter 'y' or 'Y' to buy item\nenter 'n' or 'N' to decline\n___________________\n");
                return;
            }
            if (input == "y" || input == "Y")
            {
                if (playerBank < tmpArmor.Price)
                {
                    Prompt($"Hey! You dont have any enough units left to purchase that!");
                    Prompt($"You have {playerBank} units and this item is {tmpArmor.Price}");
                    return;
                }
                else
                {
                    armorList.Remove(tmpArmor);
                    myArmors.Add(tmpArmor);

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


                    Prompt($"You now own {tmpArmor.Name}!\n" +
                           $"You currently have {playerBank} units left in your bank\n___________________\n");
                    return;
                }
            }
        }
예제 #2
0
        // method to sell a specific armor
        static public void SellArmor(List <Armor.ArmorStruct> myArmorInv, List <Armor.ArmorStruct> armorList, int indexNum)
        {
            Armor.ArmorStruct tmpArmor = myArmorInv[indexNum - 1];

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

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

            if (input == "n" || input == "N")
            {
                Prompt($"You declined to sell this armor\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 < tmpArmor.Price)
                {
                    Prompt($"Yikes. I dont have enough units to buy that back.");
                    Prompt($"The item is {tmpArmor.Price} units and I have only have {shopBank} ");
                    return;
                }
                else
                {
                    myArmorInv.Remove(tmpArmor);
                    armorList.Add(tmpArmor);

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

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