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

shipStatistics.py (2963B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\login\charcreation\empireTechnologyViews\shipStatistics.py
      2 from localization import GetByLabel
      3 
      4 class ShipStatistic(object):
      5 
      6     def __init__(self, label = None, attributeID = None):
      7         self.label = label
      8         self.attributeID = attributeID
      9 
     10     def GetString(self, typeID):
     11         if self.label and self.attributeID:
     12             value = self.GetValue(typeID)
     13             if value:
     14                 return GetByLabel(self.label, value=value)
     15         return ''
     16 
     17     def GetValue(self, typeID):
     18         return sm.GetService('godma').GetTypeAttribute(typeID=typeID, attributeID=self.attributeID)
     19 
     20 
     21 class ShipMassStatistic(ShipStatistic):
     22 
     23     def __init__(self, label = None, labelTonnes = None, attributeID = None):
     24         self.labelTonnes = labelTonnes
     25         ShipStatistic.__init__(self, label, attributeID)
     26 
     27     def GetString(self, typeID):
     28         if self.label and self.attributeID:
     29             value = self.GetValue(typeID)
     30             if value:
     31                 if value > 10000.0:
     32                     value = value / 1000.0
     33                     return GetByLabel(self.labelTonnes, value=value)
     34                 return GetByLabel(self.label, value=value)
     35         return ''
     36 
     37 
     38 SHIELD_LABEL = 'UI/ShipStatistics/ShieldStatistic'
     39 ARMOR_LABEL = 'UI/ShipStatistics/ArmorStatistic'
     40 STRUCTURE_LABEL = 'UI/ShipStatistics/StructureStatistic'
     41 MASS_KG_LABEL = 'UI/ShipStatistics/MassStatisticKg'
     42 MASS_TONNES_LABEL = 'UI/ShipStatistics/MassStatisticTonnes'
     43 MAX_VELOCITY_LABEL = 'UI/ShipStatistics/MaxVelocityStatistic'
     44 WARP_SPEED_LABEL = 'UI/ShipStatistics/WarpSpeedStatistic'
     45 MAX_TARGET_RG_LABEL = 'UI/ShipStatistics/MaxTargetRangeStatistic'
     46 MAX_LOCKED_TARGETS_LABEL = 'UI/ShipStatistics/MaxLockedTargetsStatistic'
     47 SHIELD = ShipStatistic(label=SHIELD_LABEL, attributeID=const.attributeShieldCapacity)
     48 ARMOR = ShipStatistic(label=ARMOR_LABEL, attributeID=const.attributeArmorHP)
     49 STRUCTURE = ShipStatistic(label=STRUCTURE_LABEL, attributeID=const.attributeHp)
     50 MASS = ShipMassStatistic(label=MASS_KG_LABEL, labelTonnes=MASS_TONNES_LABEL, attributeID=const.attributeMass)
     51 MAX_VELOCITY = ShipStatistic(label=MAX_VELOCITY_LABEL, attributeID=const.attributeMaxVelocity)
     52 WARP_SPEED = ShipStatistic(label=WARP_SPEED_LABEL, attributeID=const.attributeBaseWarpSpeed)
     53 MAX_TARGET_RG = ShipStatistic(label=MAX_TARGET_RG_LABEL, attributeID=const.attributeMaxTargetRange)
     54 MAX_LOCKED_TARGETS = ShipStatistic(label=MAX_LOCKED_TARGETS_LABEL, attributeID=const.attributeMaxLockedTargets)
     55 SHIP_STATISTICS = [SHIELD,
     56  ARMOR,
     57  STRUCTURE,
     58  MASS,
     59  MAX_VELOCITY,
     60  WARP_SPEED,
     61  MAX_TARGET_RG,
     62  MAX_LOCKED_TARGETS]
     63 
     64 def GetStatistics(typeID):
     65     statistics = ''
     66     for shipStat in SHIP_STATISTICS:
     67         shipStatString = shipStat.GetString(typeID).upper()
     68         if statistics and shipStatString:
     69             statistics += '\n'
     70         statistics += shipStatString
     71 
     72     return statistics