factionsvc.py (5668B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\services\factionsvc.py 2 from carbon.common.script.sys.service import Service 3 from collections import defaultdict 4 import telemetry 5 from characterdata.factions import get_faction_ids 6 from npcs.npccorporations import get_npc_corporation_ids 7 8 class Faction(Service): 9 __exportedcalls__ = {'GetFactionLocations': [], 10 'GetFactionOfSolarSystem': [], 11 'GetPirateFactionsOfRegion': []} 12 __guid__ = 'svc.faction' 13 __notifyevents__ = ['OnSessionChanged'] 14 __servicename__ = 'account' 15 __displayname__ = 'Faction Service' 16 17 def Run(self, memStream = None): 18 self.LogInfo('Starting Faction Svc') 19 self.factionRegions = None 20 self.factionConstellations = None 21 self.factionSolarSystems = None 22 self.factionRaces = None 23 self.solarSystemFactions = None 24 self.currentFactionID = None 25 26 def OnSessionChanged(self, isRemote, session, change): 27 if 'solarsystemid2' in change: 28 self.currentFactionID = (session.solarsystemid2, self.GetFactionOfSolarSystem(session.solarsystemid2)) 29 30 @telemetry.ZONE_FUNCTION 31 def GetCurrentFactionID(self): 32 if self.currentFactionID is None: 33 self.currentFactionID = (session.solarsystemid2, self.GetFactionOfSolarSystem(session.solarsystemid2)) 34 return self.currentFactionID[1] 35 36 @telemetry.ZONE_METHOD 37 def GetFactionOfSolarSystem(self, solarsystemID): 38 if self.solarSystemFactions is None: 39 self.GetData() 40 return self.solarSystemFactions.get(solarsystemID, None) 41 42 def GetFactionsOfConstellation(self, constellationID): 43 if self.factionsByConstellation is None: 44 self.GetData() 45 return self.factionsByConstellation.get(constellationID, []) 46 47 def GetFactionsOfRegion(self, regionID): 48 if self.factionsByRegion is None: 49 self.GetData() 50 return self.factionsByRegion.get(regionID, []) 51 52 def GetPirateFactionsOfRegion(self, regionID): 53 return {10000001: (500019,), 54 10000002: (500010,), 55 10000003: (500010,), 56 10000005: (500011,), 57 10000006: (500011,), 58 10000007: (500011,), 59 10000008: (500011,), 60 10000009: (500011,), 61 10000010: (500010,), 62 10000011: (500011,), 63 10000012: (500011,), 64 10000014: (500019,), 65 10000015: (500010,), 66 10000016: (500010,), 67 10000020: (500019,), 68 10000022: (500019,), 69 10000023: (500010,), 70 10000025: (500011,), 71 10000028: (500011,), 72 10000029: (500010,), 73 10000030: (500011,), 74 10000031: (500011,), 75 10000032: (500020,), 76 10000033: (500010,), 77 10000035: (500010,), 78 10000036: (500019,), 79 10000037: (500020,), 80 10000038: (500012,), 81 10000039: (500019,), 82 10000041: (500020,), 83 10000042: (500011,), 84 10000043: (500019,), 85 10000044: (500020,), 86 10000045: (500010,), 87 10000046: (500020,), 88 10000047: (500019,), 89 10000048: (500020,), 90 10000049: (500012, 500019), 91 10000050: (500012,), 92 10000051: (500020,), 93 10000052: (500012,), 94 10000054: (500012,), 95 10000055: (500010,), 96 10000056: (500011,), 97 10000057: (500020,), 98 10000058: (500020,), 99 10000059: (500019,), 100 10000060: (500012,), 101 10000061: (500011,), 102 10000062: (500011,), 103 10000063: (500012,), 104 10000064: (500020,), 105 10000065: (500012,), 106 10000067: (500012,), 107 10000068: (500020,)}.get(regionID, ()) 108 109 def GetFactionLocations(self, factionID): 110 if self.factionRegions is None: 111 self.GetData() 112 return (self.factionRegions.get(factionID, []), self.factionConstellations.get(factionID, []), self.factionSolarSystems.get(factionID, [])) 113 114 def Stop(self, memStream = None): 115 self.factionRegions = None 116 self.factionConstellations = None 117 self.factionSolarSystems = None 118 self.factionAllies = None 119 self.factionEnemiesNone = None 120 121 @telemetry.ZONE_METHOD 122 def GetData(self): 123 self.factionRegions = defaultdict(list) 124 self.factionConstellations = defaultdict(list) 125 self.factionSolarSystems = defaultdict(list) 126 self.solarSystemFactions = {} 127 self.factionsByConstellation = defaultdict(list) 128 self.factionsByRegion = defaultdict(list) 129 ownersToPrime = set() 130 ownersToPrime.update(get_npc_corporation_ids()) 131 ownersToPrime.update(get_faction_ids()) 132 for regionID, region in cfg.mapRegionCache.iteritems(): 133 if hasattr(region, 'factionID'): 134 self.factionRegions[region.factionID].append(regionID) 135 self.factionsByRegion[regionID].append(region.factionID) 136 137 for constellationID, constellation in cfg.mapConstellationCache.iteritems(): 138 if hasattr(constellation, 'factionID'): 139 self.factionConstellations[constellation.factionID].append(constellationID) 140 self.factionsByConstellation[constellationID].append(constellation.factionID) 141 142 for solarSystemID, solarSystem in cfg.mapSystemCache.iteritems(): 143 if hasattr(solarSystem, 'factionID'): 144 self.factionSolarSystems[solarSystem.factionID].append(solarSystemID) 145 self.solarSystemFactions[solarSystemID] = solarSystem.factionID 146 147 if len(ownersToPrime): 148 cfg.eveowners.Prime(ownersToPrime)