Exemplo n.º 1
0
 def getDocumentsData(self, callback):
     items = g_itemsCache.items
     tankman = items.getTankman(self.tmanInvID)
     config = tankmen.getNationConfig(tankman.nationID)
     if tankman.descriptor.isFemale:
         shopPrice = items.shop.passportFemaleChangeCost
         defaultPrice = items.shop.defaults.passportFemaleChangeCost
     else:
         shopPrice = items.shop.passportChangeCost
         defaultPrice = items.shop.defaults.passportChangeCost
     action = None
     if shopPrice != defaultPrice:
         action = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS,
                                        'passportChangeCost', True,
                                        Money(gold=shopPrice),
                                        Money(gold=defaultPrice))
     callback({
         'money':
         items.stats.money,
         'passportChangeCost':
         shopPrice,
         'action':
         action,
         'firstnames':
         self.__getDocGroupValues(tankman, config, 'firstNames'),
         'lastnames':
         self.__getDocGroupValues(tankman, config, 'lastNames'),
         'icons':
         self.__getDocGroupValues(tankman,
                                  config,
                                  'icons',
                                  sortNeeded=False)
     })
     return
Exemplo n.º 2
0
 def getDocumentsData(self, callback):
     items = g_itemsCache.items
     tankman = items.getTankman(self.tmanInvID)
     config = tankmen.getNationConfig(tankman.nationID)
     if tankman.descriptor.isFemale:
         shopPrice = items.shop.passportFemaleChangeCost
         defaultPrice = items.shop.defaults.passportFemaleChangeCost
     else:
         shopPrice = items.shop.passportChangeCost
         defaultPrice = items.shop.defaults.passportChangeCost
     action = None
     if shopPrice != defaultPrice:
         action = {'type': ACTION_TOOLTIPS_TYPE.ECONOMICS,
          'key': 'passportChangeCost',
          'isBuying': True,
          'state': (0, ACTION_TOOLTIPS_STATE.DISCOUNT),
          'newPrice': (0, shopPrice),
          'oldPrice': (0, defaultPrice)}
     callback({'money': (items.stats.credits, items.stats.gold),
      'passportChangeCost': shopPrice,
      'action': action,
      'firstnames': self.__getDocGroupValues(tankman, config, 'firstNames'),
      'lastnames': self.__getDocGroupValues(tankman, config, 'lastNames'),
      'icons': self.__getDocGroupValues(tankman, config, 'icons', sortNeeded=False)})
     return
Exemplo n.º 3
0
 def getDocumentsData(self, callback):
     items = g_itemsCache.items
     tankman = items.getTankman(self.tmanInvID)
     config = tankmen.getNationConfig(tankman.nationID)
     if tankman.descriptor.isFemale:
         shopPrice = items.shop.passportFemaleChangeCost
         defaultPrice = items.shop.defaults.passportFemaleChangeCost
     else:
         shopPrice = items.shop.passportChangeCost
         defaultPrice = items.shop.defaults.passportChangeCost
     action = None
     if shopPrice != defaultPrice:
         action = {
             "type": ACTION_TOOLTIPS_TYPE.ECONOMICS,
             "key": "passportChangeCost",
             "isBuying": True,
             "state": (0, ACTION_TOOLTIPS_STATE.DISCOUNT),
             "newPrice": (0, shopPrice),
             "oldPrice": (0, defaultPrice),
         }
     callback(
         {
             "money": (items.stats.credits, items.stats.gold),
             "passportChangeCost": shopPrice,
             "action": action,
             "firstnames": self.__getDocGroupValues(tankman, config, "firstNames"),
             "lastnames": self.__getDocGroupValues(tankman, config, "lastNames"),
             "icons": self.__getDocGroupValues(tankman, config, "icons", sortNeeded=False),
         }
     )
     return
