From 9566b4b062ad0f10832584c65457ef6505b097ab Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 3 Apr 2017 19:28:35 -0400 Subject: Categorize the Shiftorium --- ShiftOS_TheReturn/Commands.cs | 57 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) (limited to 'ShiftOS_TheReturn/Commands.cs') diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 73a7e2d..9f85a25 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -535,7 +535,7 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed, { Console.WriteLine($@"Information for {upgrade}: -{upg.Name} - {upg.Cost} Codepoints +{upg.Category}: {upg.Name} - {upg.Cost} Codepoints ------------------------------------------------------ {upg.Description} @@ -553,15 +553,66 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); return false; } } + + [Command("categories")] + public static bool ListCategories() + { + foreach(var cat in Shiftorium.GetCategories()) + { + Console.WriteLine($"{cat} - {Shiftorium.GetAvailable().Where(x=>x.Category==cat).Count()} upgrades"); + } + return true; + } + [Command("list")] - public static bool ListAll() + public static bool ListAll(Dictionary args) { try { + bool showOnlyInCategory = false; + + string cat = "Other"; + + if (args.ContainsKey("cat")) + { + showOnlyInCategory = true; + cat = args["cat"].ToString(); + } + Dictionary upgrades = new Dictionary(); int maxLength = 5; - foreach (var upg in Shiftorium.GetAvailable()) + IEnumerable upglist = Shiftorium.GetAvailable(); + if (showOnlyInCategory) + { + if (Shiftorium.IsCategoryEmptied(cat)) + { + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("Shiftorium Query Error"); + Console.WriteLine(); + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = ConsoleColor.Gray; + Console.WriteLine("Either there are no upgrades in the category \"" + cat + "\" or the category was not found."); + return true; + } + upglist = Shiftorium.GetAvailable().Where(x => x.Category == cat); + } + + + if(upglist.Count() == 0) + { + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("No upgrades available!"); + Console.WriteLine(); + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = ConsoleColor.Gray; + Console.WriteLine("You have installed all available upgrades for your system. Please check back later for more."); + return true; + + } + foreach (var upg in upglist) { if (upg.ID.Length > maxLength) { -- cgit v1.2.3