Esempio n. 1
0
 def __init__(self, tankman, vehicle, tmanCostTypeIdx):
     hasUndistributedExp = False
     isGoldPrice = tmanCostTypeIdx == 2
     if not isGoldPrice:
         canLearnSkills, lastSkillLevel = tankman.newSkillCount
         hasUndistributedExp = lastSkillLevel > 0 or canLearnSkills > 1
     self.vehicle = vehicle
     self.tmanCostTypeIdx = tmanCostTypeIdx
     self.tmanCost = self._getRecruitPrice(self.tmanCostTypeIdx)
     ctx = {'tankname': vehicle.userName}
     if isGoldPrice:
         ctx['price'] = formatPrice(self.tmanCost,
                                    reverse=True,
                                    useIcon=True,
                                    useStyle=True)
     super(TankmanRetraining, self).__init__(
         tankman,
         (plugins.VehicleValidator(
             vehicle, False), plugins.TankmanLockedValidator(tankman),
          plugins.VehicleCrewLockedValidator(vehicle),
          plugins.MessageConfirmator('tankmanRetraining/knownVehicleByGold',
                                     ctx=ctx,
                                     isEnabled=vehicle.isInInventory
                                     and isGoldPrice),
          plugins.MessageConfirmator(
              'tankmanRetraining/unknownVehicleByGold',
              ctx=ctx,
              isEnabled=not vehicle.isInInventory and isGoldPrice),
          plugins.MessageConfirmator('tankmanRetraining/unknownVehicle',
                                     ctx=ctx,
                                     isEnabled=not vehicle.isInInventory
                                     and not isGoldPrice),
          plugins.MessageConfirmator('tankmanRetraining/undistributedExp',
                                     ctx=ctx,
                                     isEnabled=hasUndistributedExp)))
Esempio n. 2
0
 def __init__(self, tankman):
     self.__tankman = tankman
     restorePrice, _ = getTankmenRestoreInfo(tankman)
     super(TankmanRestore, self).__init__(tankman, (plugins.TankmanLockedValidator(tankman),
      plugins.TankmanOperationConfirmator('restoreTankman', tankman),
      plugins.BarracksSlotsValidator(berthsNeeded=1),
      plugins.MoneyValidator(restorePrice),
      plugins.IsLongDisconnectedFromCenter()))
Esempio n. 3
0
 def __init__(self, tankman, role, vehTypeCompDescr):
     self.__roleIdx = SKILL_INDICES[role]
     self.__vehTypeCompDescr = vehTypeCompDescr
     self.__changeRoleCost = self.itemsCache.items.shop.changeRoleCost
     vehicle = self.itemsCache.items.getItemByCD(self.__vehTypeCompDescr)
     super(TankmanChangeRole, self).__init__(tankman, (plugins.TankmanLockedValidator(tankman),
      plugins.VehicleCrewLockedValidator(vehicle),
      plugins.MessageConfirmator('tankmanChageRole/unknownVehicle', ctx={'tankname': vehicle.userName}, isEnabled=not vehicle.isInInventory),
      plugins.VehicleValidator(vehicle, False),
      plugins.VehicleRoleValidator(vehicle, role, tankman),
      plugins.MoneyValidator(Money(gold=self.__changeRoleCost))))
Esempio n. 4
0
 def __init__(self, tankman):
     vehicle = None
     if tankman.vehicleInvID > 0:
         vehicle = self.itemsCache.items.getVehicle(tankman.vehicleInvID)
     confirmator = plugins.TankmanOperationConfirmator('protectedDismissTankman', tankman)
     super(TankmanDismiss, self).__init__(tankman, [plugins.TankmanLockedValidator(tankman), confirmator, plugins.VehicleValidator(vehicle, isEnabled=tankman.vehicleInvID > 0)])
     deletedTankmen = self.restore.getTankmenBeingDeleted()
     if deletedTankmen and tankman.isRestorable():
         self.addPlugin(plugins.BufferOverflowConfirmator({'dismissed': tankman,
          'deleted': deletedTankmen[0]}))
     return
Esempio n. 5
0
 def __init__(self, tankman):
     raise tankman is not None or AssertionError('tankman must be given')
     self.__tankman = tankman
     restorePrice, _ = getTankmenRestoreInfo(tankman)
     super(TankmanRestore, self).__init__(
         tankman,
         (plugins.TankmanLockedValidator(tankman),
          plugins.TankmanOperationConfirmator('restoreTankman', tankman),
          plugins.BarracksSlotsValidator(berthsNeeded=1),
          plugins.MoneyValidator(restorePrice),
          plugins.IsLongDisconnectedFromCenter()))
     return
Esempio n. 6
0
 def __init__(self, tankman, vehicle, tmanCostTypeIdx):
     hasUndistributedExp = False
     if tmanCostTypeIdx != 2:
         canLearnSkills, lastSkillLevel = tankman.newSkillCount
         hasUndistributedExp = lastSkillLevel > 0 or canLearnSkills > 1
     super(TankmanRetraining, self).__init__(tankman, (plugins.VehicleValidator(vehicle, False),
      plugins.TankmanLockedValidator(tankman),
      plugins.VehicleCrewLockedValidator(vehicle),
      plugins.MessageConfirmator('tankmanRetraining/unknownVehicle', ctx={'tankname': vehicle.userName}, isEnabled=not vehicle.isInInventory),
      plugins.MessageConfirmator('tankmanRetraining/undistributedExp', ctx={}, isEnabled=hasUndistributedExp)))
     self.vehicle = vehicle
     self.tmanCostTypeIdx = tmanCostTypeIdx
     self.tmanCost = self._getRecruitPrice(self.tmanCostTypeIdx)
