ghostControllerMixin.py (24890B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\fittingScreen\ghostControllerMixin.py 2 import signals 3 from carbon.common.script.util.timerstuff import AutoTimer 4 from carbonui.control.dragdrop.dragdata import TypeDragData 5 from corruptionsuppression.client.systemEffectsClient import CorruptionWarpSpeedIncreaserCheckerClient 6 from crimewatch.util import GetKillReportHashValue 7 from dogma import const as dogmaConst 8 from eve.client.script.ui.shared.fitting.fittingUtil import GHOST_FITTABLE_CATEGORIES, ModifiedAttribute, GetEffectiveHp, CanFitFromSourceLocation, GetAlignTimeForShip 9 import evetypes 10 from eve.client.script.ui.shared.fittingScreen.tryFit import TryFitter, FAKE_ITEM_GUID, FAKE_ITEM_LOCATION_GUID 11 from eve.common.script.util.eveCommonUtils import GetKillMailInfo 12 from inventorycommon.util import IsSubsystemFlagVisible 13 from shipfitting.droneUtil import GetDroneBandwidth 14 from shipfitting.fittingDogmaLocationUtil import CapacitorSimulator, GetFuelUsage, GetAllDpsInfo, GetAlphaStrike, GetTotalFighterDps, GetFullAndPartialSquadrons 15 EFFECTIVE_HP = 'effectiveHp' 16 ALIGN_TIME = 'alignTime' 17 FUEL_USAGE = 'fuelUsage' 18 ALPHA_STRIKE = 'alphaStrike' 19 CAP_DELTA = 'delta' 20 CAP_DELTA_PERCENTAGE = 'deltaPercentage' 21 LOAD_BALANCE = 'loadBalance' 22 TTL = 'TTL' 23 PASSIVE_RECHARGE = 'passiveRecharge' 24 TOTAL_DPS = 'totalDps' 25 TOTAL_DPS_WITH_RELOAD = 'totalDpsWithReload' 26 FIGHTER_DPS = 'fighterDps' 27 FIGHTER_FULL = 'fighterFullSquadrons' 28 FIGHTER_PARTIAL = 'fighterPartialSquadrons' 29 ACTIVE_DRONES = 'activeDrones' 30 DRONE_BANDWITH_USAGE = 'droneBandwithUsage' 31 DRONE_BANDWITH = 'droneBandwidth' 32 DRONE_DPS = 'droneDps' 33 34 class GhostControllerMixin(object): 35 __notifyevents__ = [] 36 37 def __init__(self, itemID, typeID = None): 38 self.actuallyFittedSubsystemInfo = None 39 self.on_slots_changed = signals.Signal(signalName='on_slots_changed') 40 self.on_simulation_state_changed = signals.Signal(signalName='on_simulation_state_changed') 41 self.on_gauge_preview_changed = signals.Signal(signalName='on_gauge_preview_changed') 42 self.on_drone_bay_open = signals.Signal(signalName='on_drone_bay_open') 43 self.attributesBeforePreviewfitting = {} 44 self.previewItemThread = None 45 self.previewItemPending = None 46 47 def OnFittingSlotsChanged(self, *args): 48 self.on_slots_changed() 49 self._UpdateSlots() 50 51 def OnSubSystemsChanged(self, *args): 52 self.on_subsystem_fitted(animate=False) 53 54 def OnSubSystemsReallyChanged(self): 55 slotsToOffline = [] 56 for eachSlotController in self.slotsByFlagID.itervalues(): 57 if eachSlotController.GetModule() and not eachSlotController.IsOnlineable() and eachSlotController.IsOnline(): 58 slotsToOffline.append(eachSlotController.GetFlagID()) 59 60 if slotsToOffline: 61 sm.GetService('ghostFittingSvc').OfflineSlotList(slotsToOffline) 62 self.on_subsystem_really_changed() 63 64 def OnSimulatedShipLoaded(self, itemID, typeID = None): 65 self.SetDogmaLocation() 66 self.UpdateItem(itemID, typeID) 67 68 def IsSimulated(self): 69 return self.isShipSimulated 70 71 def SetSimulationState(self, simulationOn = False): 72 self.isShipSimulated = simulationOn 73 74 def SetPreviewFittedItem(self, ghostItem = None, force = False): 75 self.previewItemPending = ghostItem 76 if force: 77 if self.previewItemThread: 78 self.previewItemThread.KillTimer() 79 self._SetPreviewFittedItem() 80 elif not self.previewItemThread: 81 self.previewItemThread = AutoTimer(100, self._SetPreviewFittedItem) 82 83 def _SetPreviewFittedItem(self): 84 self.previewItemThread = None 85 ghostItem = self.previewItemPending 86 self.ResetPreviewItemInfo() 87 if ghostItem and evetypes.GetCategoryID(ghostItem.typeID) not in GHOST_FITTABLE_CATEGORIES: 88 return 89 dogmaItem = None 90 previouslyFitted = self.actuallyFittedSubsystemInfo 91 if ghostItem: 92 desiredFlag = int(self.dogmaLocation.dogmaStaticMgr.GetTypeAttribute2(ghostItem.typeID, dogmaConst.attributeSubSystemSlot)) 93 isSubsystemFlag = IsSubsystemFlagVisible(desiredFlag) 94 if isSubsystemFlag: 95 self.TryFitPreviouslyFittedType(previouslyFitted) 96 self.attributesBeforePreviewfitting = self.GetCurrentAttributeValues() 97 if isSubsystemFlag: 98 self.RemoveModuleAndRememberIt(desiredFlag) 99 dogmaItem = self.ghostFittingExtension.PreviewFitItem(ghostItem) 100 else: 101 self.actuallyFittedSubsystemInfo = None 102 self.TryFitPreviouslyFittedType(previouslyFitted) 103 sm.GetService('ghostFittingSvc').SendOnFeedbackTextChanged(None) 104 self.previewFittedItem = dogmaItem 105 self.on_item_ghost_fitted() 106 self.on_stats_changed() 107 108 def RemoveModuleAndRememberIt(self, desiredFlag, *args): 109 dogmaItem = self.dogmaLocation.GetSubSystemInFlag(None, desiredFlag) 110 if dogmaItem: 111 if not getattr(dogmaItem, 'isPreviewItem', False): 112 self.actuallyFittedSubsystemInfo = (desiredFlag, dogmaItem.typeID) 113 self.ghostFittingExtension.UnFitItem(dogmaItem) 114 115 def ResetPreviewItemInfo(self): 116 self.attributesBeforePreviewfitting = {} 117 self.RemovePreviewItem() 118 119 def RemovePreviewItem(self): 120 if self.previewFittedItem: 121 dogmaItem = self.dogmaLocation.SafeGetDogmaItem(self.previewFittedItem.itemID) 122 if dogmaItem and getattr(dogmaItem, 'isPreviewItem', False): 123 self.ghostFittingExtension.UnFitItem(dogmaItem) 124 125 def TryFitPreviouslyFittedType(self, previouslyFitted): 126 if not previouslyFitted: 127 return 128 flagID, moduleTypeID = previouslyFitted 129 dogmaItemInSlot = self.dogmaLocation.GetSubSystemInFlag(None, flagID) 130 if not dogmaItemInSlot or getattr(dogmaItemInSlot, 'isPreviewItem', False): 131 shipID = self.dogmaLocation.GetCurrentShipID() 132 dogmaItem, errorInfo = sm.GetService('ghostFittingSvc').FitModuleToShipAndChangeState(shipID, flagID, moduleTypeID, ignoreSubsystemChange=True) 133 self.actuallyFittedSubsystemInfo = None 134 135 def OnSimulationStateChanged(self): 136 self.on_simulation_state_changed() 137 138 def OnPreviewCPU(self, cpuValue, powergridValue, calibrationValue): 139 self.on_gauge_preview_changed(cpuValue, powergridValue, calibrationValue) 140 141 def OpenFakeDroneBay(self, *args): 142 self.on_drone_bay_open() 143 144 def OpenFakeFighterBay(self, *args): 145 self.on_drone_bay_open() 146 147 def OnDropData(self, dragObj, nodes): 148 if not nodes: 149 return 150 if not CanFitFromSourceLocation(nodes): 151 return 152 recs = [] 153 fakeRecs = [] 154 for node in nodes: 155 guid = getattr(node, '__guid__', None) 156 if getattr(node, 'rec', None): 157 recs.append(node.rec) 158 elif guid in FAKE_ITEM_GUID: 159 fakeRecs.append(node) 160 elif guid in FAKE_ITEM_LOCATION_GUID and getattr(node, 'typeID', None): 161 if evetypes.GetCategoryID(node.typeID) == const.categoryStructure: 162 fakeRecs.append(node) 163 elif isinstance(node, TypeDragData): 164 fakeRecs.append(node) 165 166 if recs or fakeRecs: 167 return TryFitter().TryFit(recs, fakeRecs, self, self.GetItemID()) 168 firstNode = nodes[0] 169 firstNodeGuid = getattr(firstNode, '__guid__', None) 170 if firstNodeGuid == 'listentry.FittingEntry': 171 fitting = firstNode.fitting 172 sm.GetService('ghostFittingSvc').SimulateFitting(fitting) 173 elif firstNodeGuid == 'listentry.KillMail': 174 hashValue = GetKillReportHashValue(node.mail) 175 self._SimulateFittingFromKillReport(node.mail.killID, hashValue) 176 elif firstNodeGuid == 'TextLink': 177 url = node.url 178 if url.startswith('killReport:'): 179 killID, hashValue = url.split(':')[1:] 180 killID = int(killID) 181 self._SimulateFittingFromKillReport(killID, hashValue) 182 elif url.startswith('fitting:'): 183 fittingString = url[len('fitting:'):] 184 fitting, truncated = sm.StartService('fittingSvc').GetFittingFromString(fittingString) 185 self._SimulateFitting(fitting) 186 187 def _SimulateFittingFromKillReport(self, killID, hashValue): 188 kill = sm.RemoteSvc('warStatisticMgr').GetKillMail(killID, hashValue) 189 _, items = GetKillMailInfo(kill) 190 fitting = sm.GetService('fittingSvc').GetFittingFromItems(kill.victimShipTypeID, items) 191 self._SimulateFitting(fitting) 192 193 def _SimulateFitting(self, fitting): 194 from eve.client.script.ui.services.menuSvcExtras.openFunctions import SimulateFitting 195 SimulateFitting(fitting) 196 197 def GetCurrentAttributeValues(self): 198 delta, deltaPercentage, loadBalance, TTL_value = self._GetCapSimulatorValues() 199 activeDroneNumInfo, droneBandwidthUsageInfo, droneDpsInfo = self.GetDroneInfo() 200 fullInfo, partialInfo = self.GetFullAndPartialSquadrons() 201 attributeValueDict = {dogmaConst.attributeScanResolution: self.GetScanResolution().value, 202 dogmaConst.attributeMaxTargetRange: self.GetMaxTargetRange().value, 203 dogmaConst.attributeMaxLockedTargets: self.GetMaxTargets().value, 204 dogmaConst.attributeSignatureRadius: self.GetSignatureRadius().value, 205 dogmaConst.attributeScanRadarStrength: self.GetScanRadarStrength().value, 206 dogmaConst.attributeScanMagnetometricStrength: self.GetScanMagnetometricStrength().value, 207 dogmaConst.attributeScanGravimetricStrength: self.GetScanGravimetricStrength().value, 208 dogmaConst.attributeScanLadarStrength: self.GetScanLadarStrength().value, 209 dogmaConst.attributeMass: self.GetMass().value, 210 dogmaConst.attributeAgility: self.GetAgility().value, 211 dogmaConst.attributeBaseWarpSpeed: self.GetBaseWarpSpeed().value, 212 dogmaConst.attributeWarpSpeedMultiplier: self.GetWarpSpeedMultiplier().value, 213 dogmaConst.attributeMaxVelocity: self.GetMaxVelocity().value, 214 dogmaConst.attributeCpuLoad: self.GetCPULoad().value, 215 dogmaConst.attributeCpuOutput: self.GetCPUOutput().value, 216 dogmaConst.attributePowerLoad: self.GetPowerLoad().value, 217 dogmaConst.attributePowerOutput: self.GetPowerOutput().value, 218 dogmaConst.attributeUpgradeLoad: self.GetCalibrationLoad().value, 219 dogmaConst.attributeUpgradeCapacity: self.GetCalibrationOutput().value, 220 dogmaConst.attributeShieldCapacity: self.GetShieldHp().value, 221 dogmaConst.attributeArmorHP: self.GetArmorHp().value, 222 dogmaConst.attributeHp: self.GetStructureHp().value, 223 dogmaConst.attributeShieldRechargeRate: self.GetRechargeRate().value, 224 dogmaConst.attributeShieldEmDamageResonance: self.GetShieldEmDamageResonance().value, 225 dogmaConst.attributeShieldExplosiveDamageResonance: self.GetShieldExplosiveDamageResonance().value, 226 dogmaConst.attributeShieldKineticDamageResonance: self.GetShieldKineticDamageResonance().value, 227 dogmaConst.attributeShieldThermalDamageResonance: self.GetShieldThermalDamageResonance().value, 228 dogmaConst.attributeArmorEmDamageResonance: self.GetArmorEmDamageResonance().value, 229 dogmaConst.attributeArmorExplosiveDamageResonance: self.GetArmorExplosiveDamageResonance().value, 230 dogmaConst.attributeArmorKineticDamageResonance: self.GetArmorKineticDamageResonance().value, 231 dogmaConst.attributeArmorThermalDamageResonance: self.GetArmorThermalDamageResonance().value, 232 dogmaConst.attributeEmDamageResonance: self.GetStructureEmDamageResonance().value, 233 dogmaConst.attributeExplosiveDamageResonance: self.GetStructureExplosiveDamageResonance().value, 234 dogmaConst.attributeKineticDamageResonance: self.GetStructureKineticDamageResonance().value, 235 dogmaConst.attributeThermalDamageResonance: self.GetStructureThermalDamageResonance().value, 236 dogmaConst.attributeDroneControlDistance: self.GetDroneControlRange().value, 237 dogmaConst.attributeCapacity: self.GetCargoCapacity().value, 238 dogmaConst.attributeDroneCapacity: self.GetDroneCapacity().value, 239 dogmaConst.attributeCapacitorCapacity: self.GetCapacitorCapacity().value, 240 dogmaConst.attributeRechargeRate: self.GetCapRechargeRate().value, 241 CAP_DELTA: delta, 242 CAP_DELTA_PERCENTAGE: deltaPercentage, 243 LOAD_BALANCE: loadBalance, 244 TTL: TTL_value, 245 EFFECTIVE_HP: self.GetEffectiveHp().value, 246 ALIGN_TIME: self.GetAlignTime().value, 247 FUEL_USAGE: self.GetFuelUsage().value, 248 PASSIVE_RECHARGE: self.GetPassiveRechargeRate().value, 249 TOTAL_DPS: self.GetTotalDps().value, 250 TOTAL_DPS_WITH_RELOAD: self.GetTotalDpsWithReload().value, 251 ALPHA_STRIKE: self.GetAlphaStrike().value, 252 ACTIVE_DRONES: activeDroneNumInfo.value, 253 DRONE_BANDWITH: self.GetDroneBandwidth().value, 254 DRONE_BANDWITH_USAGE: droneBandwidthUsageInfo.value, 255 DRONE_DPS: droneDpsInfo.value, 256 FIGHTER_DPS: self.GetFighterDps().value, 257 FIGHTER_FULL: fullInfo.value, 258 FIGHTER_PARTIAL: partialInfo.value} 259 return attributeValueDict 260 261 def GetScanResolution(self): 262 return self.GetStatsInfo(dogmaConst.attributeScanResolution) 263 264 def GetMaxTargetRange(self): 265 return self.GetStatsInfo(dogmaConst.attributeMaxTargetRange) 266 267 def GetMaxTargets(self): 268 return self.GetStatsInfo(dogmaConst.attributeMaxLockedTargets) 269 270 def GetSignatureRadius(self): 271 return self.GetStatsInfo(dogmaConst.attributeSignatureRadius, higherIsBetter=False) 272 273 def GetScanRadarStrength(self): 274 return self.GetStatsInfo(dogmaConst.attributeScanRadarStrength) 275 276 def GetScanMagnetometricStrength(self): 277 return self.GetStatsInfo(dogmaConst.attributeScanMagnetometricStrength) 278 279 def GetScanGravimetricStrength(self): 280 return self.GetStatsInfo(dogmaConst.attributeScanGravimetricStrength) 281 282 def GetScanLadarStrength(self): 283 return self.GetStatsInfo(dogmaConst.attributeScanLadarStrength) 284 285 def GetMass(self): 286 return self.GetStatsInfo(dogmaConst.attributeMass, higherIsBetter=False) 287 288 def GetAgility(self): 289 return self.GetStatsInfo(dogmaConst.attributeAgility, higherIsBetter=False) 290 291 def GetBaseWarpSpeed(self): 292 return self.GetStatsInfo(dogmaConst.attributeBaseWarpSpeed) 293 294 def GetWarpSpeedMultiplier(self): 295 return self.GetStatsInfo(dogmaConst.attributeWarpSpeedMultiplier) 296 297 def GetMaxVelocity(self): 298 return self.GetStatsInfo(dogmaConst.attributeMaxVelocity) 299 300 def GetCPULoad(self): 301 return self.GetStatsInfo(dogmaConst.attributeCpuLoad, higherIsBetter=False) 302 303 def GetCPUOutput(self): 304 return self.GetStatsInfo(dogmaConst.attributeCpuOutput) 305 306 def GetPowerLoad(self): 307 return self.GetStatsInfo(dogmaConst.attributePowerLoad, higherIsBetter=False) 308 309 def GetPowerOutput(self): 310 return self.GetStatsInfo(dogmaConst.attributePowerOutput) 311 312 def GetCalibrationLoad(self): 313 return self.GetStatsInfo(dogmaConst.attributeUpgradeLoad, higherIsBetter=False) 314 315 def GetCalibrationOutput(self): 316 return self.GetStatsInfo(dogmaConst.attributeUpgradeCapacity) 317 318 def GetShieldHp(self): 319 return self.GetStatsInfo(dogmaConst.attributeShieldCapacity) 320 321 def GetArmorHp(self): 322 return self.GetStatsInfo(dogmaConst.attributeArmorHP) 323 324 def GetStructureHp(self): 325 return self.GetStatsInfo(dogmaConst.attributeHp) 326 327 def GetRechargeRate(self): 328 return self.GetStatsInfo(dogmaConst.attributeShieldRechargeRate) 329 330 def GetShieldEmDamageResonance(self): 331 return self.GetStatsInfo(dogmaConst.attributeShieldEmDamageResonance, higherIsBetter=False) 332 333 def GetShieldExplosiveDamageResonance(self): 334 return self.GetStatsInfo(dogmaConst.attributeShieldExplosiveDamageResonance, higherIsBetter=False) 335 336 def GetShieldKineticDamageResonance(self): 337 return self.GetStatsInfo(dogmaConst.attributeShieldKineticDamageResonance, higherIsBetter=False) 338 339 def GetShieldThermalDamageResonance(self): 340 return self.GetStatsInfo(dogmaConst.attributeShieldThermalDamageResonance, higherIsBetter=False) 341 342 def GetArmorEmDamageResonance(self): 343 return self.GetStatsInfo(dogmaConst.attributeArmorEmDamageResonance, higherIsBetter=False) 344 345 def GetArmorExplosiveDamageResonance(self): 346 return self.GetStatsInfo(dogmaConst.attributeArmorExplosiveDamageResonance, higherIsBetter=False) 347 348 def GetArmorKineticDamageResonance(self): 349 return self.GetStatsInfo(dogmaConst.attributeArmorKineticDamageResonance, higherIsBetter=False) 350 351 def GetArmorThermalDamageResonance(self): 352 return self.GetStatsInfo(dogmaConst.attributeArmorThermalDamageResonance, higherIsBetter=False) 353 354 def GetStructureEmDamageResonance(self): 355 return self.GetStatsInfo(dogmaConst.attributeEmDamageResonance, higherIsBetter=False) 356 357 def GetStructureExplosiveDamageResonance(self): 358 return self.GetStatsInfo(dogmaConst.attributeExplosiveDamageResonance, higherIsBetter=False) 359 360 def GetStructureKineticDamageResonance(self): 361 return self.GetStatsInfo(dogmaConst.attributeKineticDamageResonance, higherIsBetter=False) 362 363 def GetStructureThermalDamageResonance(self): 364 return self.GetStatsInfo(dogmaConst.attributeThermalDamageResonance, higherIsBetter=False) 365 366 def GetCargoCapacity(self): 367 return self.GetStatsInfo(dogmaConst.attributeCapacity) 368 369 def GetDroneCapacity(self): 370 return self.GetStatsInfo(dogmaConst.attributeDroneCapacity) 371 372 def GetCapacitorCapacity(self): 373 return self.GetStatsInfo(dogmaConst.attributeCapacitorCapacity) 374 375 def GetCapRechargeRate(self): 376 return self.GetStatsInfo(dogmaConst.attributeRechargeRate, higherIsBetter=False) 377 378 def GetFighterCapacity(self): 379 return self.GetStatsInfo(dogmaConst.attributeFighterCapacity) 380 381 def GetStatsInfo(self, attributeID, higherIsBetter = True): 382 oldValue = self.attributesBeforePreviewfitting.get(attributeID, None) 383 currentValue = self.GetAttribute(attributeID) 384 currentValue = round(currentValue, 10) 385 return ModifiedAttribute(value=currentValue, oldValue=oldValue, higherIsBetter=higherIsBetter, attributeID=attributeID) 386 387 def GetEffectiveHp(self): 388 oldValue = self.attributesBeforePreviewfitting.get(EFFECTIVE_HP, None) 389 currentValue = GetEffectiveHp(self) 390 return ModifiedAttribute(value=currentValue, oldValue=oldValue) 391 392 def GetAlignTime(self): 393 oldValue = self.attributesBeforePreviewfitting.get(ALIGN_TIME, None) 394 currentValue = GetAlignTimeForShip(self.dogmaLocation) 395 return ModifiedAttribute(value=currentValue, oldValue=oldValue, higherIsBetter=False) 396 397 def GetFuelUsage(self): 398 oldValue = self.attributesBeforePreviewfitting.get(FUEL_USAGE, None) 399 currentValue = GetFuelUsage(self.dogmaLocation) 400 return ModifiedAttribute(value=currentValue, oldValue=oldValue, higherIsBetter=False) 401 402 def GetPassiveRechargeRate(self): 403 oldValue = self.attributesBeforePreviewfitting.get(PASSIVE_RECHARGE, None) 404 shieldCapacity = self.GetAttribute(dogmaConst.attributeShieldCapacity) 405 shieldRR = self.GetAttribute(dogmaConst.attributeShieldRechargeRate) 406 hpPerSec = int(2.5 * shieldCapacity / (shieldRR / 1000.0)) 407 return ModifiedAttribute(value=hpPerSec, oldValue=oldValue) 408 409 def _GetCapSimulatorValues(self): 410 dogmaLocation = self.dogmaLocation 411 peakRechargeRate, totalCapNeed, loadBalance, TTL_value = CapacitorSimulator(dogmaLocation, dogmaLocation.GetCurrentShipID()) 412 delta = round((peakRechargeRate - totalCapNeed) * 1000, 2) 413 deltaPercentage = round((peakRechargeRate - totalCapNeed) / peakRechargeRate * 100, 1) 414 return (delta, 415 deltaPercentage, 416 loadBalance, 417 TTL_value) 418 419 def GetCapSimulatorInfos(self): 420 delta, deltaPercentage, loadBalance, TTL_value = self._GetCapSimulatorValues() 421 oldValue = self.attributesBeforePreviewfitting.get(CAP_DELTA, None) 422 deltaInfo = ModifiedAttribute(value=delta, oldValue=oldValue) 423 oldValue = self.attributesBeforePreviewfitting.get(CAP_DELTA_PERCENTAGE, None) 424 deltaPercentageInfo = ModifiedAttribute(value=deltaPercentage, oldValue=oldValue) 425 oldValue = self.attributesBeforePreviewfitting.get(LOAD_BALANCE, None) 426 loadBalanceInfo = ModifiedAttribute(value=loadBalance, oldValue=oldValue) 427 oldValue = self.attributesBeforePreviewfitting.get(TTL, None) 428 ttlInfo = ModifiedAttribute(value=TTL_value or 0, oldValue=oldValue) 429 return [deltaInfo, 430 deltaPercentageInfo, 431 loadBalanceInfo, 432 ttlInfo] 433 434 def GetTotalDps(self): 435 oldValue = self.attributesBeforePreviewfitting.get(TOTAL_DPS, None) 436 allDpsInfo = self._GetAllDpsInfo() 437 totalDps = allDpsInfo.totalDps 438 return ModifiedAttribute(value=totalDps, oldValue=oldValue) 439 440 def GetTotalDpsWithReload(self): 441 oldValue = self.attributesBeforePreviewfitting.get(TOTAL_DPS_WITH_RELOAD, None) 442 allDpsInfo = self._GetAllDpsInfo() 443 totalDpsWithReload = allDpsInfo.totalDpsWithReload 444 return ModifiedAttribute(value=totalDpsWithReload, oldValue=oldValue) 445 446 def _GetAllDpsInfo(self): 447 dogmaLocation = self.dogmaLocation 448 shipID = dogmaLocation.GetCurrentShipID() 449 allDpsInfo = GetAllDpsInfo(shipID, dogmaLocation) 450 return allDpsInfo 451 452 def GetAlphaStrike(self): 453 oldValue = self.attributesBeforePreviewfitting.get(ALPHA_STRIKE, None) 454 alphaStrike = GetAlphaStrike(self.dogmaLocation) 455 return ModifiedAttribute(value=alphaStrike, oldValue=oldValue) 456 457 def GetDroneInfo(self): 458 activeDrones = self.dogmaLocation.GetActiveDrones() 459 activeDroneNumInfo = self._GetActiveDronesNum(activeDrones) 460 droneBandwidthUsageInfo = self._GetDroneBandWidthUsage(activeDrones) 461 droneDpsInfo = self._GetDroneDps(activeDrones) 462 return (activeDroneNumInfo, droneBandwidthUsageInfo, droneDpsInfo) 463 464 def _GetActiveDronesNum(self, activeDrones): 465 oldValue = self.attributesBeforePreviewfitting.get(ACTIVE_DRONES, None) 466 numActiveDrones = sum((qty for qty in activeDrones.itervalues())) 467 return ModifiedAttribute(value=numActiveDrones, oldValue=oldValue) 468 469 def _GetDroneBandWidthUsage(self, activeDrones): 470 oldValue = self.attributesBeforePreviewfitting.get(DRONE_BANDWITH_USAGE, None) 471 shipID = self.dogmaLocation.GetCurrentShipID() 472 bandwidthUsed, _ = GetDroneBandwidth(shipID, self.dogmaLocation, activeDrones) 473 return ModifiedAttribute(value=bandwidthUsed, oldValue=oldValue, higherIsBetter=False) 474 475 def _GetDroneDps(self, activeDrones): 476 oldValue = self.attributesBeforePreviewfitting.get(DRONE_DPS, None) 477 shipID = self.dogmaLocation.GetCurrentShipID() 478 droneDps, _ = self.dogmaLocation.GetOptimalDroneDamage2(shipID, activeDrones) 479 return ModifiedAttribute(value=droneDps, oldValue=oldValue) 480 481 def GetDroneBandwidth(self): 482 return self.GetStatsInfo(dogmaConst.attributeDroneBandwidth) 483 484 def GetDroneControlRange(self): 485 attributeID = const.attributeDroneControlDistance 486 oldValue = self.attributesBeforePreviewfitting.get(attributeID, None) 487 currentValue = self.dogmaLocation.GetAttributeValue(session.charid, attributeID) 488 return ModifiedAttribute(value=currentValue, oldValue=oldValue, attributeID=attributeID) 489 490 def GetFighterDps(self): 491 totalFighterDps = GetTotalFighterDps(self.dogmaLocation) 492 oldValue = self.attributesBeforePreviewfitting.get(FIGHTER_DPS, None) 493 return ModifiedAttribute(value=totalFighterDps, oldValue=oldValue) 494 495 def GetFullAndPartialSquadrons(self): 496 full, partial = GetFullAndPartialSquadrons(self.dogmaLocation) 497 oldValueFull = self.attributesBeforePreviewfitting.get(FIGHTER_FULL, None) 498 oldValuePartial = self.attributesBeforePreviewfitting.get(FIGHTER_PARTIAL, None) 499 return (ModifiedAttribute(value=full, oldValue=oldValueFull), ModifiedAttribute(value=partial, oldValue=oldValuePartial)) 500 501 def GetCorruptionWarpSpeedIncrease(self): 502 corruptionWarpSpeedChecker = CorruptionWarpSpeedIncreaserCheckerClient(session.solarsystemid2) 503 corruptionWarpSpeedIncrease = corruptionWarpSpeedChecker.GetWarpSpeedIncrease(session.warfactionid) 504 return corruptionWarpSpeedIncrease