예제 #1
0
    def buyAndInstallItem(self, itemCD, state, inInventory = False):
        itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD)
        assert itemTypeID in GUI_ITEM_TYPE.VEHICLE_MODULES
        vehicle = self._data.getRootItem()
        assert vehicle.isInInventory, 'Vehicle must be in inventory'
        item = self._data.getItem(itemCD)
        conflictedEqs = item.getConflictedEquipments(vehicle)
        if not inInventory:
            Waiting.show('buyItem')
            buyResult = yield ModuleBuyer(item, count=1, buyForCredits=True, conflictedEqs=conflictedEqs, install=True).request()
            Waiting.hide('buyItem')
            if len(buyResult.userMsg):
                SystemMessages.g_instance.pushI18nMessage(buyResult.userMsg, type=buyResult.sysMsgType)
            if buyResult.success:
                item = self._data.getItem(itemCD)
            else:
                return
        else:
            RequestState.sent(state)
        if item.isInInventory:
            Waiting.show('applyModule')
            result = yield getInstallerProcessor(vehicle, item, conflictedEqs=conflictedEqs).request()
            if result and result.auxData:
                for m in result.auxData:
                    SystemMessages.g_instance.pushI18nMessage(m.userMsg, type=m.sysMsgType)

            if result and len(result.userMsg):
                SystemMessages.g_instance.pushI18nMessage(result.userMsg, type=result.sysMsgType)
            if result.success and item.itemTypeID in (GUI_ITEM_TYPE.TURRET, GUI_ITEM_TYPE.GUN):
                vehicle = g_itemsCache.items.getItemByCD(vehicle.intCD)
                yield tryToLoadDefaultShellsLayout(vehicle)
            Waiting.hide('applyModule')
        RequestState.received(state)
예제 #2
0
    def buyAndInstallItem(self, itemCD, state, inInventory = False):
        itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD)
        raise itemTypeID in _RESEARCH_ITEMS or AssertionError
        oldStyleVehicle = self._data.getInvItem(self._data.getRootCD())
        if not oldStyleVehicle is not None:
            raise AssertionError, 'Vehicle has be in inventory'
            eqs = functions.findConflictedEquipments(itemCD, itemTypeID, oldStyleVehicle)
            item = g_itemsCache.items.getItemByCD(itemCD)
            vehicle = g_itemsCache.items.getItemByCD(self._data.getRootCD())
            if not inInventory:
                Waiting.show('buyItem')
                buyResult = yield ModuleBuyer(item, count=1, buyForCredits=True, conflictedEqs=eqs, install=True).request()
                if len(buyResult.userMsg):
                    SystemMessages.g_instance.pushI18nMessage(buyResult.userMsg, type=buyResult.sysMsgType)
                Waiting.hide('buyItem')
            else:
                RequestState.sent(state)
            item = g_itemsCache.items.getItemByCD(itemCD)
            if item is not None and item.isInInventory:
                Waiting.show('applyModule')
                result = yield getInstallerProcessor(vehicle, item).request()
                success = result.success
                if result and result.auxData:
                    for m in result.auxData:
                        SystemMessages.g_instance.pushI18nMessage(m.userMsg, type=m.sysMsgType)

                if result and len(result.userMsg):
                    SystemMessages.g_instance.pushI18nMessage(result.userMsg, type=result.sysMsgType)
                success and itemTypeID in (_GUN, _TURRET) and self.tryLoadShells()
            Waiting.hide('applyModule')
        RequestState.received(state)
        return
예제 #3
0
 def _doUnlockItem(self, unlockCD, vehCD, unlockIdx, xpCost, result):
     if result and self._validateItem2Unlock(unlockCD, vehCD, unlockIdx,
                                             xpCost):
         costCtx = self._getXPCostCtx(self._data.getVehXP(vehCD), xpCost)
         Waiting.show('research')
         RequestState.sent('unlock')
         BigWorld.player().stats.unlock(vehCD,
                                        unlockIdx,
                                        callback=partial(
                                            self.__cb_onUnlock, unlockCD,
                                            costCtx))
예제 #4
0
 def installItem(self, itemCD, rootCD, state):
     itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD)
     raise itemTypeID in GUI_ITEM_TYPE.VEHICLE_MODULES or AssertionError
     vehicle = g_itemsCache.items.getItemByCD(rootCD)
     if not vehicle.isInInventory:
         raise AssertionError('Vehicle must be in inventory')
         item = g_itemsCache.items.getItemByCD(itemCD)
         conflictedEqs = item.getConflictedEquipments(vehicle)
         RequestState.sent(state)
         if item.isInInventory:
             Waiting.show('applyModule')
             result = yield getInstallerProcessor(vehicle, item, conflictedEqs=conflictedEqs).request()
             processMsg(result)
             vehicle = result.success and item.itemTypeID in (GUI_ITEM_TYPE.TURRET, GUI_ITEM_TYPE.GUN) and g_itemsCache.items.getItemByCD(vehicle.intCD)
             yield tryToLoadDefaultShellsLayout(vehicle)
         Waiting.hide('applyModule')
     RequestState.received(state)
     yield lambda callback = None: callback
     return
