activeMissionController.py (4857B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\activeMissionController.py 2 import evetypes 3 from carbonui.util.color import Color 4 from eve.client.script.ui.station.agents import agentUtil 5 from eve.common.lib import appConst 6 from localization import GetByLabel, GetByMessageID 7 import blue 8 MISSIONSTATE_ORDER = (appConst.agentMissionStateAccepted, 9 appConst.agentMissionStateAllocated, 10 appConst.agentMissionStateOffered, 11 appConst.agentMissionStateFailed) 12 13 class ActiveMissionController(object): 14 15 def __init__(self, missionState, importantMission, missionType, missionName, agentID, expirationTime, bookmarks, remoteOfferable, remoteCompletable, contentID): 16 self.missionState = missionState 17 self.isImportantMission = importantMission 18 self.missionTypeID = missionType 19 self.missionName = missionName 20 self.agentID = agentID 21 self.expirationTime = expirationTime 22 self.bookmarks = bookmarks 23 self.remoteOfferable = remoteOfferable 24 self.remoteCompletable = remoteCompletable 25 self.contentID = contentID 26 self._disallowedTypeIDs = None 27 self._isSpecialShipRestriction = None 28 self._dungeonData = -1 29 30 def GetExpiryTimeText(self, short = False): 31 return agentUtil.GetMissionExpirationText(self.missionState, self.expirationTime, short=short) 32 33 def GetMissionStateText(self): 34 return agentUtil.GetMissionStateText(self.missionState, self.expirationTime) 35 36 def GetMissionStateTextColored(self): 37 color = Color.RGBtoHex(*self.GetMissionStateColor()) 38 text = agentUtil.GetMissionStateText(self.missionState, self.expirationTime) 39 return "<color='%s'>%s</color>" % (color, text) 40 41 def GetMissionStateColor(self): 42 return agentUtil.GetMissionStateColor(self.missionState, self.expirationTime) 43 44 def GetTimeRemaining(self): 45 return self.expirationTime - blue.os.GetWallclockTime() 46 47 def IsExpired(self): 48 return self.GetTimeRemaining() <= 0 49 50 def GetMissionTypeText(self): 51 return GetByLabel(self.missionTypeID) 52 53 def GetMissionName(self): 54 return GetByMessageID(self.missionName) 55 56 def GetEnemyFactionID(self): 57 missionDetails = self.GetMissionDetails() 58 try: 59 dungeons = missionDetails['objectives']['dungeons'] 60 except KeyError: 61 return None 62 63 for dungeon in dungeons: 64 if 'ownerID' in dungeon: 65 return dungeon['ownerID'] 66 67 def GetMissionDetails(self): 68 return sm.GetService('agents').GetMissionInfo(self.agentID, contentID=self.contentID) 69 70 def GetActiveMissionSortKey(self): 71 try: 72 return MISSIONSTATE_ORDER.index(self.missionState) 73 except ValueError: 74 return len(MISSIONSTATE_ORDER) 75 76 def GetDungeonID(self): 77 self._CheckPrimeDungeonData() 78 if self._dungeonData: 79 return self._dungeonData['dungeonID'] 80 81 def _CheckPrimeDungeonData(self): 82 if self._dungeonData == -1: 83 missionInfo = sm.GetService('agents').GetMissionInfo(self.agentID) 84 dungeons = missionInfo['objectives']['dungeons'] 85 if dungeons: 86 self._dungeonData = dungeons[0] 87 else: 88 self._dungeonData = None 89 90 def GetAllowedShipTypeIDs(self): 91 disallowedTypes = self.GetDisallowedShipTypeIDs() 92 if disallowedTypes: 93 allShipTypes = evetypes.GetTypeIDsByCategory(appConst.categoryShip) 94 return [ typeID for typeID in allShipTypes if typeID not in disallowedTypes and evetypes.IsPublished(typeID) ] 95 96 def GetDisallowedShipTypeIDs(self): 97 if not self._disallowedTypeIDs: 98 self._FetchDisallowedTypeIDs() 99 return self._disallowedTypeIDs 100 101 def _FetchDisallowedTypeIDs(self): 102 dungeonID = self.GetDungeonID() 103 if not dungeonID: 104 return None 105 restrictions = sm.GetService('agents').GetAgentMoniker(self.agentID).GetDungeonShipRestrictions(dungeonID) 106 self._disallowedTypeIDs = restrictions['restrictedShipTypes'] 107 108 def IsShipRestrictionInteresting(self): 109 self._CheckPrimeDungeonData() 110 if self._dungeonData is not None: 111 return self._dungeonData.get('shipRestrictions', 0) == 1 112 113 def IsMissionAccepted(self): 114 return self.missionState == appConst.agentMissionStateAccepted 115 116 def GetDestinationAgentID(self): 117 if self.missionTypeID == appConst.missionTypeEpicArcTalkToAgent and self.IsMissionAccepted(): 118 details = self.GetMissionDetails() 119 try: 120 agentID = details['objectives']['objectives'][0][1][0] 121 return agentID 122 except KeyError as IndexError: 123 pass 124 125 return self.agentID