def canActivate(self, entityName = None, avatar = None): result, error = super(_ExtinguisherItem, self).canActivate(entityName, avatar) if not result: return (result, error) if not avatar_getter.isVehicleInFire(avatar): return (False, _ActivationError('extinguisherDoesNotActivated', {'name': self._descriptor.userString})) return (True, None)
def repairHandler(self, data): sessionProvider = dependency.instance(IBattleSessionProvider) equipments = sessionProvider.shared.equipments item = data['name'] if item in DEVICES: if (item == FUELTANK) and isVehicleInFire(): self.useEquipment(REPAIR_ITEMS['extinguisher'], None, sessionProvider) return elif item == COMPLEX: if self.lastComplex is not None: item = self.lastComplex elif self.complexStates: if 'destroyed' in self.complexStates.values(): for compl in self.complexStates: if compl == 'destroyed': item = compl break elif 'critical' in self.complexStates.values(): for compl in self.complexStates: if compl == 'critical': item = compl break if equipments.hasEquipment(REPAIR_ITEMS['repair_kit']): self.useEquipment(REPAIR_ITEMS['repair_kit'], item, sessionProvider) elif equipments.hasEquipment(REPAIR_ITEMS['g_repair_kit']): self.useEquipment(REPAIR_ITEMS['g_repair_kit'], item, sessionProvider) elif item in CREW: if equipments.hasEquipment(REPAIR_ITEMS['med_kit']): self.useEquipment(REPAIR_ITEMS['med_kit'], self.getContusedTankmanWIndex(item), sessionProvider) elif equipments.hasEquipment(REPAIR_ITEMS['g_med_kit']): self.useEquipment(REPAIR_ITEMS['g_med_kit'], self.getContusedTankmanWIndex(item), sessionProvider)