Exemplo n.º 4
0
 def __parseTankmanData(self, nationID):
     config = tankmen.getNationGroups(nationID, self.__isPremium)
     found = [c for c in config.itervalues() if c.name == self.__group]
     if found:
         nationGroup = found[0]
         firstNamesList = nationGroup.firstNamesList
         lastNamesList = nationGroup.lastNamesList
         iconsList = nationGroup.iconsList
         if not firstNamesList or not lastNamesList or not iconsList:
             return ([], EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, False)
         if len(firstNamesList) > 1 or len(lastNamesList) > 1 or len(
                 iconsList) > 1:
             if nationGroup.isFemales:
                 return (nationGroup.rolesList,
                         _ms(QUESTS.BONUSES_ITEM_TANKWOMAN), EMPTY_STRING,
                         _TANKWOMAN_ICON, nationGroup.isFemales)
             return (nationGroup.rolesList,
                     _ms(QUESTS.BONUSES_ITEM_TANKMAN), EMPTY_STRING,
                     _TANKMAN_ICON, nationGroup.isFemales)
         firstNameId = nationGroup.firstNamesList[0]
         lastNameId = nationGroup.lastNamesList[0]
         iconId = nationGroup.iconsList[0]
         nationConfig = tankmen.getNationConfig(nationID)
         return (nationGroup.rolesList,
                 nationConfig.getFirstName(firstNameId),
                 nationConfig.getLastName(lastNameId),
                 nationConfig.getIcon(iconId), nationGroup.isFemales)
     return ([], EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, False)
Exemplo n.º 5
0
 def getDocumentsData(self, callback):
     items = g_itemsCache.items
     config = tankmen.getNationConfig(items.getTankman(self.tmanInvID).nationID)
     callback({'money': (items.stats.credits, items.stats.gold),
      'passportChangeCost': items.shop.passportChangeCost,
      'firstnames': self.__getDocNormalGroupValues(config, 'firstNames'),
      'lastnames': self.__getDocNormalGroupValues(config, 'lastNames'),
      'icons': self.__getDocNormalGroupValues(config, 'icons')})
 def getDocumentsData(self, callback):
     items = self.itemsCache.items
     tankman = items.getTankman(self.tmanInvID)
     config = tankmen.getNationConfig(tankman.nationID)
     callback({'firstName': tankman.firstUserName,
      'lastName': tankman.lastUserName,
      'firstnames': self.__getDocGroupValues(tankman, config, operator.attrgetter('firstNamesList'), config.getFirstName),
      'lastnames': self.__getDocGroupValues(tankman, config, operator.attrgetter('lastNamesList'), config.getLastName),
      'icons': self.__getDocGroupValues(tankman, config, operator.attrgetter('iconsList'), config.getIcon, sortNeeded=False)})
Exemplo n.º 7
0
    def __hasUniqueData(cls, tankman, firstNameID, lastNameID, iconID):
        tDescr = tankman.descriptor
        nationConfig = tankmen.getNationConfig(tankman.nationID)
        for group in nationConfig['normalGroups']:
            if group.get('notInShop'):
                if tDescr.firstNameID != firstNameID and firstNameID is not None and tDescr.firstNameID in group['firstNamesList'] or tDescr.lastNameID != lastNameID and lastNameID is not None and tDescr.lastNameID in group['lastNamesList'] or tDescr.iconID != iconID and iconID is not None and tDescr.iconID in group['iconsList']:
                    return True

        return False
    def __hasUniqueData(cls, tankman, firstNameID, lastNameID, iconID):
        tDescr = tankman.descriptor
        nationConfig = tankmen.getNationConfig(tankman.nationID)
        for group in nationConfig.normalGroups:
            if group.notInShop:
                if tDescr.firstNameID != firstNameID and firstNameID is not None and tDescr.firstNameID in group.firstNamesList or tDescr.lastNameID != lastNameID and lastNameID is not None and tDescr.lastNameID in group.lastNamesList or tDescr.iconID != iconID and iconID is not None and tDescr.iconID in group.iconsList:
                    return True

        return False
