aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS_TheReturn
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-04-03 19:28:35 -0400
committerMichael <[email protected]>2017-04-03 19:28:35 -0400
commit9566b4b062ad0f10832584c65457ef6505b097ab (patch)
tree20a11842ea6e71b26941624af7f50f4ed29cdf19 /ShiftOS_TheReturn
parentf43f6fe17d054f83c686b552201d6b4bfc83524d (diff)
downloadshiftos_thereturn-9566b4b062ad0f10832584c65457ef6505b097ab.tar.gz
shiftos_thereturn-9566b4b062ad0f10832584c65457ef6505b097ab.tar.bz2
shiftos_thereturn-9566b4b062ad0f10832584c65457ef6505b097ab.zip
Categorize the Shiftorium
Diffstat (limited to 'ShiftOS_TheReturn')
-rw-r--r--ShiftOS_TheReturn/Commands.cs57
-rw-r--r--ShiftOS_TheReturn/Shiftorium.cs23
2 files changed, 77 insertions, 3 deletions
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<string, object> args)
{
try
{
+ bool showOnlyInCategory = false;
+
+ string cat = "Other";
+
+ if (args.ContainsKey("cat"))
+ {
+ showOnlyInCategory = true;
+ cat = args["cat"].ToString();
+ }
+
Dictionary<string, int> upgrades = new Dictionary<string, int>();
int maxLength = 5;
- foreach (var upg in Shiftorium.GetAvailable())
+ IEnumerable<ShiftoriumUpgrade> 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)
{
diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs
index 4556cd6..43ea13a 100644
--- a/ShiftOS_TheReturn/Shiftorium.cs
+++ b/ShiftOS_TheReturn/Shiftorium.cs
@@ -41,6 +41,27 @@ namespace ShiftOS.Engine
/// </summary>
public static bool Silent = false;
+ /// <summary>
+ /// Gets all Shiftorium categories.
+ /// </summary>
+ /// <param name="onlyAvailable">Should we look in the "available" upgrade list (i.e, what the user can buy right now), or the full upgrade list?</param>
+ /// <returns>All Shiftorium categories from the list, in a <see cref="System.String[]"/>. </returns>
+ public static string[] GetCategories(bool onlyAvailable = true)
+ {
+ List<string> cats = new List<string>();
+ IEnumerable < ShiftoriumUpgrade > upgrades = GetDefaults();
+ if (onlyAvailable)
+ upgrades = new List<ShiftoriumUpgrade>(GetAvailable());
+
+ foreach(var upg in upgrades)
+ {
+ if (!cats.Contains(upg.Category))
+ cats.Add(upg.Category);
+ }
+
+ return cats.ToArray();
+ }
+
public static void InvokeUpgradeInstalled()
{
Installed?.Invoke();
@@ -289,6 +310,8 @@ namespace ShiftOS.Engine
public string ID { get; private set; }
}
+
+
public class ShiftoriumUpgrade
{
public string Name { get; set; }