diff --git a/app/utils/commonUtil.js b/app/utils/commonUtil.js index 8a6c304..2b1cc6e 100644 --- a/app/utils/commonUtil.js +++ b/app/utils/commonUtil.js @@ -53,9 +53,24 @@ export const convertToSeconds = (val) => { return 0; }; +export const getRandNumberInRange = (range) => { + const rangeVal = getRangeValue(range); + if (rangeVal.length >= 2) { + return getRandNum(rangeVal[0], rangeVal[1]); + } + return rangeVal[0] || 0; +}; + export const getRandNum = (min, max) => Math.round(Math.random() * (max - min) + min); +export const getRangeValue = (range) => { + if (range) { + return (range + "").split("-").map((a) => parseInt(a)); + } + return []; +}; + export const showLoader = () => { $(".ut-click-shield").addClass("showing"); $(".loaderIcon ").css("display", "block"); diff --git a/app/utils/sellUtil.js b/app/utils/sellUtil.js index 0b1c16c..c7d2422 100644 --- a/app/utils/sellUtil.js +++ b/app/utils/sellUtil.js @@ -1,12 +1,12 @@ import { getValue } from "../services/repository"; -import { convertToSeconds, getRandWaitTime, wait } from "./commonUtil"; +import { convertToSeconds, getRandWaitTime, wait, getRandNumberInRange } from "./commonUtil"; import { getBuyBidPrice, getSellBidPrice, roundOffPrice } from "./priceUtil"; export const listForPrice = async (sellPrice, player, futBinPercent) => { sellPrice = parseInt(sellPrice.replace(/[,.]/g, "")); await getPriceLimits(player); if (sellPrice) { - futBinPercent = futBinPercent || 100; + futBinPercent = getRandNumberInRange(futBinPercent) || 100; const duration = getValue("EnhancerSettings")["idFutBinDuration"] || "1H"; let calculatedPrice = (sellPrice * futBinPercent) / 100; if (player.hasPriceLimits()) { diff --git a/app/utils/uiUtils/generateTextInput.js b/app/utils/uiUtils/generateTextInput.js index 8ee6b1b..97bb81d 100644 --- a/app/utils/uiUtils/generateTextInput.js +++ b/app/utils/uiUtils/generateTextInput.js @@ -15,7 +15,8 @@ export const generateTextInput = ( info, value = null, type = "number", - additionalClasses = "settings-field" + additionalClasses = "settings-field", + pattern = ".*", ) => { const key = Object.keys(id)[0]; updateCache(key, value || placeholder, type); @@ -36,7 +37,7 @@ export const generateTextInput = (
- +
`; diff --git a/app/view/EnhancerSettingsView.js b/app/view/EnhancerSettingsView.js index 86116df..61ec0e1 100644 --- a/app/view/EnhancerSettingsView.js +++ b/app/view/EnhancerSettingsView.js @@ -67,10 +67,13 @@ EnhancerSettingsView.prototype._generate = function _generate() { )} ${generateTextInput( "FUTBIN Sale Percent", - 95, + "95-100", { idFutBinPercent }, "Sale Price percent for Relist FUTBIN", - enhancerSetting["idFutBinPercent"] + enhancerSetting["idFutBinPercent"], + "text", + "settings-field", + "\\d+-\\d+$" )} ${generateTextInput( "Rating",