The error tells you EXACTLY what the problem is (and running in the debugger or reading the stack trace will tell you exactly where the problem is):
C# Collection was modified; enumeration operation may not execute.
Your problem is the loop
foreach (KeyValuePair<int, int> kvp in rankings) {
//
}
wherein you modify the collection rankings
. In particular, the offensive line is
rankings[kvp.Key] = rankings[kvp.Key] + 4;
Before you enter the loop, add the following line:
var listOfRankingsToModify = new List<int>();
Replace the offending line with
listOfRankingsToModify.Add(kvp.Key);
and after you exit the loop
foreach(var key in listOfRankingsToModify) {
rankings[key] = rankings[key] + 4;
}
That is, record what changes you need to make, and make them without iterating over the collection that you need to modify.