Esempio n. 7
0
 def __init__(self, tankman, vehicle, slot):
     super(TankmanEquip, self).__init__()
     self.tankman = tankman
     self.vehicle = vehicle
     self.slot = slot
     self.isReequip = False
     anotherTankman = dict(vehicle.crew).get(slot)
     if tankman is not None and anotherTankman is not None and anotherTankman.invID != tankman.invID:
         self.isReequip = True
     self.addPlugins((plugins.TankmanLockedValidator(tankman),
      plugins.VehicleCrewLockedValidator(vehicle),
      plugins.VehicleValidator(vehicle, False, prop={'isLocked': True}),
      plugins.ModuleValidator(tankman),
      plugins.ModuleTypeValidator(tankman, (GUI_ITEM_TYPE.TANKMAN,))))
     return
Esempio n. 8
0
 def __init__(self, tankman, role, vehTypeCompDescr):
     self.__roleIdx = SKILL_INDICES[role]
     self.__vehTypeCompDescr = vehTypeCompDescr
     self.__changeRoleCost = self.itemsCache.items.shop.changeRoleCost
     vehicle = self.itemsCache.items.getItemByCD(self.__vehTypeCompDescr)
     super(TankmanChangeRole, self).__init__(
         tankman,
         (plugins.TankmanLockedValidator(tankman),
          plugins.VehicleCrewLockedValidator(vehicle),
          plugins.MessageConfirmator('tankmanChageRole/unknownVehicle',
                                     ctx={'tankname': vehicle.userName},
                                     isEnabled=not vehicle.isInInventory),
          plugins.VehicleValidator(vehicle, False),
          plugins.VehicleRoleValidator(vehicle, role, tankman),
          plugins.MoneyValidator(Money(gold=self.__changeRoleCost))))
     self.__compensationPriceObject = None
     self.__compensationRequired = False
     lobbyContext = dependency.instance(ILobbyContext)
     equippedSkinID = tankman.skinID
     if equippedSkinID != NO_CREW_SKIN_ID and lobbyContext.getServerSettings(
     ).isCrewSkinsEnabled():
         crewSkinItem = self.itemsCache.items.getCrewSkin(equippedSkinID)
         roleMismatch = crewSkinItem.getRoleID(
         ) is not None and crewSkinItem.getRoleID() != role
         self.__compensationPriceObject = crewSkinItem.getBuyPrice()
         self.__compensationRequired = roleMismatch and not crewSkinItem.isStorageAvailable(
         )
         self.addPlugins(
             (plugins.CrewSkinsRoleChangeRemovalConfirmator(
                 'crewSkins/skinWillBeRemoved',
                 ctx={'items': [crewSkinItem]},
                 isEnabled=roleMismatch
                 and crewSkinItem.isStorageAvailable()),
              plugins.CrewSkinsCompensationDialogConfirmator(
                  'crewSkins/skinWillBeDeleted',
                  plugins.CrewSkinsRemovalCompensationDialogMeta.
                  ROLE_MISMATCH_SUFFIX,
                  ctx={
                      'price': self.__compensationPriceObject,
                      'items': [crewSkinItem]
                  },
                  isEnabled=self.__compensationRequired)))
     return
Esempio n. 9
0
 def __init__(self, tankman):
     vehicle = None
     if tankman.vehicleInvID > 0:
         vehicle = self.itemsCache.items.getVehicle(tankman.vehicleInvID)
     confirmator = plugins.TankmanOperationConfirmator(
         'protectedDismissTankman', tankman)
     super(TankmanDismiss, self).__init__(tankman, [
         plugins.TankmanLockedValidator(tankman), confirmator,
         plugins.VehicleValidator(vehicle,
                                  isEnabled=tankman.vehicleInvID > 0)
     ])
     deletedTankmen = self.restore.getTankmenBeingDeleted()
     if deletedTankmen and tankman.isRestorable():
         self.addPlugin(
             plugins.BufferOverflowConfirmator({
                 'dismissed': tankman,
                 'deleted': deletedTankmen[0]
             }))
     self.__compensationPriceObject = None
     self.__compensationRequired = False
     lobbyContext = dependency.instance(ILobbyContext)
     equippedSkinID = tankman.skinID
     if equippedSkinID != NO_CREW_SKIN_ID and lobbyContext.getServerSettings(
     ).isCrewSkinsEnabled():
         crewSkinItem = self.itemsCache.items.getCrewSkin(equippedSkinID)
         self.__compensationPriceObject = crewSkinItem.getBuyPrice()
         self.__compensationRequired = not crewSkinItem.isStorageAvailable()
         self.addPlugin(
             plugins.CrewSkinsCompensationDialogConfirmator(
                 'crewSkins/skinWillBeDeleted',
                 plugins.CrewSkinsRemovalCompensationDialogMeta.
                 OUT_OF_STORAGE_SUFFIX,
                 ctx={
                     'price': self.__compensationPriceObject,
                     'action': None,
                     'items': [crewSkinItem]
                 },
                 isEnabled=self.__compensationRequired))
     return