Exemplo n.º 9
0
def preprocessBotName(name):
    ids = LOCALIZABLE_BOT_NAME.parse(name)
    if ids is not None:
        nationID, firstNameID, lastNameID = ids
        nationConfig = tankmen.getNationConfig(nationID)
        firstName = i18n.convert(nationConfig.getFirstName(firstNameID))
        lastName = i18n.convert(nationConfig.getLastName(lastNameID))
        if IS_DEVELOPMENT:
            name = '{0}_{1}_{2} :{3} {4}:'.format(nationID, firstNameID,
                                                  lastNameID, firstName,
                                                  lastName)
        else:
            name = ':{0} {1}:'.format(firstName, lastName)
    return name
Exemplo n.º 10
0
 def getDocumentsData(self, callback):
     items = g_itemsCache.items
     config = tankmen.getNationConfig(
         items.getTankman(self.tmanInvID).nationID)
     callback({
         'money': (items.stats.credits, items.stats.gold),
         'passportChangeCost':
         items.shop.passportChangeCost,
         'firstnames':
         self.__getDocNormalGroupValues(config, 'firstNames'),
         'lastnames':
         self.__getDocNormalGroupValues(config, 'lastNames'),
         'icons':
         self.__getDocNormalGroupValues(config, 'icons')
     })
 def __parseTankmanData(self, nationID):
     config = tankmen.getNationGroups(nationID, self.__isPremium)
     found = [c for c in config if c.name == self.__group]
     if found:
         nationGroup = found[0]
         if not nationGroup.firstNamesList or not nationGroup.lastNamesList or not nationGroup.iconsList:
             return ([], EMPTY_STRING, EMPTY_STRING, EMPTY_STRING)
         firstNameId = nationGroup.firstNamesList[0]
         lastNameId = nationGroup.lastNamesList[0]
         iconId = nationGroup.iconsList[0]
         nationConfig = tankmen.getNationConfig(nationID)
         return (nationGroup.rolesList,
                 nationConfig.getFirstName(firstNameId),
                 nationConfig.getLastName(lastNameId),
                 nationConfig.getIcon(iconId))
     return ([], EMPTY_STRING, EMPTY_STRING, EMPTY_STRING)
Exemplo n.º 12
0
    def __createCrew(self, crewXml, vCompDescr):
        crew = {}
        if not crewXml:
            return crew
        else:
            crewStr = '<root>{}</root>'.format(crewXml.encode('ascii'))
            crewSection = ResMgr.DataSection().createSectionFromString(crewStr)
            if crewSection is not None:
                crew['tankmen'] = []
                _, nationId, vehTypeId = vehicles.parseIntCompactDescr(
                    vCompDescr)
                for tankmanSection in crewSection.values():
                    tmanDict = {}
                    tmanId = tankmanSection.readString('name')
                    if not tmanId:
                        continue
                    tData = None
                    tIdx = None
                    for idx, tMan in tankmen.getNationConfig(
                            nationId).premiumGroups.iteritems():
                        if tMan.name == tmanId:
                            tData = tMan
                            tIdx = idx
                            break

                    if tData is None:
                        continue
                    tmanDict['isPremium'] = True
                    tmanDict['gId'] = tIdx
                    tmanDict['nationID'] = nationId
                    tmanDict['firstNameID'] = first(tData.firstNames)
                    tmanDict['lastNameID'] = first(tData.lastNames)
                    tmanDict['iconID'] = first(tData.icons)
                    tmanDict['vehicleTypeID'] = vehTypeId
                    tmanDict['role'] = tankmanSection.readString('role')
                    for param in ('roleLevel', 'freeXP'):
                        tmanDict[param] = tankmanSection.readInt(param)

                    for param in ('skills', 'freeSkills'):
                        paramAsStr = tankmanSection.readString(param)
                        tmanDict[param] = paramAsStr.split(
                            ' ') if paramAsStr else []

                    crew['tankmen'].append(tmanDict)

            return crew
