MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / Fighter

Class Fighter

eos/saveddata/fighter.py:40–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38
39
40class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
41 DAMAGE_TYPES = ("em", "kinetic", "explosive", "thermal")
42 DAMAGE_TYPES2 = ("EM", "Kin", "Exp", "Therm")
43
44 def __init__(self, item):
45 """Initialize a fighter from the program"""
46 self.__item = item
47
48 if self.isInvalid:
49 raise ValueError("Passed item is not a Fighter")
50
51 self.itemID = item.ID if item is not None else None
52 self.projected = False
53 self.projectionRange = None
54 self.active = True
55
56 # -1 is a placeholder that represents max squadron size, which we may not know yet as ships may modify this with
57 # their effects. If user changes this, it is then overridden with user value.
58 self._amount = -1
59
60 self.__abilities = self.__getAbilities()
61
62 self.build()
63
64 standardAttackActive = False
65 for ability in self.abilities:
66 if ability.effect.isImplemented and ability.effect.name == 'fighterAbilityAttackM':
67 # Activate "standard attack" if available
68 ability.active = True
69 standardAttackActive = True
70 else:
71 # Activate all other abilities (Neut, Web, etc) except propmods if no standard attack is active
72 if ability.effect.isImplemented and \
73 standardAttackActive is False and \
74 ability.effect.name != 'fighterAbilityMicroWarpDrive' and \
75 ability.effect.name != 'fighterAbilityEvasiveManeuvers':
76 ability.active = True
77
78 @reconstructor
79 def init(self):
80 """Initialize a fighter from the database and validate"""
81 self.__item = None
82
83 if self.itemID:
84 self.__item = eos.db.getItem(self.itemID)
85 if self.__item is None:
86 pyfalog.error("Item (id: {0}) does not exist", self.itemID)
87 return
88
89 if self.isInvalid:
90 pyfalog.error("Item (id: {0}) is not a Fighter", self.itemID)
91 return
92
93 self.build()
94
95 def build(self):
96 """ Build object. Assumes proper and valid item already set """
97 self.__charge = None

Callers 7

importESIFunction · 0.90
importXmlFunction · 0.90
importEftCfgFunction · 0.90
addFighterMethod · 0.90
processImportInfoFunction · 0.90
toFighterMethod · 0.90
__deepcopy__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected