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

Class FighterInfo

gui/fitCommands/helpers.py:220–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218
219
220class FighterInfo:
221
222 def __init__(self, itemID, amount=None, state=None, abilities=None):
223 self.itemID = itemID
224 self.amount = amount
225 self.state = state
226 self.abilities = abilities
227
228 @classmethod
229 def fromFighter(cls, fighter):
230 if fighter is None:
231 return None
232 info = cls(
233 itemID=fighter.itemID,
234 amount=fighter.amount,
235 state=fighter.active,
236 abilities={fa.effectID: fa.active for fa in fighter.abilities})
237 return info
238
239 def toFighter(self):
240 item = Market.getInstance().getItem(self.itemID, eager=('attributes', 'group.category'))
241 try:
242 fighter = Fighter(item)
243 except ValueError:
244 pyfalog.warning('Invalid item: {}'.format(self.itemID))
245 return None
246 if self.amount is not None:
247 fighter.amount = self.amount
248 if self.state is not None:
249 fighter.active = self.state
250 if self.abilities is not None:
251 for ability in fighter.abilities:
252 ability.active = self.abilities.get(ability.effectID, ability.active)
253 return fighter
254
255 def __repr__(self):
256 return makeReprStr(self, ['itemID', 'amount', 'state', 'abilities'])
257
258
259class ImplantInfo:

Callers 3

DoMethod · 0.90
DoMethod · 0.90
DoMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected