// 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]; Item armor = new Armor(); armor.ToString(tmpArmor.Name, tmpArmor.Type, tmpArmor.Info, tmpArmor.Defense, tmpArmor.Rarity, tmpArmor.Price); 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 armor? ('y' or 'n')"); string input = Console.ReadLine().ToLower().Trim();; if (input == "n") { return; } if (input != "y") { Prompt($"Oops! Looks like you entered and invalid response. \nPlease select your desired armor piece and try again\n" + $"*Remember*: \nenter 'y' or 'Y' to buy item\nenter 'n' or 'N' to decline\n___________________\n"); return; } if (input == "y") { if (playerBank < tmpArmor.Price) { Prompt($"\nHey! You dont have any enough units left to purchase that!"); Prompt($"\nYou have {playerBank} units and this item is {tmpArmor.Price}\n"); return; } else { armorList.Remove(tmpArmor); myArmors.Add(tmpArmor); playerBank -= tmpArmor.Price; shopBank += tmpArmor.Price; Prompt($"\nYou now own {tmpArmor.Name}!\n" + $"\nYou currently have {playerBank} units left in your bank\n___________________\n"); return; } } }
// 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]; Item armor = new Armor(); // prints values using overriden method armor.ToString(tmpArmor.Name, tmpArmor.Type, tmpArmor.Info, tmpArmor.Defense, tmpArmor.Rarity, tmpArmor.Price); Prompt($"Would you like to sell this item? ('y' or 'n')"); string input = Console.ReadLine().Trim().ToLower(); if (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") { 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; } } }