def __onDropVehicleCamouflage(self, resultID, kind):
     if resultID < 0:
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SERVER_ERROR)
         self.onCustomizationDropFailed(message)
         return
     else:
         item = self.currentItemsByKind.get(kind)
         hangarItem = CustomizationHelper.getItemFromHangar(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE_TYPE, item.get('id'), self._nationID)
         if hangarItem:
             intCD = g_currentVehicle.item.intCD
             vehicle = vehicles.getVehicleType(int(intCD))
             message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_STORED_SUCCESS, vehicle=vehicle.userString)
         else:
             message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SUCCESS)
         if g_tankActiveCamouflage.has_key(g_currentVehicle.item.intCD):
             del g_tankActiveCamouflage[g_currentVehicle.item.intCD]
         newID = None
         newLifeCycle = None
         if gui.game_control.g_instance.igr.getRoomType() != IGR_TYPE.NONE:
             camouflages = g_currentVehicle.item.descriptor.camouflages
             camo = camouflages[kind]
             if camo[0] is not None:
                 newID = camo[0]
                 newLifeCycle = (camo[1], camo[2])
         item['id'] = newID
         item['lifeCycle'] = newLifeCycle
         if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == kind:
             self._itemsDP.currentItemID = newID
         self.onCustomizationDropSuccess(message)
         return
示例#2
0
    def onRequestList(self, groupName):
        self.currentGroup = groupName
        customization = vehicles.g_cache.customization(self.nationID)
        result = []
        if customization is not None:
            groups = customization.get('camouflageGroups', {})
            group = groups.get(groupName, {})
            camouflages = customization.get('camouflages', {})
            armorColor = customization.get('armorColor', 0)
            ids = group.get('ids', [])
            currIntDescr = g_currentVehicle.item.intCD
            for id in ids:
                camouflageInfo = self._constructCamouflage(id, groups, camouflages, armorColor, isCurrent=self.currentItemID == id, isInHangar=CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE, id, self.nationID), withoutCheck=False, currVehIntD=currIntDescr)
                if camouflageInfo is not None:
                    if not self._isIGR and camouflageInfo.get('igrType') == constants.IGR_TYPE.NONE or self._isIGR and camouflageInfo.get('igrType') == constants.IGR_TYPE.PREMIUM:
                        result.append(camouflageInfo)

            if gui.GUI_SETTINGS.igrEnabled:
                for name, group in groups.iteritems():
                    if name not in CAMOUFLAGE_KINDS:
                        ids = group.get('ids', [])
                        for cID in ids:
                            camouflage = camouflages.get(cID, None)
                            if camouflage.get('kind', 0) == CAMOUFLAGE_KINDS.get(groupName, 0):
                                camouflageInfo = self._constructCamouflage(cID, groups, camouflages, armorColor, isCurrent=self.currentItemID == cID, isInHangar=CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE, cID, self.nationID), withoutCheck=False, currVehIntD=currIntDescr)
                                if camouflageInfo is not None and camouflageInfo:
                                    if not self._isIGR and camouflageInfo.get('igrType') == constants.IGR_TYPE.NONE or self._isIGR and camouflageInfo.get('igrType') == constants.IGR_TYPE.PREMIUM:
                                        result.append(camouflageInfo)

        return sorted(result, cmp=self.__comparator)
