public class Player { public string Name { get; set; } public List Inventory { get; set; } public int MaxHealth { get; set; } public int CurrentHealth { get; set; } public int MaxMPoints { get; set; } public int CurrentMPoints { get; set; } public Player(string name, List inventory, int maxhealth, int currenthealth, int maxmpoints, int currentmpoints) { Name = name; Inventory = inventory; MaxHealth = maxhealth; CurrentHealth = currenthealth; MaxMPoints = maxmpoints; CurrentMPoints = currentmpoints; } //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()); } //For using a healing item. Doesn't allow you to overheal. public void UseHealingItem(HealingItem item) { if ((CurrentHealth + item.HealingAmount) > MaxHealth) { CurrentHealth = MaxHealth; } 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}"); } } }