private int CountMatchingFriends(PlayerModel player, Scope scope)
{
if (player == null) return 0;
if (player.Friendex == -1) return 0;
if (player.Team == 0 || player.Squad == 0) return 0;
int team = player.Team;
int squad = player.Squad;
List<PlayerModel> teamList = GetTeam(team);
if (teamList == null) return 0;
int same = 0;
foreach (PlayerModel mate in teamList) {
if (scope == Scope.SameSquad && mate.Squad != squad) continue;
if (mate.Friendex == player.Friendex) ++same;
}
String sname = GetSquadName(squad) + " squad";
String where = sname;
if (scope == Scope.SameTeam) {
where = GetTeamName(team) + " team";
}
if (DebugLevel >= 6 && same > 1) DebugBalance("Count of matching friends for player ^b" + player.Name + "^n in " + where + ", found " + same + " matching friends (friendex = " + player.Friendex + ")");
return same;
}