Exemplo n.º 13
0
 def getDocumentsData(self, callback):
     items = self.itemsCache.items
     tankman = items.getTankman(self.tmanInvID)
     config = tankmen.getNationConfig(tankman.nationID)
     if tankman.descriptor.isFemale:
         shopPrice = items.shop.passportFemaleChangeCost
         defaultPrice = items.shop.defaults.passportFemaleChangeCost
     else:
         shopPrice = items.shop.passportChangeCost
         defaultPrice = items.shop.defaults.passportChangeCost
     currentGold = self.itemsCache.items.stats.gold
     enableSubmitButton = shopPrice <= currentGold or isIngameShopEnabled()
     action = None
     if shopPrice != defaultPrice:
         action = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS,
                                        'passportChangeCost', True,
                                        Money(gold=shopPrice),
                                        Money(gold=defaultPrice))
     callback({
         'money':
         items.stats.money.toMoneyTuple(),
         'passportChangeCost':
         shopPrice,
         'action':
         action,
         'firstnames':
         self.__getDocGroupValues(tankman, config,
                                  operator.attrgetter('firstNamesList'),
                                  config.getFirstName),
         'lastnames':
         self.__getDocGroupValues(tankman, config,
                                  operator.attrgetter('lastNamesList'),
                                  config.getLastName),
         'icons':
         self.__getDocGroupValues(tankman,
                                  config,
                                  operator.attrgetter('iconsList'),
                                  config.getIcon,
                                  sortNeeded=False),
         'enableSubmitButton':
         enableSubmitButton
     })
     return
Exemplo n.º 14
0
 def getDocumentsData(self, callback):
     items = g_itemsCache.items
     tankman = items.getTankman(self.tmanInvID)
     config = tankmen.getNationConfig(tankman.nationID)
     if tankman.descriptor.isFemale:
         shopPrice = items.shop.passportFemaleChangeCost
         defaultPrice = items.shop.defaults.passportFemaleChangeCost
     else:
         shopPrice = items.shop.passportChangeCost
         defaultPrice = items.shop.defaults.passportChangeCost
     action = None
     if shopPrice != defaultPrice:
         action = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'passportChangeCost', True, Money(gold=shopPrice), Money(gold=defaultPrice))
     callback({'money': items.stats.money,
      'passportChangeCost': shopPrice,
      'action': action,
      'firstnames': self.__getDocGroupValues(tankman, config, 'firstNames'),
      'lastnames': self.__getDocGroupValues(tankman, config, 'lastNames'),
      'icons': self.__getDocGroupValues(tankman, config, 'icons', sortNeeded=False)})
     return
Exemplo n.º 15
0
def preprocessBotName(name):
    namingType, args = LocalizableBotName.parse(name)
    if namingType == BotNamingType.CREW_MEMBER:
        nationID, firstNameID, lastNameID = args
        nationConfig = tankmen.getNationConfig(nationID)
        firstName = i18n.convert(nationConfig.getFirstName(firstNameID))
        lastName = i18n.convert(nationConfig.getLastName(lastNameID))
        name = _NAME_FORMAT_CREW.format(firstName, lastName)
        if IS_DEVELOPMENT:
            name = _DEV_PREFIX_FORMAT_CREW.format(nationID, firstNameID,
                                                  lastNameID) + name
    elif namingType == BotNamingType.VEHICLE_MODEL:
        uniqueIndex, nationID, vehicleTypeID = args
        name = i18n.convert(
            vehicles.g_cache.vehicle(nationID, vehicleTypeID).shortUserString)
        if IS_DEVELOPMENT:
            name = _DEV_PREFIX_FORMAT_VEHICLE.format(uniqueIndex) + name
    elif namingType == BotNamingType.CUSTOM:
        uniqueIndex, stringKey = args
        name = i18n.makeString(stringKey)
        if IS_DEVELOPMENT:
            name = _DEV_PREFIX_FORMAT_CUSTOM.format(uniqueIndex) + name
    return name
