Exemple #1
0
 def request4Install(self, itemCD):
     if RequestState.inProcess('install'):
         SystemMessages.pushI18nMessage(
             '#system_messages:inventory/item/equip_in_processing',
             type=SystemMessages.SM_TYPE.Warning)
     itemCD = int(itemCD)
     self.buyAndInstallItem(itemCD, 'install', inInventory=True)
Exemple #2
0
 def request4Buy(self, itemCD):
     itemCD = int(itemCD)
     if getTypeOfCompactDescr(itemCD) == GUI_ITEM_TYPE.VEHICLE:
         self.buyVehicle(itemCD)
     else:
         if RequestState.inProcess('buyAndInstall'):
             SystemMessages.pushI18nMessage('#system_messages:shop/item/buy_and_equip_in_processing', type=SystemMessages.SM_TYPE.Warning)
         self.buyAndInstallItem(itemCD, 'buyAndInstall')
Exemple #3
0
 def request4Buy(self, itemCD):
     itemCD = int(itemCD)
     itemTypeID, _, _ = vehicles.parseIntCompactDescr(itemCD)
     if itemTypeID == _VEHICLE:
         self.buyVehicle(itemCD)
     else:
         if RequestState.inProcess('buyAndInstall'):
             SystemMessages.pushI18nMessage(
                 '#system_messages:shop/item/buy_and_equip_in_processing',
                 type=SystemMessages.SM_TYPE.Warning)
         self.buyAndInstallItem(itemCD, 'buyAndInstall')
 def _validateItem2Unlock(self, unlockCD, vehCD, unlockIdx, xpCost):
     itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(vehCD)
     if itemTypeID != _VEHICLE:
         LOG_ERROR('Int compact descriptor is not for vehicle', vehCD)
         return False
     if not self._data.isUnlocked(vehCD):
         LOG_ERROR('Vehicle is not unlocked', unlockCD, vehCD)
         return False
     if self._data.isUnlocked(unlockCD):
         self._showAlreadyUnlockedMsg(vehCD)
         return False
     if not self._data.isNext2Unlock(unlockCD):
         LOG_ERROR('Required items are not unlocked', unlockCD, vehCD)
         return False
     if max(self._data._accFreeXP, 0) + self._data.getVehXP(vehCD) < xpCost:
         LOG_ERROR('XP not enough for unlock', vehCD, unlockIdx, xpCost)
         return False
     if RequestState.inProcess('unlock'):
         SystemMessages.pushI18nMessage('#system_messages:unlocks/in_processing', type=SystemMessages.SM_TYPE.Warning)
         return False
     return True
Exemple #5
0
 def _validateItem2Unlock(self, unlockCD, vehCD, unlockIdx, xpCost):
     itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(vehCD)
     if itemTypeID != _VEHICLE:
         LOG_ERROR('Int compact descriptor is not for vehicle', vehCD)
         return False
     if not self._data.isUnlocked(vehCD):
         LOG_ERROR('Vehicle is not unlocked', unlockCD, vehCD)
         return False
     if self._data.isUnlocked(unlockCD):
         self._showAlreadyUnlockedMsg(vehCD)
         return False
     if not self._data.isNext2Unlock(unlockCD):
         LOG_ERROR('Required items are not unlocked', unlockCD, vehCD)
         return False
     if max(self._data._accFreeXP, 0) + self._data.getVehXP(vehCD) < xpCost:
         LOG_ERROR('XP not enough for unlock', vehCD, unlockIdx, xpCost)
         return False
     if RequestState.inProcess('unlock'):
         SystemMessages.pushI18nMessage(
             '#system_messages:unlocks/in_processing',
             type=SystemMessages.SM_TYPE.Warning)
         return False
     return True
Exemple #6
0
 def _validate(self):
     unlockCD, vehCD, unlockIdx, xpCost = self._unlockCtx[:]
     itemGetter = g_itemsCache.items.getItemByCD
     vehicle = itemGetter(vehCD)
     item = itemGetter(unlockCD)
     if vehicle.itemTypeID != GUI_ITEM_TYPE.VEHICLE:
         LOG_ERROR('Int compact descriptor is not for vehicle', vehCD)
         return plugins.makeError('vehicle_invalid')
     if not vehicle.isUnlocked:
         LOG_ERROR('Vehicle is not unlocked', unlockCD, vehCD)
         return plugins.makeError('vehicle_locked')
     if item.isUnlocked:
         return plugins.makeError('already_unlocked')
     stats = g_itemsCache.items.stats
     unlockStats = UnlockStats(stats.unlocks, stats.vehiclesXPs, stats.freeXP)
     if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE:
         result, _ = g_techTreeDP.isNext2Unlock(unlockCD, **unlockStats._asdict())
         if not result:
             LOG_ERROR('Required items are not unlocked', self._unlockCtx)
             return plugins.makeError('required_locked')
     else:
         _xpCost, _itemCD, required = vehicle.getUnlocksDescr(self._unlockCtx.unlockIdx)
         if _itemCD != unlockCD:
             LOG_ERROR('Item is invalid', self._unlockCtx)
             return plugins.makeError('item_invalid')
         if _xpCost != xpCost:
             LOG_ERROR('XP cost is invalid', self._unlockCtx)
             return plugins.makeError('xp_cost_invalid')
         if not unlockStats.isSeqUnlocked(required):
             LOG_ERROR('Required items are not unlocked', self._unlockCtx)
             return plugins.makeError('required_locked')
     if unlockStats.getVehTotalXP(vehCD) < xpCost:
         LOG_ERROR('XP not enough for unlock', self._unlockCtx)
         return plugins.makeError()
     if RequestState.inProcess('unlock'):
         return plugins.makeError('in_processing')
     return plugins.makeSuccess()
Exemple #7
0
 def request4Install(self, itemCD):
     if RequestState.inProcess('install'):
         SystemMessages.pushI18nMessage('#system_messages:inventory/item/equip_in_processing', type=SystemMessages.SM_TYPE.Warning)
     itemCD = int(itemCD)
     self.buyAndInstallItem(itemCD, 'install', inInventory=True)
Exemple #8
0
 def doAction(self):
     if RequestState.inProcess('buyAndInstall'):
         SystemMessages.pushI18nMessage('#system_messages:shop/item/buy_and_equip_in_processing', type=SystemMessages.SM_TYPE.Warning)
     self.buyAndInstallItem(self._itemCD, self._rootCD, 'buyAndInstall')
Exemple #9
0
 def doAction(self):
     if RequestState.inProcess('install'):
         SystemMessages.pushI18nMessage('#system_messages:inventory/item/equip_in_processing', type=SystemMessages.SM_TYPE.Warning)
     self.installItem(self._itemCD, self._rootCD, 'install')