Exemplo n.º 1
0
def _getUniqueVehicleSellConfirmator(vehicle, lobbyContext=None):
    """
    return confirmation plugin for unique vehicle
    :param vehicle: <Vehicle>
    :return: <MessageConfirmator>
    """
    sellForGold = vehicle.getSellPrice(preferred=True).getCurrency(
        byWeight=True) == Currency.GOLD
    if lobbyContext is not None and lobbyContext.getServerSettings(
    ).isVehicleRestoreEnabled(
    ) and not sellForGold and not vehicle.isUnrecoverable:
        if vehicle.isRecentlyRestored():
            return plugins.MessageConfirmator(
                'vehicleSell/restoreCooldown',
                ctx={
                    'cooldown':
                    formatTime(
                        vehicle.restoreInfo.getRestoreCooldownTimeLeft(),
                        time_utils.ONE_DAY)
                },
                isEnabled=vehicle.isUnique)
        if vehicle.isPurchased:
            return plugins.MessageConfirmator('vehicleSell/restoreUnlimited',
                                              isEnabled=vehicle.isUnique)
    if vehicle.isCrewLocked:
        dialogI18n = 'vehicleSell/unique/crewLocked'
    else:
        dialogI18n = 'vehicleSell/unique'
    return plugins.MessageConfirmator(dialogI18n, isEnabled=vehicle.isUnique)
Exemplo n.º 2
0
def _getUniqueVehicleSellConfirmator(vehicle):
    """
    return confirmation plugin for unique vehicle
    :param vehicle: <Vehicle>
    :return: <MessageConfirmator>
    """
    if g_lobbyContext.getServerSettings().isVehicleRestoreEnabled(
    ) and not vehicle.sellForGold and not vehicle.isUnrecoverable:
        if vehicle.isRecentlyRestored():
            return plugins.MessageConfirmator(
                'vehicleSell/restoreCooldown',
                ctx={
                    'cooldown':
                    formatTime(
                        vehicle.restoreInfo.getRestoreCooldownTimeLeft(),
                        time_utils.ONE_DAY)
                },
                isEnabled=vehicle.isUnique)
        if vehicle.isPurchased:
            return plugins.MessageConfirmator('vehicleSell/restoreUnlimited',
                                              isEnabled=vehicle.isUnique)
    return plugins.MessageConfirmator('vehicleSell/unique',
                                      isEnabled=vehicle.isUnique)
Exemplo n.º 3
0
def _getUniqueVehicleSellConfirmator(vehicle, lobbyContext=None, itemsCache=None):
    info = vehicle.restoreInfo
    if info is None and itemsCache and hasNationGroup(vehicle.intCD):
        mainVehTypeCD = getMainVehicleInNationGroup(getNationGroupID(vehicle.intCD))
        restoreData = itemsCache.items.recycleBin.vehiclesBuffer.get(mainVehTypeCD)
        if restoreData:
            restoreType, changedAt = restoreData
            restoreCfg = itemsCache.items.shop.vehiclesRestoreConfig
            info = VehicleRestoreInfo(restoreType, changedAt, restoreCfg.restoreDuration, restoreCfg.restoreCooldown)
    sellForGold = vehicle.getSellPrice(preferred=True).getCurrency(byWeight=True) == Currency.GOLD
    if lobbyContext is not None and lobbyContext.getServerSettings().isVehicleRestoreEnabled():
        if not sellForGold and not vehicle.isUnrecoverable:
            if info is not None and vehicle.isPurchased and info.isInCooldown():
                return proc_plugs.MessageConfirmator('vehicleSell/restoreCooldown', ctx={'cooldown': formatTime(info.getRestoreCooldownTimeLeft(), time_utils.ONE_DAY)}, isEnabled=vehicle.isUnique)
            if vehicle.isPurchased:
                return proc_plugs.MessageConfirmator('vehicleSell/restoreUnlimited', isEnabled=vehicle.isUnique)
        dialogI18n = vehicle.isCrewLocked and 'vehicleSell/unique/crewLocked'
    else:
        dialogI18n = 'vehicleSell/unique'
    return proc_plugs.MessageConfirmator(dialogI18n, isEnabled=vehicle.isUnique)
Exemplo n.º 4
0
def _getUniqueVehicleSellConfirmator(vehicle):
    """
    return confirmation plugin for unique vehicle
    :param vehicle: <Vehicle>
    :return: <MessageConfirmator>
    """
    if g_lobbyContext.getServerSettings().isVehicleRestoreEnabled() and not vehicle.sellForGold and not vehicle.isUnrecoverable:
        if vehicle.isRecentlyRestored():
            return plugins.MessageConfirmator('vehicleSell/restoreCooldown', ctx={'cooldown': formatTime(vehicle.restoreInfo.getRestoreCooldownTimeLeft(), time_utils.ONE_DAY)}, isEnabled=vehicle.isUnique)
        if vehicle.isPurchased:
            return plugins.MessageConfirmator('vehicleSell/restoreUnlimited', isEnabled=vehicle.isUnique)
    return plugins.MessageConfirmator('vehicleSell/unique', isEnabled=vehicle.isUnique)