Exemplo n.º 16
0
 def getDocumentsData(self, callback):
     items = g_itemsCache.items
     tankman = items.getTankman(self.tmanInvID)
     config = tankmen.getNationConfig(tankman.nationID)
     if tankman.descriptor.isFemale:
         shopPrice = items.shop.passportFemaleChangeCost
         defaultPrice = items.shop.defaults.passportFemaleChangeCost
     else:
         shopPrice = items.shop.passportChangeCost
         defaultPrice = items.shop.defaults.passportChangeCost
     action = None
     if shopPrice != defaultPrice:
         action = {
             'type': ACTION_TOOLTIPS_TYPE.ECONOMICS,
             'key': 'passportChangeCost',
             'isBuying': True,
             'state': (0, ACTION_TOOLTIPS_STATE.DISCOUNT),
             'newPrice': (0, shopPrice),
             'oldPrice': (0, defaultPrice)
         }
     callback({
         'money': (items.stats.credits, items.stats.gold),
         'passportChangeCost':
         shopPrice,
         'action':
         action,
         'firstnames':
         self.__getDocGroupValues(tankman, config, 'firstNames'),
         'lastnames':
         self.__getDocGroupValues(tankman, config, 'lastNames'),
         'icons':
         self.__getDocGroupValues(tankman,
                                  config,
                                  'icons',
                                  sortNeeded=False)
     })
 def __parseTankmanData(self, nationID):
     empty = ([],
      EMPTY_STRING,
      EMPTY_STRING,
      EMPTY_STRING,
      False)
     nationGroup = self.__getNationGroup(nationID)
     if nationGroup is None:
         return empty
     else:
         firstNamesList = nationGroup.firstNamesList
         lastNamesList = nationGroup.lastNamesList
         iconsList = nationGroup.iconsList
         if not firstNamesList or not lastNamesList or not iconsList:
             return empty
         if len(firstNamesList) > 1 or len(lastNamesList) > 1 or len(iconsList) > 1:
             if nationGroup.isFemales:
                 return (nationGroup.rolesList,
                  _ms(QUESTS.BONUSES_ITEM_TANKWOMAN),
                  EMPTY_STRING,
                  _TANKWOMAN_ICON,
                  nationGroup.isFemales)
             return (nationGroup.rolesList,
              _ms(QUESTS.BONUSES_ITEM_TANKMAN),
              EMPTY_STRING,
              _TANKMAN_ICON,
              nationGroup.isFemales)
         firstNameId = nationGroup.firstNamesList[0]
         lastNameId = nationGroup.lastNamesList[0]
         iconId = nationGroup.iconsList[0]
         nationConfig = tankmen.getNationConfig(nationID)
         return (nationGroup.rolesList,
          nationConfig.getFirstName(firstNameId),
          nationConfig.getLastName(lastNameId),
          nationConfig.getIcon(iconId),
          nationGroup.isFemales)
Exemplo n.º 18
0
def getLastUserName(nationID, lastNameID):
    return i18n.convert(tankmen.getNationConfig(nationID)["lastNames"][lastNameID])
Exemplo n.º 19
0
 def lastUserName(self):
     """ Tankman's lastname represented as user-friendly string. """
     return convert(tankmen.getNationConfig(self.nationID)['lastNames'][self.descriptor.lastNameID])
Exemplo n.º 20
0
 def icon(self):
     """ Tankman's portrait icon filename. """
     return tankmen.getNationConfig(self.nationID)['icons'][self.descriptor.iconID]
Exemplo n.º 21
0
def getIconName(nationID, iconID):
    return tankmen.getNationConfig(nationID)['icons'][iconID]
Exemplo n.º 22
0
def getLastUserName(nationID, lastNameID):
    return i18n.convert(
        tankmen.getNationConfig(nationID)['lastNames'][lastNameID])
