Esempio n. 1
0
 def __init__(self, tankman, role, vehTypeCompDescr):
     self.__roleIdx = SKILL_INDICES[role]
     self.__vehTypeCompDescr = vehTypeCompDescr
     self.__changeRoleCost = g_itemsCache.items.shop.changeRoleCost
     vehicle = g_itemsCache.items.getItemByCD(self.__vehTypeCompDescr)
     super(TankmanChangeRole, self).__init__(tankman, [plugins.MessageConfirmator('tankmanChageRole/unknownVehicle', ctx={'tankname': vehicle.userName}, isEnabled=not vehicle.isInInventory),
      plugins.VehicleValidator(vehicle, False),
      plugins.VehicleRoleValidator(vehicle, role),
      plugins.MoneyValidator(Money(gold=self.__changeRoleCost))])
Esempio n. 2
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