NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

zone_modifier_util.py (1521B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\jumpbridge\common\zone_modifier_util.py
      2 import eveuniverse
      3 import logging
      4 logger = logging.getLogger('jump_bridge')
      5 ZONE_DISTANCE_INFINITY_SENTINEL = -1
      6 ZONE_ONE = 5
      7 ZONE_TWO = 10
      8 ZONE_THREE = 15
      9 ZONE_FOUR = 20
     10 ZONE_FIVE = ZONE_DISTANCE_INFINITY_SENTINEL
     11 ZONE_DISTANCES = [ZONE_ONE,
     12  ZONE_TWO,
     13  ZONE_THREE,
     14  ZONE_FOUR,
     15  ZONE_FIVE]
     16 
     17 def GetCapacitorZoneModifierAndIdx(capitalSolarSystemID, destinationSolarsystemID, zoneMultipliers):
     18     if capitalSolarSystemID is not None:
     19         lightYears = eveuniverse.solar_systems.GetLightYearDistance(destinationSolarsystemID, capitalSolarSystemID)
     20         zoneIndex = _GetZoneIndexFromLYDistance(lightYears)
     21     else:
     22         zoneIndex = len(ZONE_DISTANCES) - 1
     23         lightYears = None
     24     multiplier = _GetMultiplierFromAttributes(zoneIndex, zoneMultipliers)
     25     logger.info('JumpBridge._GetCapacitorZoneModifier %s, %s, %s', lightYears, zoneIndex, multiplier)
     26     return (multiplier, zoneIndex)
     27 
     28 
     29 def _GetZoneIndexFromLYDistance(lightYears):
     30     for index, distance in enumerate(ZONE_DISTANCES):
     31         if distance == ZONE_DISTANCE_INFINITY_SENTINEL:
     32             return index
     33         if lightYears > distance:
     34             continue
     35         return index
     36 
     37 
     38 def _GetMultiplierFromAttributes(zoneIndex, zoneMultipliers):
     39     if zoneIndex is None or zoneIndex < 0 or zoneIndex >= len(zoneMultipliers):
     40         raise AttributeError('zoneIndex out of range')
     41     return zoneMultipliers[zoneIndex]