예제 #1
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()
예제 #2
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()
예제 #3
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')
예제 #4
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')
예제 #5
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')
예제 #6
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')