public static KnownAlliances createAllianceContactsOld(Core.User player) { KnownAlliances allianceDiplomacy = new KnownAlliances(); allianceDiplomacy.allianceDetail = new List <AllianceDetail>(); HashSet <int> knownAlliances = new HashSet <int>(); //first add player alliance if (player.allianceId > 0) { knownAlliances.Add(player.allianceId); } //get all contacts, get their allianecIds: var targetRelations = Core.Core.Instance.userRelations.getDiplomatics(player, 1); foreach (var targetRelation in targetRelations) { var targetUser = (Core.User)targetRelation.target; if (targetUser.allianceId != 0) { knownAlliances.Add(targetUser.allianceId); } } //create an entry for each allianceId foreach (var allianceId in knownAlliances) { if (!Core.Core.Instance.alliances.ContainsKey(allianceId)) { continue; } var alliance = Core.Core.Instance.alliances[allianceId]; allianceDiplomacy.allianceDetail.Add( new AllianceDetail(alliance.id, alliance.NAME, alliance.allianceowner ?? 0, alliance.overallVicPoints, alliance.overallRank) ); } return(allianceDiplomacy); }
public static KnownAlliances createAllianceContacts(Core.User player) { KnownAlliances allianceDiplomacy = new KnownAlliances(); allianceDiplomacy.allianceDetail = new List <AllianceDetail>(); //create an entry for each allianceId foreach (var alliance in Core.Core.Instance.alliances.Values) { allianceDiplomacy.allianceDetail.Add( new AllianceDetail(alliance.id, alliance.NAME, alliance.allianceowner ?? 0, alliance.overallVicPoints, alliance.overallRank) ); } return(allianceDiplomacy); }