PRoConEvents.MULTIbalancer.CompareSquads C# (CSharp) Method

CompareSquads() private method

private CompareSquads ( int beforeTeam, int afterTeam, List before, List after, int otherTeam, List otherAfter, bool finalCheck ) : void
beforeTeam int
afterTeam int
before List
after List
otherTeam int
otherAfter List
finalCheck bool
return void
        private void CompareSquads(int beforeTeam, int afterTeam, List<PlayerModel> before, List<PlayerModel> after, int otherTeam, List<PlayerModel> otherAfter,  bool finalCheck)
        {
            Dictionary<int,List<String>> beforeTable = new Dictionary<int,List<String>>();
            Dictionary<int,List<String>> afterTable = new Dictionary<int,List<String>>();
            Dictionary<int,List<String>> otherTable = new Dictionary<int,List<String>>();
            // Load the expected squad assignments into a table indexed by squad
            foreach (PlayerModel b in before) {
            List<String> s = null;
            if (beforeTable.TryGetValue(b.Squad, out s) && s != null) {
            s.Add(b.Name);
            } else {
            s = new List<String>();
            s.Add(b.Name);
            beforeTable[b.Squad] = s;
            }
            }
            // Load actual squad assignments into a table indexed by squad
            foreach (PlayerModel a in after) {
            List<String> s = null;
            if (afterTable.TryGetValue(a.Squad, out s) && s != null) {
            s.Add(a.Name);
            } else {
            s = new List<String>();
            s.Add(a.Name);
            afterTable[a.Squad] = s;
            }
            }
            // Check for cross-team moves
            foreach (PlayerModel o in otherAfter) {
            List<String> s = null;
            if (otherTable.TryGetValue(o.Squad, out s) && s != null) {
            s.Add(o.Name);
            } else {
            s = new List<String>();
            s.Add(o.Name);
            otherTable[o.Squad] = s;
            }
            }

            // Compare
            foreach (int expectedSquad in beforeTable.Keys) {
            try {
            AnalyzeSquadLists(beforeTeam, expectedSquad, beforeTable[expectedSquad], afterTeam, afterTable, otherTeam, otherTable, finalCheck);
            } catch (Exception e) {
            ConsoleException(e);
            }
            }
        }
MULTIbalancer