loyaltyPointsWalletSvc.py (3869B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\wallet\loyaltyPointsWalletSvc.py 2 import logging 3 from appConst import corpHeraldry 4 from carbon.common.script.sys.service import Service 5 from inventorycommon.const import ownerCONCORD 6 logger = logging.getLogger(__name__) 7 8 class LoyaltyPointsWalletSvc(Service): 9 __guid__ = 'svc.loyaltyPointsWallet' 10 __servicename__ = 'loyaltyPointsWallet' 11 __displayname__ = 'Loyalty Points Wallet' 12 __dependencies__ = [] 13 __notifyevents__ = ['OnSessionChanged', 14 'ProcessSessionReset', 15 'OnLPChange', 16 'OnCorpLPChange'] 17 _characterLPBalanceByIssuerCorpID = None 18 _corpLPBalanceByIssuerCorpID = None 19 20 @staticmethod 21 def _GetRemoteLPService(): 22 return sm.RemoteSvc('LPSvc') 23 24 def _LoadCharacterLPData(self): 25 if self._characterLPBalanceByIssuerCorpID is None: 26 loyaltyPoints = self._GetRemoteLPService().GetAllMyCharacterWalletLPBalances() 27 self._characterLPBalanceByIssuerCorpID = {row[0]:row[1] for row in loyaltyPoints} 28 return self._characterLPBalanceByIssuerCorpID 29 30 def _LoadCorporationLPData(self): 31 if self._corpLPBalanceByIssuerCorpID is None: 32 loyaltyPoints = self._GetRemoteLPService().GetAllMyCorporationWalletLPBalances() 33 self._corpLPBalanceByIssuerCorpID = {row[0]:row[1] for row in loyaltyPoints} 34 return self._corpLPBalanceByIssuerCorpID 35 36 def _FlushAllCharacterLPData(self): 37 self._characterLPBalanceByIssuerCorpID = None 38 39 def _FlushAllCorporationLPData(self): 40 self._corpLPBalanceByIssuerCorpID = None 41 42 def ProcessSessionReset(self): 43 self._FlushAllCharacterLPData() 44 self._FlushAllCorporationLPData() 45 46 def OnSessionChanged(self, isremote, sess, change): 47 if 'corpid' in change or 'corprole' in change: 48 self._FlushAllCorporationLPData() 49 50 def OnLPChange(self, _changeType, issuerCorpID, lpBefore, lpAfter): 51 self._FlushAllCharacterLPData() 52 sm.ScatterEvent('OnCharacterLPBalanceChange_Local', issuerCorpID, lpBefore, lpAfter) 53 54 def OnCorpLPChange(self, reason, issuerCorpID): 55 self._FlushAllCorporationLPData() 56 sm.ScatterEvent('OnCorporationLPBalanceChange_Local', issuerCorpID) 57 58 def GetCharacterWalletLPBalance(self, issuerCorpID): 59 characterLPByCorpID = self._LoadCharacterLPData() 60 return characterLPByCorpID.get(issuerCorpID, 0) 61 62 def GetCharacterEvermarkBalance(self): 63 return self.GetCharacterWalletLPBalance(corpHeraldry) 64 65 def GetCharacterConcordLPBalance(self): 66 return self.GetCharacterWalletLPBalance(ownerCONCORD) 67 68 def GetAllCharacterLPBalancesExcludingEvermarks(self): 69 characterLPByCorpID = self._LoadCharacterLPData() 70 return [ (issuerCorpID, amount) for issuerCorpID, amount in characterLPByCorpID.iteritems() if issuerCorpID != corpHeraldry ] 71 72 def GetCorporationWalletLPBalance(self, issuerCorpID): 73 corpLPByCorpID = self._LoadCorporationLPData() 74 return corpLPByCorpID.get(issuerCorpID, 0) 75 76 def GetCorporationEvermarkBalance(self): 77 return self.GetCorporationWalletLPBalance(corpHeraldry) 78 79 def GetAllCorporationLPBalancesExcludingEvermarks(self): 80 corpLPByIssuerCorpID = self._LoadCorporationLPData() 81 return [ (issuerCorpID, amount) for issuerCorpID, amount in corpLPByIssuerCorpID.iteritems() if issuerCorpID != corpHeraldry ] 82 83 def TransferLPFromCorpToCorp(self, receiverCorpID, issuerCorpID, lpAmount): 84 self._GetRemoteLPService().TransferLPFromMyCorpWalletToOtherCorp(receiverCorpID, issuerCorpID, lpAmount) 85 86 def TransferLPFromPlayerToCorp(self, receiverCorpID, issuerCorpID, lpAmount): 87 self._GetRemoteLPService().TransferLPFromMyWalletToOtherCorp(receiverCorpID, issuerCorpID, lpAmount)