warPermit.py (2015B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\services\wars\warPermit.py 2 from carbon.common.script.sys.service import Service 3 from eve.common.script.sys.idCheckers import IsAlliance 4 5 class WarPermit(Service): 6 __guid__ = 'svc.warPermit' 7 __servicename__ = 'warPermit' 8 __displayname__ = 'War Permit Service' 9 __notifyevents__ = ['OnAllowWarUpdated'] 10 11 def __init__(self, *args): 12 Service.__init__(self) 13 self.myCorpAllowsWar = None 14 15 def CanDeclareWarAgainst(self, otherID = None): 16 if self.GetMyCorpsWarPermitStatus(): 17 if otherID is None: 18 return True 19 if IsAlliance(otherID): 20 otherID = sm.RemoteSvc('allianceRegistry').GetAlliancePublicInfo(otherID).executorCorpID 21 return self.GetWarPermitStatusForCorp(otherID) 22 return False 23 24 def DoesMyCorpHaveNegativeWarPermit(self): 25 return self.GetMyCorpsWarPermitStatus() == False 26 27 def GetMyCorpsWarPermitStatus(self): 28 if self.myCorpAllowsWar is None: 29 corpInfo = sm.GetService('corp').GetCorporation(session.corpid) 30 self.myCorpAllowsWar = corpInfo.allowWar 31 return self.myCorpAllowsWar 32 33 def GetWarPermitStatusForCorp(self, corpID): 34 if corpID == session.corpid: 35 return self.GetMyCorpsWarPermitStatus() 36 corpInfo = sm.RemoteSvc('corpmgr').GetPublicInfo(corpID) 37 return corpInfo.allowWar 38 39 def OnAllowWarUpdated(self, corpID, allowWar): 40 if corpID != session.corpid: 41 raise RuntimeError("Getting updates about a corp I don't belong to") 42 self.myCorpAllowsWar = allowWar 43 self.ResetCaches() 44 45 def OnSessionChanged(self, isRemote, session, change): 46 if 'corpid' in change or 'allianceid' in change: 47 self.myCorpAllowsWar = None 48 49 def ResetCaches(self): 50 sm.GetService('corp').ResetCacheForMyCorp() 51 sm.GetService('alliance').ResetCacheForMyAlliance()