Skip to content

Commit dd30ca9

Browse files
committed
input range for futbin sale price
1 parent d869ee9 commit dd30ca9

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

app/utils/commonUtil.js

+15
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,24 @@ export const convertToSeconds = (val) => {
5353
return 0;
5454
};
5555

56+
export const getRandNumberInRange = (range) => {
57+
const rangeVal = getRangeValue(range);
58+
if (rangeVal.length >= 2) {
59+
return getRandNum(rangeVal[0], rangeVal[1]);
60+
}
61+
return rangeVal[0] || 0;
62+
};
63+
5664
export const getRandNum = (min, max) =>
5765
Math.round(Math.random() * (max - min) + min);
5866

67+
export const getRangeValue = (range) => {
68+
if (range) {
69+
return (range + "").split("-").map((a) => parseInt(a));
70+
}
71+
return [];
72+
};
73+
5974
export const showLoader = () => {
6075
$(".ut-click-shield").addClass("showing");
6176
$(".loaderIcon ").css("display", "block");

app/utils/sellUtil.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { getValue } from "../services/repository";
2-
import { convertToSeconds, getRandWaitTime, wait } from "./commonUtil";
2+
import { convertToSeconds, getRandWaitTime, wait, getRandNumberInRange } from "./commonUtil";
33
import { getBuyBidPrice, getSellBidPrice, roundOffPrice } from "./priceUtil";
44

55
export const listForPrice = async (sellPrice, player, futBinPercent) => {
66
sellPrice = parseInt(sellPrice.replace(/[,.]/g, ""));
77
await getPriceLimits(player);
88
if (sellPrice) {
9-
futBinPercent = futBinPercent || 100;
9+
futBinPercent = getRandNumberInRange(futBinPercent) || 100;
1010
const duration = getValue("EnhancerSettings")["idFutBinDuration"] || "1H";
1111
let calculatedPrice = (sellPrice * futBinPercent) / 100;
1212
if (player.hasPriceLimits()) {

app/utils/uiUtils/generateTextInput.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export const generateTextInput = (
1515
info,
1616
value = null,
1717
type = "number",
18-
additionalClasses = "settings-field"
18+
additionalClasses = "settings-field",
19+
pattern = ".*",
1920
) => {
2021
const key = Object.keys(id)[0];
2122
updateCache(key, value || placeholder, type);
@@ -36,7 +37,7 @@ export const generateTextInput = (
3637
</div>
3738
<div class="buttonInfo">
3839
<div class="inputBox">
39-
<input type="${type}" class="numericInput" id='${id[key]}' placeholder=${placeholder}>
40+
<input pattern="${pattern}" type="${type}" class="numericInput" id='${id[key]}' placeholder=${placeholder}>
4041
</div>
4142
</div>
4243
</div>`;

app/view/EnhancerSettingsView.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ EnhancerSettingsView.prototype._generate = function _generate() {
6767
)}
6868
${generateTextInput(
6969
"FUTBIN Sale Percent",
70-
95,
70+
"95-100",
7171
{ idFutBinPercent },
7272
"Sale Price percent for Relist FUTBIN",
73-
enhancerSetting["idFutBinPercent"]
73+
enhancerSetting["idFutBinPercent"],
74+
"text",
75+
"settings-field",
76+
"\\d+-\\d+$"
7477
)}
7578
${generateTextInput(
7679
"Rating",

0 commit comments

Comments
 (0)