PRoConEvents.MULTIbalancer.CountMatchingTags C# (CSharp) Method

CountMatchingTags() private method

private CountMatchingTags ( PlayerModel player, Scope scope ) : int
player PlayerModel
scope Scope
return int
        private int CountMatchingTags(PlayerModel player, Scope scope)
        {
            if (player == null) return 0;
            if (player.Team == 0 || player.Squad == 0) return 0;
            int team = player.Team;
            int squad = player.Squad;

            if (scope == Scope.TeamOne) { team =  1; }
            else if (scope == Scope.TeamTwo) { team = 2; }
            else if (scope == Scope.TeamThree) { team = 3; }
            else if (scope == Scope.TeamFour) { team = 4; }

            List<PlayerModel> teamList = GetTeam(team);
            if (teamList == null) return 0;

            String tag = ExtractTag(player);
            if (String.IsNullOrEmpty(tag)) return 0;
            int same = 0;
            int verified = 0;
            int total = 0;

            foreach (PlayerModel mate in teamList) {
            if (scope == Scope.SameSquad && mate.Squad != squad) continue;
            ++total;
            if (mate.TagVerified) ++verified;
            if (fTestClanDispersal) {
            // Treat tags of same length as equal
            if (ExtractTag(mate).Length == tag.Length) {
                ++same;
                continue;
            }
            }
            if (ExtractTag(mate) == tag) ++same;
            }

            String sname = GetSquadName(squad);

            String loc = sname;
            if (scope == Scope.SameTeam || (scope >= Scope.TeamOne && scope <= Scope.TeamFour)) loc = GetTeamName(team);
            else if (scope == Scope.Total) loc = "server";

            if (verified < 2) {
            if (DebugLevel >= 7) DebugBalance("Count for matching tags for player ^b" + player.Name + "^n in " + loc + ", not enough verified tags to find matches");
            return 0;
            } else {
            if (DebugLevel >= 7 && same > 1) DebugBalance("Count for matching tags for player ^b" + player.Name + "^n in " + loc + ", found " + same + " matching tags [" + tag + "]");
            }
            return same;
        }
MULTIbalancer