diff --git a/Main.cs b/Main.cs index 2755a06..6107bfb 100644 --- a/Main.cs +++ b/Main.cs @@ -10,34 +10,22 @@ class Program List allItems = ItemLoader.LoadAllItems("data/items.json"); Player user = new("Tanner", [], 100, 90, 20, 20); - Console.WriteLine($"{user.Name} has {user.CurrentHealth}/{user.MaxHealth} Hit Points.\n"); - Console.WriteLine($"{user.Name} has {user.CurrentMPoints}/{user.MaxMPoints} Mana Points.\n"); + user.DisplayStats(); user.Inventory.Add(allItems.FirstOrDefault(m => m.Name == "Potion")); user.Inventory.Add(allItems.FirstOrDefault(m => m.Name == "Super Potion")); user.Inventory.Add(allItems.FirstOrDefault(m => m.Name == "Hyper Potion")); user.Inventory.Add(allItems.FirstOrDefault(m => m.Name == "Elixir")); - Console.WriteLine($"{user.Name}'s current inventory:"); - foreach (var inv in user.RetrieveInventory()) - { - Console.WriteLine($"{inv.Key}: {inv.Value}"); - } - Console.WriteLine("Do you want to use your Potion? (Y/N)"); - string input = Console.ReadLine().ToUpper(); - + string? input = Console.ReadLine().ToUpper(); + Console.WriteLine("\n"); + if (input == "Y") { user.UseHealingItem((HealingItem)user.Inventory.FirstOrDefault(m => m.Name == "Potion")); - user.Inventory.Remove(user.Inventory.FirstOrDefault(m => m.Name == "Potion")); } - Console.WriteLine($"{user.Name} has {user.CurrentHealth}/{user.MaxHealth} Hit Points.\n"); - Console.WriteLine($"\n{user.Name}'s current inventory:"); - foreach (var inv in user.RetrieveInventory()) - { - Console.WriteLine($"{inv.Key}: {inv.Value}"); - } + user.DisplayStats(); } } diff --git a/bin/Debug/net8.0/MiniRPG.dll b/bin/Debug/net8.0/MiniRPG.dll index c55e778..e46947a 100644 Binary files a/bin/Debug/net8.0/MiniRPG.dll and b/bin/Debug/net8.0/MiniRPG.dll differ diff --git a/bin/Debug/net8.0/MiniRPG.pdb b/bin/Debug/net8.0/MiniRPG.pdb index 48e07a8..37dca14 100644 Binary files a/bin/Debug/net8.0/MiniRPG.pdb and b/bin/Debug/net8.0/MiniRPG.pdb differ diff --git a/obj/Debug/net8.0/MiniRPG.AssemblyInfo.cs b/obj/Debug/net8.0/MiniRPG.AssemblyInfo.cs index 922788d..c2da1a1 100644 --- a/obj/Debug/net8.0/MiniRPG.AssemblyInfo.cs +++ b/obj/Debug/net8.0/MiniRPG.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("MiniRPG")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+8ceb9a2dd8d39872b5e938a69e814fca0b69edd3")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b44401c8d7d108f0c10a5464d7c3d52644511ce0")] [assembly: System.Reflection.AssemblyProductAttribute("MiniRPG")] [assembly: System.Reflection.AssemblyTitleAttribute("MiniRPG")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/obj/Debug/net8.0/MiniRPG.AssemblyInfoInputs.cache b/obj/Debug/net8.0/MiniRPG.AssemblyInfoInputs.cache index 27de07a..371e73a 100644 --- a/obj/Debug/net8.0/MiniRPG.AssemblyInfoInputs.cache +++ b/obj/Debug/net8.0/MiniRPG.AssemblyInfoInputs.cache @@ -1 +1 @@ -7baa8b6508c62e19ef199636745e63b875d03ba084ae694d983c02c6913ea1bb +c3f2c804e2ee64e4e07e15b987abb29b0956207f6714fc9b00396faa7781a1ea diff --git a/obj/Debug/net8.0/MiniRPG.dll b/obj/Debug/net8.0/MiniRPG.dll index c55e778..e46947a 100644 Binary files a/obj/Debug/net8.0/MiniRPG.dll and b/obj/Debug/net8.0/MiniRPG.dll differ diff --git a/obj/Debug/net8.0/MiniRPG.pdb b/obj/Debug/net8.0/MiniRPG.pdb index 48e07a8..37dca14 100644 Binary files a/obj/Debug/net8.0/MiniRPG.pdb and b/obj/Debug/net8.0/MiniRPG.pdb differ diff --git a/obj/Debug/net8.0/ref/MiniRPG.dll b/obj/Debug/net8.0/ref/MiniRPG.dll index 6ce9eb4..ec845f2 100644 Binary files a/obj/Debug/net8.0/ref/MiniRPG.dll and b/obj/Debug/net8.0/ref/MiniRPG.dll differ diff --git a/obj/Debug/net8.0/refint/MiniRPG.dll b/obj/Debug/net8.0/refint/MiniRPG.dll index 6ce9eb4..ec845f2 100644 Binary files a/obj/Debug/net8.0/refint/MiniRPG.dll and b/obj/Debug/net8.0/refint/MiniRPG.dll differ diff --git a/scripts/Player.cs b/scripts/Player.cs index c1eed88..2b8aa3d 100644 --- a/scripts/Player.cs +++ b/scripts/Player.cs @@ -20,6 +20,11 @@ public class Player //Returns the players inventory in a Dictionary. public Dictionary RetrieveInventory() { + if (Inventory == null || Inventory.Count == 0) + { + Console.WriteLine("Empty"); + return new Dictionary(); + } return Inventory .GroupBy(item => item.Name) .ToDictionary(group => group.Key, group => group.Count()); @@ -34,5 +39,21 @@ public class Player } else { CurrentHealth += item.HealingAmount; } + Inventory.Remove(Inventory.FirstOrDefault(m => m.Name == item.Name)); + Console.WriteLine($"Used one {item.Name}. Regained {item.HealingAmount} Health.\n"); + } + + //#####DEBUG METHODS#####// + + //Display stats about the Player. + public void DisplayStats(){ + Console.WriteLine($"Player Name: {Name}"); + Console.WriteLine($"Health: {CurrentHealth}/{MaxHealth}"); + Console.WriteLine($"Mana: {CurrentMPoints}/{MaxMPoints}\n"); + Console.WriteLine("Current Inventory: "); + foreach (var inv in RetrieveInventory()) + { + Console.WriteLine($"{inv.Key}: {inv.Value}"); + } } } \ No newline at end of file