| 27 | |
| 28 | |
| 29 | class FighterAbility: |
| 30 | |
| 31 | # We aren't able to get data on the charges that can be stored with fighters. So we hardcode that data here, keyed |
| 32 | # with the fighter squadron role |
| 33 | NUM_SHOTS_MAPPING = { |
| 34 | 1: 0, # Superiority fighter / Attack |
| 35 | 2: 12, # Light fighter / Attack |
| 36 | 4: 6, # Heavy fighter / Heavy attack |
| 37 | 5: 3, # Heavy fighter / Long range attack |
| 38 | } |
| 39 | # Same as above |
| 40 | REARM_TIME_MAPPING = { |
| 41 | 1: 0, # Superiority fighter / Attack |
| 42 | 2: 4000, # Light fighter / Attack |
| 43 | 4: 6000, # Heavy fighter / Heavy attack |
| 44 | 5: 20000, # Heavy fighter / Long range attack |
| 45 | } |
| 46 | |
| 47 | def __init__(self, effect): |
| 48 | """Initialize from the program""" |
| 49 | self.__effect = effect |
| 50 | self.effectID = effect.ID if effect is not None else None |
| 51 | self.active = False |
| 52 | self.build() |
| 53 | |
| 54 | @reconstructor |
| 55 | def init(self): |
| 56 | """Initialize from the database""" |
| 57 | self.__effect = None |
| 58 | |
| 59 | if self.effectID: |
| 60 | self.__effect = next((x for x in self.fighter.item.effects.values() if x.ID == self.effectID), None) |
| 61 | if self.__effect is None: |
| 62 | pyfalog.error("Effect (id: {0}) does not exist", self.effectID) |
| 63 | return |
| 64 | |
| 65 | self.build() |
| 66 | |
| 67 | def build(self): |
| 68 | pass |
| 69 | |
| 70 | @property |
| 71 | def effect(self): |
| 72 | return self.__effect |
| 73 | |
| 74 | @property |
| 75 | def name(self): |
| 76 | return self.__effect.getattr('displayName') or self.__effect.name |
| 77 | |
| 78 | @property |
| 79 | def attrPrefix(self): |
| 80 | return self.__effect.getattr('prefix') |
| 81 | |
| 82 | @property |
| 83 | def dealsDamage(self): |
| 84 | attr = "{}DamageMultiplier".format(self.attrPrefix) |
| 85 | return attr in self.fighter.itemModifiedAttributes or self.fighter.charge is not None |
| 86 | |