示例#3
0
 def __onChangeVehicleCamouflage(self, price, kind, resultID):
     if resultID < 0:
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SERVER_ERROR)
         self.onCustomizationChangeFailed(message)
         return
     else:
         item = self.currentItemsByKind.get(kind)
         g_tankActiveCamouflage[g_currentVehicle.item.intCD] = kind
         item['id'] = item.get('newItemID')
         item['lifeCycle'] = None
         item['newItemID'] = None
         if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == kind:
             self._itemsDP.currentItemID = item['id']
         cost, isGold = price
         if isGold:
             key = SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SUCCESS_GOLD
             fCost = BigWorld.wg_getGoldFormat(cost)
             typeValue = SystemMessages.SM_TYPE.CustomizationForGold
         else:
             key = SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SUCCESS_CREDITS
             fCost = BigWorld.wg_getIntegralFormat(cost)
             typeValue = SystemMessages.SM_TYPE.CustomizationForCredits
         str = i18n.makeString(key, fCost)
         self.onCustomizationChangeSuccess(str, typeValue)
         return
 def __onChangeVehicleCamouflage(self, price, kind, resultID):
     if resultID < 0:
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SERVER_ERROR)
         self.onCustomizationChangeFailed(message)
         return
     else:
         item = self.currentItemsByKind.get(kind)
         g_tankActiveCamouflage[g_currentVehicle.item.intCD] = kind
         item['id'] = item.get('newItemID')
         item['lifeCycle'] = None
         item['newItemID'] = None
         if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == kind:
             self._itemsDP.currentItemID = item['id']
         cost, isGold = price
         if cost == 0:
             key = SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SUCCESS_FREE
             typeValue = SystemMessages.SM_TYPE.Information
             str = i18n.makeString(key)
         else:
             if isGold:
                 key = SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SUCCESS_GOLD
                 fCost = BigWorld.wg_getGoldFormat(cost)
                 typeValue = SystemMessages.SM_TYPE.CustomizationForGold
             else:
                 key = SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_CHANGE_SUCCESS_CREDITS
                 fCost = BigWorld.wg_getIntegralFormat(cost)
                 typeValue = SystemMessages.SM_TYPE.CustomizationForCredits
             str = i18n.makeString(key, fCost)
         self.onCustomizationChangeSuccess(str, typeValue)
         return
 def __onDropVehicleCamouflage(self, resultID, kind):
     if resultID < 0:
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SERVER_ERROR)
         self.onCustomizationDropFailed(message)
         return
     item = self.currentItemsByKind.get(kind)
     hangarItem = CustomizationHelper.getItemFromHangar(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE_TYPE, item.get('id'), self._nationID)
     if hangarItem:
         intCD = g_currentVehicle.item.intCD
         vehicle = vehicles.getVehicleType(int(intCD))
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_STORED_SUCCESS, vehicle=vehicle.userString)
     else:
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SUCCESS)
     if g_tankActiveCamouflage.has_key(g_currentVehicle.item.intCD):
         del g_tankActiveCamouflage[g_currentVehicle.item.intCD]
     newID = None
     newLifeCycle = None
     if gui.game_control.g_instance.igr.getRoomType() != IGR_TYPE.NONE:
         camouflages = g_currentVehicle.item.descriptor.camouflages
         camo = camouflages[kind]
         if camo[0] is not None:
             newID = camo[0]
             newLifeCycle = (camo[1], camo[2])
     item['id'] = newID
     item['lifeCycle'] = newLifeCycle
     if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == kind:
         self._itemsDP.currentItemID = newID
     self.onCustomizationDropSuccess(message)
 def refreshViewData(self, vehType, refresh=False):
     if vehType is not None:
         self._groupsDP.buildList()
         self._itemsDP.setVehicleTypeParams(
             self.getItemPriceFactor(vehType),
             self.getItemDefaultPriceFactor(vehType),
             self.currentItemsByKind.get(CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup, 0), {"id": None}).get(
                 "id"
             ),
         )
     self._rentalPackageDP.refreshList()
     return
示例#7
0
    def buildList(self):
        customization = vehicles.g_cache.customization(self._nationID)
        result = []
        if customization is not None:
            groups = customization.get('camouflageGroups', {})
            for name, info in groups.iteritems():
                result.append({'name': name,
                 'userString': info.get('userString', name),
                 'hasNew': info.get('hasNew', False),
                 'kind': CAMOUFLAGE_KINDS.get(name)})

        self.__list = sorted(result, cmp=self.__comparator)
        return
示例#8
0
    def buildList(self):
        customization = vehicles.g_cache.customization(self._nationID)
        result = []
        if customization is not None:
            groups = customization.get('camouflageGroups', {})
            for name, info in groups.iteritems():
                result.append({
                    'name': name,
                    'userString': info.get('userString', name),
                    'hasNew': info.get('hasNew', False),
                    'kind': CAMOUFLAGE_KINDS.get(name)
                })

        self.__list = sorted(result, cmp=self.__comparator)
        return
