This won’t get you there…
In fact, my original damagePerSkill.Keys.First would fail because you could start with one magic punch, and then do an equal amount of Melee and Ranged, and these would be the winner…
You’d have to have yet another tracking system
private List<Skill> damageOrder = new List<Skill>();
private void AddDamage(Skill skill, float damage)
{
damageOrder.AddUnique(skill); //This will make a list in order from the first skill used to the last
if (!damagePerSkill.ContainsKey(skill)) damagePerSkill[skill] = damage;
else damagePerSkill[skill] += damage;
}
private Skill GetMostUsedSkill()
{
var pairs = damagePerSkill.OrderByDescending().ToList<>();
if(pairs.Count==1) return pairs.Key;
if(pairs[0]==pairs[1])
{
for(int i=-;i<damageOrder;i++)
if(damageOrder[i] == pairs[0].Key) return pairs[0].Key);
if(damageOrder[i] == pairs[1].Key) return pairs[1].Key);
}
return pairs[0].Key; //It should never get here, but won't compile without it
}