public class Player : Character { public List Inventory { get; set; } public List Moves { get; set; } public Player(string name, int maxhealth, int currenthealth, int maxmpoints, int currentmpoints, List inventory, List moves) : base(name, maxhealth, currenthealth, maxmpoints, currentmpoints) { Inventory = inventory; Moves = moves; } //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 (Inventory.FirstOrDefault(m => m.Name == item?.Name) != null){ Inventory.Remove(Inventory.FirstOrDefault(m => m.Name == item.Name)); if ((CurrentHealth + item.HealingAmount) > MaxHealth) { CurrentHealth = MaxHealth; } else { CurrentHealth += item.HealingAmount; } Console.WriteLine($"Used one {item.Name}. Regained {item.HealingAmount} Health.\n"); } else { Console.WriteLine($"{Name} does not have any of that in their inventory."); } } //#####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}"); } } }