示例#9
0
 def __onDropVehicleCamouflage(self, resultID, kind):
     if resultID < 0:
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SERVER_ERROR)
         self.onCustomizationDropFailed(message)
         return
     else:
         item = self.currentItemsByKind.get(kind)
         if g_tankActiveCamouflage.has_key(g_currentVehicle.item.intCD):
             del g_tankActiveCamouflage[g_currentVehicle.item.intCD]
         item['id'] = None
         item['lifeCycle'] = None
         if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == kind:
             self._itemsDP.currentItemID = None
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SUCCESS)
         self.onCustomizationDropSuccess(message)
         return
示例#10
0
    def update(self, vehicleDescr):
        camouflages = vehicleDescr.camouflages
        isUpdated = False
        for index, camouflage in enumerate(camouflages):
            camouflageID = camouflage[0] if camouflage is not None else None
            item = self.currentItemsByKind[index]
            if camouflageID != item.get('id'):
                isUpdated = True
                item['id'] = camouflageID
                if camouflage is not None:
                    _, startTime, days = camouflage
                    startTime = time_utils.makeLocalServerTime(startTime)
                    item['lifeCycle'] = (startTime, days)
                else:
                    item['lifeCycle'] = None
                if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == index:
                    self._itemsDP.currentItemID = item['id']

        if isUpdated:
            self.onCurrentItemChange(self._name)
示例#11
0
    def buildList(self):
        customization = vehicles.g_cache.customization(self._nationID)
        result = []
        compactDescr = g_currentVehicle.item.descriptor.type.compactDescr
        activeGroup = g_tankActiveCamouflage['historical'].get(compactDescr)
        if activeGroup is None:
            activeGroup = g_tankActiveCamouflage.get(compactDescr, 0)
        if customization is not None:
            groups = customization.get('camouflageGroups', {})
            for name, info in groups.iteritems():
                isHasNew = self._hasNewItems(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE_TYPE, info.get('ids', []))
                if name in CAMOUFLAGE_KINDS:
                    groupId = CAMOUFLAGE_KINDS.get(name)
                    result.append({'name': name,
                     'userString': info.get('userString', name),
                     'hasNew': isHasNew,
                     'kind': groupId,
                     'enabled': True,
                     'selected': activeGroup == groupId})

        self._list = sorted(result, cmp=self.__comparator)
 def __onDropVehicleCamouflage(self, resultID, kind):
     if resultID < 0:
         message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SERVER_ERROR)
         self.onCustomizationDropFailed(message)
         return
     item = self.currentItemsByKind.get(kind)
     if g_tankActiveCamouflage.has_key(g_currentVehicle.item.intCD):
         del g_tankActiveCamouflage[g_currentVehicle.item.intCD]
     newID = None
     newLifeCycle = None
     if gui.game_control.g_instance.igr.getRoomType() != IGR_TYPE.NONE:
         camouflages = g_currentVehicle.item.descriptor.camouflages
         camo = camouflages[kind]
         if camo[0] is not None:
             newID = camo[0]
             newLifeCycle = (camo[1], camo[2])
     item['id'] = newID
     item['lifeCycle'] = newLifeCycle
     if CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup) == kind:
         self._itemsDP.currentItemID = newID
     message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DROP_SUCCESS)
     self.onCustomizationDropSuccess(message)
示例#13
0
def __readVehicleCamouflageKind(section):
    kindName = section.readString('vehicleCamouflageKind')
    kind = CAMOUFLAGE_KINDS.get(kindName)
    if kind is None:
        raise Exception("missing or wrong section 'vehicleCamouflageKind'")
    return kind
示例#14
0
def __readVehicleCamouflageKind(section):
    kindName = section.readString('vehicleCamouflageKind')
    kind = CAMOUFLAGE_KINDS.get(kindName)
    if kind is None:
        raise Exception("missing or wrong section 'vehicleCamouflageKind'")
    return kind
示例#15
0
 def refreshViewData(self, vehType, refresh = False):
     if vehType is not None:
         self._groupsDP.buildList()
         self._itemsDP.setVehicleTypeParams(self.getItemPriceFactor(vehType), self.getItemDefaultPriceFactor(vehType), self.currentItemsByKind.get(CAMOUFLAGE_KINDS.get(self._itemsDP.currentGroup, 0), {'id': None}).get('id'))
     self._rentalPackageDP.refreshList()