def __prepareAndSendInitData(self):
        items = g_itemsCache.items
        tankman = items.getTankman(self.__tankManId)
        if len(tankman.skills) == 0:
            return
        rate = items.shop.freeXPToTManXPRate
        toNextPrcLeft = self.__getCurrentTankmanLevelCost(tankman)
        toNextPrcLeft = self.__roundByModulo(toNextPrcLeft, rate)
        needMaxXp = max(1, toNextPrcLeft / rate)
        tDescr = tankman.descriptor
        nextSkillLevel = tDescr.lastSkillLevel
        freeXp = items.stats.freeXP
        if freeXp - needMaxXp >= 0:
            nextSkillLevel += 1
            while nextSkillLevel < MAX_SKILL_LEVEL:
                needMaxXp += self.__calcLevelUpCost(
                    tankman, nextSkillLevel,
                    tDescr.lastSkillNumber - tDescr.freeSkillsNumber) / rate
                if freeXp - needMaxXp < 0:
                    break
                nextSkillLevel += 1

        data = {
            'tankmanID':
            self.__tankManId,
            'currentSkill':
            packTankmanSkill(tankman.skills[len(tankman.skills) - 1]),
            'lastSkillLevel':
            tDescr.lastSkillLevel,
            'nextSkillLevel':
            nextSkillLevel
        }
        self.as_setInitDataS(data)
    def __prepareAndSendInitData(self):
        items = g_itemsCache.items
        tankman = items.getTankman(self.__tankManId)
        if len(tankman.skills) == 0:
            return
        rate = items.shop.freeXPToTManXPRate
        toNextPrcLeft = self.__getCurrentTankmanLevelCost(tankman)
        toNextPrcLeft = self.__roundByModulo(toNextPrcLeft, rate)
        needMaxXp = max(1, toNextPrcLeft / rate)
        tDescr = tankman.descriptor
        nextSkillLevel = tDescr.lastSkillLevel
        freeXp = items.stats.freeXP
        if freeXp - needMaxXp >= 0:
            nextSkillLevel += 1
            while nextSkillLevel < MAX_SKILL_LEVEL:
                needMaxXp += self.__calcLevelUpCost(tankman, nextSkillLevel, tDescr.lastSkillNumber - tDescr.freeSkillsNumber) / rate
                if freeXp - needMaxXp < 0:
                    break
                nextSkillLevel += 1

        data = {'tankmanID': self.__tankManId,
         'currentSkill': packTankmanSkill(tankman.skills[len(tankman.skills) - 1]),
         'lastSkillLevel': tDescr.lastSkillLevel,
         'nextSkillLevel': nextSkillLevel}
        self.as_setInitDataS(data)
Exemple #3
0
    def __prepareAndSendInitData(self):
        items = self.itemsCache.items
        tankman = items.getTankman(self.__tankManId)
        if tankman is None or not tankman.skills:
            return
        else:
            rate = items.shop.freeXPToTManXPRate
            toNextPrcLeft = self.__getCurrentTankmanLevelCost(tankman)
            tDescr = tankman.descriptor
            nextSkillLevel = tDescr.lastSkillLevel
            freeXp = items.stats.freeXP
            if freeXp >= self.__roundByModulo(toNextPrcLeft, rate) / rate:
                nextSkillLevel += 1
                skillNumber = tDescr.lastSkillNumber - tDescr.freeSkillsNumber
                while nextSkillLevel < MAX_SKILL_LEVEL:
                    toNextPrcLeft += self.__calcLevelUpCost(
                        tankman, nextSkillLevel, skillNumber)
                    if freeXp < self.__roundByModulo(toNextPrcLeft,
                                                     rate) / rate:
                        break
                    nextSkillLevel += 1

            data = {
                'tankmanID':
                self.__tankManId,
                'currentSkill':
                packTankmanSkill(tankman.skills[len(tankman.skills) - 1],
                                 tankman),
                'lastSkillLevel':
                tDescr.lastSkillLevel,
                'nextSkillLevel':
                nextSkillLevel
            }
            self.as_setInitDataS(data)
            return