def Do(self): fit = eos.db.getFit(self.fitID) item = eos.db.getItem(self.itemID, eager=("attributes", "group.category")) try: fighter = Fighter(item) except ValueError: pyfalog.warning("Invalid fighter: {}", item) return False if not fighter.fits(fit): return False used = fit.getSlotsUsed(fighter.slot) total = fit.getNumSlots(fighter.slot) if used >= total: fighter.active = False fit.fighters.append(fighter) self.new_index = fit.fighters.index(fighter) eos.db.commit() return True
def toFighter(self): item = Market.getInstance().getItem(self.itemID, eager=('attributes', 'group.category')) try: fighter = Fighter(item) except ValueError: pyfalog.warning('Invalid item: {}'.format(self.itemID)) return None if self.amount is not None: fighter.amount = self.amount if self.state is not None: fighter.active = self.state if self.abilities is not None: for ability in fighter.abilities: ability.active = self.abilities.get(ability.effectID, ability.active) return fighter