public void DisplayItem(Player player, Location location, bool showBuy = true) { Console.Clear(); Console.WriteLine("\n {0} - {1}", location.PlaceName, Name); Console.WriteLine("------------------------------------------"); Console.WriteLine("\n{0}\n", Description); if (FirstInquire) { Console.WriteLine("\"{0}\"\n", FirstLook); FirstInquire = false; } else { Console.WriteLine("\"{0}\"\n", LookAgain); } if (WillingToSell && showBuy) { Console.WriteLine("The going price is: ${0}\n\n", BuyFor); BuyItem(player, location); } else if (!WillingToSell) { Console.WriteLine("Doesn't look like they are willing to part with this item, better keep looking.\n"); Console.WriteLine("\nPress any key to continue."); Console.ReadKey(); Console.Clear(); } }
public void Visit(Player player, Location location) { location.PlaceIntro(); do { var item = location.SelectItem(player); if (!location.Finished) item.DisplayItem(player, location); } while (!location.Finished); }
public void BuyItem(Player player, Location location) { bool valid; do { Console.WriteLine("${0, 5} - Your Cash", player.PlayerWallet.Cash); Console.WriteLine("${0, 5} - Price", BuyFor); Console.WriteLine("________"); Console.WriteLine("${0, 5} - Your cash if you purchase {1}", player.PlayerWallet.Cash - BuyFor, Name); if (FriendCalled == false) { Console.WriteLine( "\n\nWould you like to purchase this item now? (Y/N) \nOr perhaps you want to phone a friend? (F)\nKeep in mind you can always look at this item again."); } else { Console.WriteLine( "\n\nWould you like to purchase this item now? (Y/N) \nKeep in mind you can always look at this item again."); } var answer = Console.ReadLine(); if (answer.ToUpper() == "Y") { bool canBuy = player.PlayerWallet.RemoveCash(BuyFor); if (canBuy) { valid = true; Console.Clear(); Console.WriteLine("{0}\n", Thanks); player.AddItem(this); location.RemoveItem(this); player.DisplayInventory(); } else { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\nI'm sorry, it looks like you don't have enough money for that purchase."); Console.ResetColor(); return; } } else if (answer.ToUpper() == "N") { valid = true; Console.Clear(); } else if (answer.ToUpper() == "F" && FriendCalled == false) { Console.WriteLine(); var friend = new PhoneAFriend(); string friendAnswer = friend.Call(); valid = false; FriendCalled = true; Console.WriteLine("{0}\n\nAlright, your friend give you some good pointers? \nPress any key to continue.", friendAnswer); Console.ReadKey(); Console.Clear(); DisplayItem(player, location, false); } else { valid = false; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("I'm sorry, that was an invalid input, please enter \"y\" for Yes or \"n\" for No"); Console.ResetColor(); } } while (!valid); }