def addFighter(self, fitID, itemID, recalc=True): pyfalog.debug("Adding fighters ({0}) to fit ID: {1}", itemID, fitID) if fitID is None: return False fit = eos.db.getFit(fitID) item = eos.db.getItem(itemID, eager=("attributes", "group.category")) if item.category.name == "Fighter": fighter = None ''' for d in fit.fighters.find(item): if d is not None and d.amountActive == 0 and d.amount < max(5, fit.extraAttributes["maxActiveDrones"]): drone = d break ''' if fighter is None: fighter = es_Fighter(item) used = fit.getSlotsUsed(fighter.slot) total = fit.getNumSlots(fighter.slot) if used >= total: fighter.active = False if fighter.fits(fit) is True: fit.fighters.append(fighter) else: return False eos.db.commit() if recalc: self.recalc(fit) return True else: return False
def project(self, fitID, thing): pyfalog.debug("Projecting fit ({0}) onto: {1}", fitID, thing) if fitID is None: return fit = eos.db.getFit(fitID) if isinstance(thing, int): thing = eos.db.getItem(thing, eager=("attributes", "group.category")) if isinstance(thing, es_Module): thing = copy.deepcopy(thing) fit.projectedModules.append(thing) elif isinstance(thing, FitType): if thing in fit.projectedFits: return fit.__projectedFits[thing.ID] = thing # this bit is required -- see GH issue # 83 eos.db.saveddata_session.flush() eos.db.saveddata_session.refresh(thing) elif thing.category.name == "Drone": drone = None for d in fit.projectedDrones.find(thing): if d is None or d.amountActive == d.amount or d.amount >= 5: drone = d break if drone is None: drone = es_Drone(thing) fit.projectedDrones.append(drone) drone.amount += 1 elif thing.category.name == "Fighter": fighter = es_Fighter(thing) fit.projectedFighters.append(fighter) elif thing.group.name in es_Module.SYSTEM_GROUPS: module = es_Module(thing) module.state = State.ONLINE fit.projectedModules.append(module) else: try: module = es_Module(thing) except ValueError: return False module.state = State.ACTIVE if not module.canHaveState(module.state, fit): module.state = State.OFFLINE fit.projectedModules.append(module) eos.db.commit() self.recalc(fit) return True
def project(self, fitID, thing): pyfalog.debug("Projecting fit ({0}) onto: {1}", fitID, thing) if fitID is None: return fit = eos.db.getFit(fitID) if isinstance(thing, int): thing = eos.db.getItem(thing, eager=("attributes", "group.category")) if isinstance(thing, es_Module): thing = copy.deepcopy(thing) fit.projectedModules.append(thing) elif isinstance(thing, FitType): if thing in fit.projectedFits: return fit.projectedFitDict[thing.ID] = thing # this bit is required -- see GH issue # 83 eos.db.saveddata_session.flush() eos.db.saveddata_session.refresh(thing) elif thing.category.name == "Drone": drone = None for d in fit.projectedDrones.find(thing): if d is None or d.amountActive == d.amount or d.amount >= 5: drone = d break if drone is None: drone = es_Drone(thing) fit.projectedDrones.append(drone) drone.amount += 1 elif thing.category.name == "Fighter": fighter = es_Fighter(thing) fit.projectedFighters.append(fighter) elif thing.group.name in es_Module.SYSTEM_GROUPS: module = es_Module(thing) module.state = FittingModuleState.ONLINE fit.projectedModules.append(module) else: try: module = es_Module(thing) except ValueError: return False module.state = FittingModuleState.ACTIVE if not module.canHaveState(module.state, fit): module.state = FittingModuleState.OFFLINE fit.projectedModules.append(module) eos.db.commit() self.recalc(fit) return True
def addFighter(self, fitID, itemID): if fitID is None: return False fit = getFit(fitID) item = getItem(itemID, eager=("attributes", "group.category")) if item.category.name == "Fighter": fighter = None ''' for d in fit.fighters.find(item): if d is not None and d.amountActive == 0 and d.amount < max(5, fit.extraAttributes["maxActiveDrones"]): drone = d break ''' if fighter is None: fighter = es_Fighter(item) used = fit.getSlotsUsed(fighter.slot) total = fit.getNumSlots(fighter.slot) standardAttackActive = False for ability in fighter.abilities: if (ability.effect.isImplemented and ability.effect.handlerName == u'fighterabilityattackm'): # Activate "standard attack" if available ability.active = True standardAttackActive = True else: # Activate all other abilities (Neut, Web, etc) except propmods if no standard attack is active if (ability.effect.isImplemented and standardAttackActive is False and ability.effect.handlerName != u'fighterabilitymicrowarpdrive' and ability.effect.handlerName != u'fighterabilityevasivemaneuvers'): ability.active = True if used >= total: fighter.active = False if fighter.fits(fit) is True: fit.fighters.append(fighter) else: return False eds_queries.commit() self.recalc(fit) return True else: return False
def project(self, fitID, thing): if fitID is None: return fit = eos.db.getFit(fitID) if isinstance(thing, int): thing = eos.db.getItem(thing, eager=("attributes", "group.category")) if isinstance(thing, FitType): if thing in fit.projectedFits: return fit.__projectedFits[thing.ID] = thing # this bit is required -- see GH issue # 83 eos.db.saveddata_session.flush() eos.db.saveddata_session.refresh(thing) elif thing.category.name == "Drone": drone = None for d in fit.projectedDrones.find(thing): if d is None or d.amountActive == d.amount or d.amount >= 5: drone = d break if drone is None: drone = es_Drone(thing) fit.projectedDrones.append(drone) drone.amount += 1 elif thing.category.name == "Fighter": fighter = es_Fighter(thing) fit.projectedFighters.append(fighter) elif thing.group.name == "Effect Beacon": module = es_Module(thing) module.state = State.ONLINE fit.projectedModules.append(module) else: module = es_Module(thing) module.state = State.ACTIVE if not module.canHaveState(module.state, fit): module.state = State.OFFLINE fit.projectedModules.append(module) eos.db.commit() self.recalc(fit) return True
def addFighter(self, fitID, itemID, recalc=True): pyfalog.debug("Adding fighters ({0}) to fit ID: {1}", itemID, fitID) if fitID is None: return False fit = eos.db.getFit(fitID) item = eos.db.getItem(itemID, eager=("attributes", "group.category")) if item.category.name == "Fighter": fighter = None ''' for d in fit.fighters.find(item): if d is not None and d.amountActive == 0 and d.amount < max(5, fit.extraAttributes["maxActiveDrones"]): drone = d break ''' if fighter is None: fighter = es_Fighter(item) used = fit.getSlotsUsed(fighter.slot) total = fit.getNumSlots(fighter.slot) standardAttackActive = False for ability in fighter.abilities: if ability.effect.isImplemented and ability.effect.handlerName == 'fighterabilityattackm': # Activate "standard attack" if available ability.active = True standardAttackActive = True else: # Activate all other abilities (Neut, Web, etc) except propmods if no standard attack is active if ability.effect.isImplemented and \ standardAttackActive is False and \ ability.effect.handlerName != 'fighterabilitymicrowarpdrive' and \ ability.effect.handlerName != 'fighterabilityevasivemaneuvers': ability.active = True if used >= total: fighter.active = False if fighter.fits(fit) is True: fit.fighters.append(fighter) else: return False eos.db.commit() if recalc: self.recalc(fit) return True else: return False