Exemplo n.º 23
0
 def rankUserName(self):
     """ Tankman's rank represented as user-friendly string. """
     return convert(
         tankmen.getNationConfig(
             self.nationID)['ranks'][self.descriptor.rankID]['userString'])
Exemplo n.º 24
0
def getRankUserName(nationID, rankID):
    return i18n.convert(tankmen.getNationConfig(nationID)['ranks'][rankID]['userString'])
Exemplo n.º 25
0
def getRankIconName(nationID, rankID):
    return tankmen.getNationConfig(nationID)['ranks'][rankID]['icon']
Exemplo n.º 26
0
def getRankIconName(nationID, rankID):
    return tankmen.getNationConfig(nationID)["ranks"][rankID]["icon"]
Exemplo n.º 27
0
def getIconName(nationID, iconID):
    return tankmen.getNationConfig(nationID)["icons"][iconID]
Exemplo n.º 28
0
def getRankUserName(nationID, rankID):
    return i18n.convert(tankmen.getNationConfig(nationID)["ranks"][rankID]["userString"])
Exemplo n.º 29
0
 def iconRank(self):
     """ Tankman's rank icon filepath. """
     return tankmen.getNationConfig(
         self.nationID)['ranks'][self.descriptor.rankID]['icon']
Exemplo n.º 30
0
 def lastUserName(self):
     """ Tankman's lastname represented as user-friendly string. """
     return convert(
         tankmen.getNationConfig(
             self.nationID)['lastNames'][self.descriptor.lastNameID])
def getExtensionLessIconName(nationID, iconID):
    return tankmen.getNationConfig(nationID).getExtensionLessIcon(iconID)
Exemplo n.º 32
0
def getFirstUserName(nationID, firstNameID):
    return i18n.convert(
        tankmen.getNationConfig(nationID)['firstNames'][firstNameID])
Exemplo n.º 33
0
 def _getNationGroup(nationID, isPremium, groupID):
     config = getNationConfig(nationID)
     return (config.premiumGroups
             if isPremium else config.normalGroups).get(groupID)
Exemplo n.º 34
0
def getRankUserName(nationID, rankID):
    return i18n.convert(
        tankmen.getNationConfig(nationID)['ranks'][rankID]['userString'])
Exemplo n.º 35
0
def getRankUserName(nationID, rankID):
    return i18n.convert(
        tankmen.getNationConfig(nationID).getRank(rankID).userString)
Exemplo n.º 36
0
def getRankIconName(nationID, rankID):
    return tankmen.getNationConfig(nationID)['ranks'][rankID]['icon']
Exemplo n.º 37
0
def getIconName(nationID, iconID):
    return tankmen.getNationConfig(nationID).getIcon(iconID)
Exemplo n.º 38
0
def _iterNationsConfigs():
    return ((nationID, getNationConfig(nationID))
            for nationID in (nations.NAMES.index(n) for n in GUI_NATIONS))
Exemplo n.º 39
0
def getRankIconName(nationID, rankID):
    return tankmen.getNationConfig(nationID).getRank(rankID).icon
Exemplo n.º 40
0
 def iconRank(self):
     """ Tankman's rank icon filepath. """
     return tankmen.getNationConfig(self.nationID)['ranks'][self.descriptor.rankID]['icon']
Exemplo n.º 41
0
 def icon(self):
     """ Tankman's portrait icon filename. """
     return tankmen.getNationConfig(
         self.nationID)['icons'][self.descriptor.iconID]
Exemplo n.º 42
0
 def rankUserName(self):
     """ Tankman's rank represented as user-friendly string. """
     return convert(tankmen.getNationConfig(self.nationID)['ranks'][self.descriptor.rankID]['userString'])
Exemplo n.º 43
0
def getFirstUserName(nationID, firstNameID):
    return i18n.convert(tankmen.getNationConfig(nationID)["firstNames"][firstNameID])