예제 #5
0
    def buyAndInstallItem(self, itemCD, state, inInventory=False):
        itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD)
        raise itemTypeID in _RESEARCH_ITEMS or AssertionError
        oldStyleVehicle = self._data.getInvItem(self._data.getRootCD())
        if not oldStyleVehicle is not None:
            raise AssertionError, 'Vehicle has be in inventory'
            eqs = functions.findConflictedEquipments(itemCD, itemTypeID,
                                                     oldStyleVehicle)
            item = g_itemsCache.items.getItemByCD(itemCD)
            vehicle = g_itemsCache.items.getItemByCD(self._data.getRootCD())
            if not inInventory:
                Waiting.show('buyItem')
                buyResult = yield ModuleBuyer(item,
                                              count=1,
                                              buyForCredits=True,
                                              conflictedEqs=eqs,
                                              install=True).request()
                if len(buyResult.userMsg):
                    SystemMessages.g_instance.pushI18nMessage(
                        buyResult.userMsg, type=buyResult.sysMsgType)
                Waiting.hide('buyItem')
            else:
                RequestState.sent(state)
            item = g_itemsCache.items.getItemByCD(itemCD)
            if item is not None and item.isInInventory:
                Waiting.show('applyModule')
                result = yield getInstallerProcessor(vehicle, item).request()
                success = result.success
                if result and result.auxData:
                    for m in result.auxData:
                        SystemMessages.g_instance.pushI18nMessage(
                            m.userMsg, type=m.sysMsgType)

                if result and len(result.userMsg):
                    SystemMessages.g_instance.pushI18nMessage(
                        result.userMsg, type=result.sysMsgType)
                success and itemTypeID in (_GUN,
                                           _TURRET) and self.tryLoadShells()
            Waiting.hide('applyModule')
        RequestState.received(state)
        return
예제 #6
0
파일: actions.py 프로젝트: webiumsk/WoT
    def buyAndInstallItem(self, itemCD, rootCD, state, inInventory = False):
        itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD)
        raise itemTypeID in GUI_ITEM_TYPE.VEHICLE_MODULES or AssertionError
        vehicle = g_itemsCache.items.getItemByCD(rootCD)
        if not vehicle.isInInventory:
            raise AssertionError('Vehicle must be in inventory')
            item = g_itemsCache.items.getItemByCD(itemCD)
            conflictedEqs = item.getConflictedEquipments(vehicle)
            if not inInventory:
                if not self._canBuy(item) and self._canBuyWithExchange(item):
                    isOk, args = yield DialogsInterface.showDialog(ExchangeCreditsMeta(itemCD))
                    if not isOk:
                        return
                if self._canBuy(item):
                    Waiting.show('buyItem')
                    buyResult = yield ModuleBuyer(item, count=1, buyForCredits=True, conflictedEqs=conflictedEqs, install=True).request()
                    Waiting.hide('buyItem')
                    if len(buyResult.userMsg):
                        SystemMessages.g_instance.pushI18nMessage(buyResult.userMsg, type=buyResult.sysMsgType)
                    if buyResult.success:
                        item = g_itemsCache.items.getItemByCD(itemCD)
                    else:
                        return
            else:
                RequestState.sent(state)
            if item.isInInventory:
                Waiting.show('applyModule')
                result = yield getInstallerProcessor(vehicle, item, conflictedEqs=conflictedEqs).request()
                if result and result.auxData:
                    for m in result.auxData:
                        SystemMessages.g_instance.pushI18nMessage(m.userMsg, type=m.sysMsgType)

                if result and len(result.userMsg):
                    SystemMessages.g_instance.pushI18nMessage(result.userMsg, type=result.sysMsgType)
                vehicle = result.success and item.itemTypeID in (GUI_ITEM_TYPE.TURRET, GUI_ITEM_TYPE.GUN) and g_itemsCache.items.getItemByCD(vehicle.intCD)
                yield tryToLoadDefaultShellsLayout(vehicle)
            Waiting.hide('applyModule')
        RequestState.received(state)
        yield lambda callback = None: callback
        return
예제 #7
0
파일: unlock.py 프로젝트: webiumsk/WoT
 def _request(self, callback):
     RequestState.sent('unlock')
     BigWorld.player().stats.unlock(self.vehTypeCD, self.unlockIdx, lambda code: self._response(code, callback))
예제 #8
0
 def _doUnlockItem(self, unlockCD, vehCD, unlockIdx, xpCost, result):
     if result and self._validateItem2Unlock(unlockCD, vehCD, unlockIdx, xpCost):
         costCtx = self._getXPCostCtx(self._data.getVehXP(vehCD), xpCost)
         Waiting.show('research')
         RequestState.sent('unlock')
         BigWorld.player().stats.unlock(vehCD, unlockIdx, callback=partial(self.__cb_onUnlock, unlockCD, costCtx))