def onValue(self, bonus, name, value): if self.__eventType != EVENT_TYPE.POTAPOV_QUEST and name == 'tankmen': tankmenList = [ tankmen.makeTmanDescrByTmanData(tmanData) for tmanData in value ] bonus['tankmen'] = tankmenList if self.__eventType in EVENT_TYPE.LIKE_TOKEN_QUESTS and name == 'customization': if 'boundToCurrentVehicle' in value: raise Exception("Unsupported tag 'boundToCurrentVehicle' in 'like token' quests")
def __postprocessBonus(self, bonus, eventType): if eventType != EVENT_TYPE.POTAPOV_QUEST and 'tankmen' in bonus: tankmenList = [ tankmen.makeTmanDescrByTmanData(tmanData) for tmanData in bonus['tankmen'] ] bonus['tankmen'] = tankmenList if eventType in EVENT_TYPE.LIKE_TOKEN_QUESTS and 'customization' in bonus: if 'boundToCurrentVehicle' in bonus['customization']: raise Exception, "Unsupported tag 'boundToCurrentVehicle' in 'like token' quests"
def __readBonus_tankmen(bonus, vehTypeCompDescr, section, eventType): lst = [] for subsection in section.values(): tmanDescr = subsection.asString if tmanDescr: try: tman = tankmen.TankmanDescr(tmanDescr) if type(vehTypeCompDescr) == int: _, vehNationID, vehicleTypeID = vehicles.parseIntCompactDescr( vehTypeCompDescr) if vehNationID != tman.nationID or vehicleTypeID != tman.vehicleTypeID: raise SoftException('Vehicle and tankman mismatch.') except Exception as e: raise SoftException( 'Invalid tankmen compact descr. Error: %s' % (e, )) lst.append(tmanDescr) continue tmanData = { 'isFemale': subsection.readBool('isFemale', False), 'firstNameID': subsection.readInt('firstNameID', -1), 'lastNameID': subsection.readInt('lastNameID', -1), 'role': subsection.readString('role', ''), 'iconID': subsection.readInt('iconID', -1), 'roleLevel': subsection.readInt('roleLevel', 50), 'freeXP': subsection.readInt('freeXP', 0), 'fnGroupID': subsection.readInt('fnGroupID', 0), 'lnGroupID': subsection.readInt('lnGroupID', 0), 'iGroupID': subsection.readInt('iGroupID', 0), 'isPremium': subsection.readBool('isPremium', False), 'nationID': subsection.readInt('nationID', -1), 'vehicleTypeID': subsection.readInt('vehicleTypeID', -1), 'skills': subsection.readString('skills', '').split(), 'freeSkills': subsection.readString('freeSkills', '').split() } for record in ('firstNameID', 'lastNameID', 'iconID'): if tmanData[record] == -1: tmanData[record] = None try: if type(vehTypeCompDescr) == int: _, vehNationID, vehicleTypeID = vehicles.parseIntCompactDescr( vehTypeCompDescr) if vehNationID != tmanData[ 'nationID'] or vehicleTypeID != tmanData[ 'vehicleTypeID']: raise SoftException('Vehicle and tankman mismatch.') if eventType != EVENT_TYPE.PERSONAL_MISSION: tmanData = tankmen.makeTmanDescrByTmanData(tmanData) lst.append(tmanData) except Exception as e: raise SoftException('%s: %s' % (e, tmanData)) bonus['tankmen'] = lst return
def __readBonus_tankmen(self, eventType, bonus, vehTypeCompDescr, section, _gFinishTime): lst = [] for subsection in section.values(): tmanDescr = subsection.asString if tmanDescr: try: tman = tankmen.TankmanDescr(tmanDescr) if type(vehTypeCompDescr) == int: _, vehNationID, vehicleTypeID = vehicles.parseIntCompactDescr(vehTypeCompDescr) if vehNationID != tman.nationID or vehicleTypeID != tman.vehicleTypeID: raise Exception, 'Vehicle and tankman mismatch.' except Exception as e: raise Exception, 'Invalid tankmen compact descr. Error: %s' % (e,) lst.append(tmanDescr) continue tmanData = {'isFemale': subsection.readBool('isFemale', False), 'firstNameID': subsection.readInt('firstNameID', -1), 'lastNameID': subsection.readInt('lastNameID', -1), 'role': subsection.readString('role', ''), 'iconID': subsection.readInt('iconID', -1), 'roleLevel': subsection.readInt('roleLevel', 50), 'freeXP': subsection.readInt('freeXP', 0), 'fnGroupID': subsection.readInt('fnGroupID', 0), 'lnGroupID': subsection.readInt('lnGroupID', 0), 'iGroupID': subsection.readInt('iGroupID', 0), 'isPremium': subsection.readBool('isPremium', False), 'nationID': subsection.readInt('nationID', -1), 'vehicleTypeID': subsection.readInt('vehicleTypeID', -1), 'skills': subsection.readString('skills', '').split(), 'freeSkills': subsection.readString('freeSkills', '').split()} for record in ('firstNameID', 'lastNameID', 'iconID'): if tmanData[record] == -1: tmanData[record] = None try: if type(vehTypeCompDescr) == int: _, vehNationID, vehicleTypeID = vehicles.parseIntCompactDescr(vehTypeCompDescr) if vehNationID != tmanData['nationID'] or vehicleTypeID != tmanData['vehicleTypeID']: raise Exception, 'Vehicle and tankman mismatch.' if eventType != EVENT_TYPE.POTAPOV_QUEST: lst.append(tankmen.makeTmanDescrByTmanData(tmanData)) else: lst.append(tmanData) except Exception as e: raise Exception, '%s: %s' % (e, tmanData) bonus['tankmen'] = lst return