def _handleCondition(self, name, data, uniqueName, group): if name == 'battles': return conditions.BattlesCount(uniqueName, data, self) if name == 'vehicleKills': return conditions.VehicleKillsCumulative(uniqueName, data, self) if name == 'vehicleDamage': return conditions.VehicleDamageCumulative(uniqueName, data, self) if name == 'cumulative': result = [] for idx, data in enumerate(data): result.append( conditions.CumulativeResult('%s%d' % (uniqueName, idx), (data, ), self)) return result if name == 'unit': result = [] for idx, data in enumerate(dict(data)['cumulative']): result.append( conditions.CumulativeResult( '%s%d' % (uniqueName, idx), (data, ), self, isUnit=True, preBattleCond=self.__preBattleCond)) return result
def _handleCondition(self, name, data, uniqueName, group): if name == 'battles': return conditions.BattlesCount(uniqueName, data, self, preBattleCond=self.__preBattleCond) if name == 'vehicleKills': return conditions.VehicleKillsCumulative(uniqueName, data, self) if name == 'vehicleDamage': return conditions.VehicleDamageCumulative(uniqueName, data, self) if name == 'vehicleStun': return conditions.VehicleStunCumulative(uniqueName, data, self) if name == 'cumulativeExt' or name == 'cumulative' or name == 'unit': unitFlag = bool(name == 'unit') result = [] if unitFlag: if 'cumulative' in dict(data): conditionKey = 'cumulative' else: conditionKey = 'cumulativeExt' currentCollection = enumerate(dict(data)[conditionKey]) else: currentCollection = enumerate(data) for idx, element in currentCollection: _, elements = element description = tuple() for elementName, value in elements: if elementName == 'description': description = ((elementName, value), ) if elementName == 'key': key = value[0][1] if elementName in ('equal', 'greater', 'greaterOrEqual'): elementValue = value[0][1] raise SoftException( 'Incorrect tag in cumulative or cummulativeExt (%s)' % elementName) element = ('value', (key, elementValue)) if unitFlag: result.append( conditions.CumulativeResult( '%s%d' % (uniqueName, idx), (element, ) + description, self, isUnit=True, preBattleCond=self.__preBattleCond)) result.append( conditions.CumulativeResult('%s%d' % (uniqueName, idx), (element, ) + description, self)) return result