def getCommonData(self, callback): """ Returns common personal case data for tankman, tankman's vehicles, message, flags and so on. """ tankman = g_itemsCache.items.getTankman(self.tmanInvID) nativeVehicle = g_itemsCache.items.getItemByCD( tankman.vehicleNativeDescr.type.compactDescr) currentVehicle = None if tankman.isInTank: currentVehicle = g_itemsCache.items.getItemByCD( tankman.vehicleDescr.type.compactDescr) isLocked, reason = self.__getTankmanLockMessage(currentVehicle) callback({ 'tankman': g_itemSerializer.pack(tankman), 'currentVehicle': g_itemSerializer.pack(currentVehicle) if currentVehicle is not None else None, 'nativeVehicle': g_itemSerializer.pack(nativeVehicle), 'isOpsLocked': isLocked or g_currentVehicle.isLocked(), 'lockMessage': reason }) return
def getDossierData(self, callback): """ Returns dict of dossier data: information stats blocks and achievements list. """ tmanDossier = g_itemsCache.items.getTankmanDossier(self.tmanInvID) if tmanDossier is None: callback(None) return else: achieves = tmanDossier.getAchievements() packedAchieves = [] for sectionIdx, section in enumerate(achieves): packedAchieves.append([]) for achievement in section: data = g_itemSerializer.pack(achievement) data['dossierType'] = GUI_ITEM_TYPE.TANKMAN_DOSSIER data['dossierCompDescr'] = pickle.dumps( tmanDossier.getDossierDescr().makeCompDescr()) packedAchieves[sectionIdx].append(data) callback({ 'achievements': packedAchieves, 'stats': tmanDossier.getStats() }) return
def __prepareAndSendInitData(self): Waiting.show('updatingSkillWindow') items = g_itemsCache.items tankman = items.getTankman(self.__tankManId) if len(tankman.skills) == 0: Waiting.hide('updatingSkillWindow') return rate = items.shop.freeXPToTManXPRate toNextPrcLeft = self.__getCurrentTankmanLevelCost(tankman) toNextPrcLeft = self.__roundByModulo(toNextPrcLeft, rate) needMaxXp = max(1, toNextPrcLeft / rate) nextSkillLevel = tankman.descriptor.lastSkillLevel + 1 freeXp = items.stats.freeXP if freeXp - needMaxXp > 0: while nextSkillLevel < MAX_SKILL_LEVEL: needMaxXp += self.__calcLevelUpCost(tankman, nextSkillLevel, len(tankman.skills)) / rate if freeXp - needMaxXp <= 0: break nextSkillLevel += 1 else: nextSkillLevel -= 1 data = { 'tankmanID': self.__tankManId, 'currentSkill': g_itemSerializer.pack(tankman.skills[len(tankman.skills) - 1]), 'lastSkillLevel': tankman.descriptor.lastSkillLevel, 'nextSkillLevel': nextSkillLevel } self.as_setInitDataS(data) Waiting.hide('updatingSkillWindow')
def __prepareAndSendInitData(self): Waiting.show('updatingSkillWindow') items = g_itemsCache.items tankman = items.getTankman(self.__tankManId) if len(tankman.skills) == 0: Waiting.hide('updatingSkillWindow') return rate = items.shop.freeXPToTManXPRate toNextPrcLeft = self.__getCurrentTankmanLevelCost(tankman) toNextPrcLeft = self.__roundByModulo(toNextPrcLeft, rate) needMaxXp = max(1, toNextPrcLeft / rate) nextSkillLevel = tankman.descriptor.lastSkillLevel + 1 freeXp = items.stats.freeXP if freeXp - needMaxXp > 0: while nextSkillLevel < MAX_SKILL_LEVEL: needMaxXp += self.__calcLevelUpCost(tankman, nextSkillLevel, len(tankman.skills)) / rate if freeXp - needMaxXp <= 0: break nextSkillLevel += 1 else: nextSkillLevel -= 1 data = {'tankmanID': self.__tankManId, 'currentSkill': g_itemSerializer.pack(tankman.skills[len(tankman.skills) - 1]), 'lastSkillLevel': tankman.descriptor.lastSkillLevel, 'nextSkillLevel': nextSkillLevel} self.as_setInitDataS(data) Waiting.hide('updatingSkillWindow')
def __prepareTankmanData(self): items = yield ItemsRequester().request() dropSkillsCost = [] for k in sorted(items.shop.dropSkillsCost.keys()): dropSkillsCost.append(items.shop.dropSkillsCost[k]) skills_count = list(tankmen.ACTIVE_SKILLS) availableSkillsCount = len(skills_count) - len(self.tankman.skills) if self.tankman.roleLevel == tankmen.MAX_SKILL_LEVEL and availableSkillsCount: if not self.tankman.descriptor.lastSkillLevel == tankmen.MAX_SKILL_LEVEL: hasNewSkills = not len(self.tankman.skills) self.as_tankManS({'money': (items.stats.credits, items.stats.gold), 'tankman': g_itemSerializer.pack(self.tankman), 'dropSkillsCost': dropSkillsCost, 'hasNewSkills': hasNewSkills, 'defaultSavingMode': 0}) question = len(self.tankman.skills) < 1 and self.tankman.roleLevel < 100 and i18n.makeString(DIALOGS.DISMISSTANKMAN_MESSAGE) else: self.controlNumber = str(self.tankman.roleLevel) question = makeHtmlString('html_templates:lobby/dialogs', 'dismissTankmanMain', {'roleLevel': str(self.tankman.roleLevel)}) else: if self.tankman.skills[-1].isPerk: skillType = DIALOGS.PROTECTEDDISMISSTANKMAN_ADDITIONALMESSAGE_ISPERK else: skillType = DIALOGS.PROTECTEDDISMISSTANKMAN_ADDITIONALMESSAGE_ISABILLITY question = makeHtmlString('html_templates:lobby/dialogs', 'dismissTankmanAdditional', {'skillType': i18n.makeString(skillType), 'skillName': self.tankman.skills[-1].userName, 'roleLevel': str(self.tankman.skills[-1].level)}) self.controlNumber = str(self.tankman.skills[-1].level) self.as_controlTextInputS(str(self.controlNumber)) self.as_setQuestionForUserS(question)
def getCommonData(self, callback): """ Returns common personal case data for tankman, tankman's vehicles, message, flags and so on. """ tankman = g_itemsCache.items.getTankman(self.tmanInvID) nativeVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr) currentVehicle = None if tankman.isInTank: currentVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleDescr.type.compactDescr) isLocked, reason = self.__getTankmanLockMessage(currentVehicle) callback({'tankman': g_itemSerializer.pack(tankman), 'currentVehicle': g_itemSerializer.pack(currentVehicle) if currentVehicle is not None else None, 'nativeVehicle': g_itemSerializer.pack(nativeVehicle), 'isOpsLocked': isLocked or g_currentVehicle.isLocked(), 'lockMessage': reason}) return
def __setData(self): Waiting.show('updatingSkillWindow') items = g_itemsCache.items tankman = items.getTankman(self.tmanInvID) dropSkillsCost = [] for k in sorted(items.shop.dropSkillsCost.keys()): dropSkillsCost.append(items.shop.dropSkillsCost[k]) skills_count = list(tankmen.ACTIVE_SKILLS) availableSkillsCount = len(skills_count) - len(tankman.skills) hasNewSkills = tankman.roleLevel == tankmen.MAX_SKILL_LEVEL and availableSkillsCount and (tankman.descriptor.lastSkillLevel == tankmen.MAX_SKILL_LEVEL or not len(tankman.skills)) self.as_setDataS({'money': (items.stats.credits, items.stats.gold), 'tankman': g_itemSerializer.pack(tankman), 'dropSkillsCost': dropSkillsCost, 'hasNewSkills': hasNewSkills, 'defaultSavingMode': 0}) Waiting.hide('updatingSkillWindow')
def __prepareTankmanData(self): items = yield ItemsRequester().request() dropSkillsCost = [] for k in sorted(items.shop.dropSkillsCost.keys()): dropSkillsCost.append(items.shop.dropSkillsCost[k]) skills_count = list(tankmen.ACTIVE_SKILLS) availableSkillsCount = len(skills_count) - len(self.tankman.skills) if self.tankman.roleLevel == tankmen.MAX_SKILL_LEVEL and availableSkillsCount: if not self.tankman.descriptor.lastSkillLevel == tankmen.MAX_SKILL_LEVEL: hasNewSkills = not len(self.tankman.skills) self.as_tankManS({ 'money': (items.stats.credits, items.stats.gold), 'tankman': g_itemSerializer.pack(self.tankman), 'dropSkillsCost': dropSkillsCost, 'hasNewSkills': hasNewSkills, 'defaultSavingMode': 0 }) question = len( self.tankman.skills ) < 1 and self.tankman.roleLevel < 100 and i18n.makeString( DIALOGS.DISMISSTANKMAN_MESSAGE) else: self.controlNumber = str(self.tankman.roleLevel) question = makeHtmlString( 'html_templates:lobby/dialogs', 'dismissTankmanMain', {'roleLevel': str(self.tankman.roleLevel)}) else: if self.tankman.skills[-1].isPerk: skillType = DIALOGS.PROTECTEDDISMISSTANKMAN_ADDITIONALMESSAGE_ISPERK else: skillType = DIALOGS.PROTECTEDDISMISSTANKMAN_ADDITIONALMESSAGE_ISABILLITY question = makeHtmlString( 'html_templates:lobby/dialogs', 'dismissTankmanAdditional', { 'skillType': i18n.makeString(skillType), 'skillName': self.tankman.skills[-1].userName, 'roleLevel': str(self.tankman.skills[-1].level) }) self.controlNumber = str(self.tankman.skills[-1].level) self.as_controlTextInputS(str(self.controlNumber)) self.as_setQuestionForUserS(question)
def toDict(self): result = GUIItem.toDict(self) def vehicleIcon(vDescr, subtype = ''): return _ICONS_MASK % {'type': 'vehicle', 'subtype': subtype, 'unicName': vDescr.name.replace(':', '-')} nativeVehicleData = {'typeCompDescr': self.vehicleNativeDescr.type.compactDescr, 'userName': self.vehicleNativeDescr.type.shortUserString, 'icon': vehicleIcon(self.vehicleNativeDescr), 'iconContour': vehicleIcon(self.vehicleNativeDescr, 'contour/')} currentVehicleData = None if self.isInTank: currentVehicleData = {'inventoryID': self.vehicleInvID, 'typeCompDescr': self.vehicleDescr.type.compactDescr, 'userName': self.vehicleDescr.type.shortUserString, 'icon': vehicleIcon(self.vehicleDescr), 'iconContour': vehicleIcon(self.vehicleDescr, 'contour/')} result.update({'strCD': pickle.dumps(self.strCD), 'inventoryID': self.invID, 'nationID': self.nationID, 'firstUserName': self.firstUserName, 'lastUserName': self.lastUserName, 'roleName': self.descriptor.role, 'rankUserName': self.rankUserName, 'roleUserName': self.roleUserName, 'skills': [ g_itemSerializer.pack(skill) for skill in self.skills ], 'efficiencyRoleLevel': self.efficiencyRoleLevel, 'realRoleLevel': self.realRoleLevel, 'roleLevel': self.roleLevel, 'icon': {'big': '%s/%s' % (self.PORTRAIT_ICON_PATH_BIG, self.icon), 'small': '%s/%s' % (self.PORTRAIT_ICON_PATH_SMALL, self.icon), 'barracks': '%s/%s' % (self.PORTRAIT_ICON_PATH_BARRACKS, self.icon)}, 'iconRole': {'big': '%s/%s' % (self.ROLE_ICON_PATH_BIG, self.iconRole), 'small': '%s/%s' % (self.ROLE_ICON_PATH_SMALL, self.iconRole)}, 'iconRank': {'big': '%s/%s' % (self.RANK_ICON_PATH_BIG, self.iconRank), 'small': '%s/%s' % (self.RANK_ICON_PATH_SMALL, self.iconRank)}, 'isInTank': self.isInTank, 'newSkillsCount': self.newSkillCount, 'nativeVehicle': nativeVehicleData, 'currentVehicle': currentVehicleData}) return result
def getDossierData(self, callback): """ Returns dict of dossier data: information stats blocks and achievements list. """ tmanDossier = g_itemsCache.items.getTankmanDossier(self.tmanInvID) if tmanDossier is None: callback(None) return else: achieves = tmanDossier.getAchievements() packedAchieves = [] for sectionIdx, section in enumerate(achieves): packedAchieves.append([]) for achievement in section: data = g_itemSerializer.pack(achievement) data['dossierType'] = GUI_ITEM_TYPE.TANKMAN_DOSSIER data['dossierCompDescr'] = pickle.dumps(tmanDossier.getDossierDescr().makeCompDescr()) packedAchieves[sectionIdx].append(data) callback({'achievements': packedAchieves, 'stats': tmanDossier.getStats()}) return
def toDict(self): result = GUIItem.toDict(self) def vehicleIcon(vDescr, subtype=''): return _ICONS_MASK % { 'type': 'vehicle', 'subtype': subtype, 'unicName': vDescr.name.replace(':', '-') } nativeVehicleData = { 'typeCompDescr': self.vehicleNativeDescr.type.compactDescr, 'userName': self.vehicleNativeDescr.type.shortUserString, 'icon': vehicleIcon(self.vehicleNativeDescr), 'iconContour': vehicleIcon(self.vehicleNativeDescr, 'contour/') } currentVehicleData = None if self.isInTank: currentVehicleData = { 'inventoryID': self.vehicleInvID, 'typeCompDescr': self.vehicleDescr.type.compactDescr, 'userName': self.vehicleDescr.type.shortUserString, 'icon': vehicleIcon(self.vehicleDescr), 'iconContour': vehicleIcon(self.vehicleDescr, 'contour/') } result.update({ 'strCD': pickle.dumps(self.strCD), 'inventoryID': self.invID, 'nationID': self.nationID, 'firstUserName': self.firstUserName, 'lastUserName': self.lastUserName, 'roleName': self.descriptor.role, 'rankUserName': self.rankUserName, 'roleUserName': self.roleUserName, 'skills': [g_itemSerializer.pack(skill) for skill in self.skills], 'efficiencyRoleLevel': self.efficiencyRoleLevel, 'realRoleLevel': self.realRoleLevel, 'roleLevel': self.roleLevel, 'icon': { 'big': '%s/%s' % (self.PORTRAIT_ICON_PATH_BIG, self.icon), 'small': '%s/%s' % (self.PORTRAIT_ICON_PATH_SMALL, self.icon), 'barracks': '%s/%s' % (self.PORTRAIT_ICON_PATH_BARRACKS, self.icon) }, 'iconRole': { 'big': '%s/%s' % (self.ROLE_ICON_PATH_BIG, self.iconRole), 'small': '%s/%s' % (self.ROLE_ICON_PATH_SMALL, self.iconRole) }, 'iconRank': { 'big': '%s/%s' % (self.RANK_ICON_PATH_BIG, self.iconRank), 'small': '%s/%s' % (self.RANK_ICON_PATH_SMALL, self.iconRank) }, 'isInTank': self.isInTank, 'newSkillsCount': self.newSkillCount, 'nativeVehicle': nativeVehicleData, 'currentVehicle': currentVehicleData }) return result
def toDict(self): result = FittingItem.toDict(self) result.update({'inventoryID': self.inventoryID, 'xp': self.xp, 'dailyXPFactor': self.dailyXPFactor, 'clanLock': self.clanLock, 'isUnique': self.isUnique, 'crew': [ (g_itemSerializer.pack(tankman) if tankman else None) for role, tankman in self.crew ], 'settings': self.settings, 'lock': self.lock, 'repairCost': self.repairCost, 'health': self.health, 'gun': g_itemSerializer.pack(self.gun), 'turret': g_itemSerializer.pack(self.turret), 'engine': g_itemSerializer.pack(self.engine), 'chassis': g_itemSerializer.pack(self.chassis), 'radio': g_itemSerializer.pack(self.radio), 'fuelTank': g_itemSerializer.pack(self.fuelTank), 'optDevices': [ (g_itemSerializer.pack(dev) if dev else None) for dev in self.optDevices ], 'shells': [ (g_itemSerializer.pack(shell) if shell else None) for shell in self.shells ], 'eqs': [ (g_itemSerializer.pack(eq) if eq else None) for eq in self.eqs ], 'eqsLayout': [ (g_itemSerializer.pack(eq) if eq else None) for eq in self.eqsLayout ], 'type': self.type, 'isPremium': self.isPremium, 'isElite': self.isElite, 'icon': self.icon, 'isLocked': self.isLocked, 'isBroken': self.isBroken, 'isAlive': self.isAlive}) return result