Skip to content

Commit

Permalink
Merge pull request ckalgos#63 from BScreen/main
Browse files Browse the repository at this point in the history
input range for futbin sale price
  • Loading branch information
ckalgos authored Jan 8, 2022
2 parents d869ee9 + dd30ca9 commit c07b84f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
15 changes: 15 additions & 0 deletions app/utils/commonUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions app/utils/sellUtil.js
Original file line number Diff line number Diff line change
@@ -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()) {
Expand Down
5 changes: 3 additions & 2 deletions app/utils/uiUtils/generateTextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -36,7 +37,7 @@ export const generateTextInput = (
</div>
<div class="buttonInfo">
<div class="inputBox">
<input type="${type}" class="numericInput" id='${id[key]}' placeholder=${placeholder}>
<input pattern="${pattern}" type="${type}" class="numericInput" id='${id[key]}' placeholder=${placeholder}>
</div>
</div>
</div>`;
Expand Down
7 changes: 5 additions & 2 deletions app/view/EnhancerSettingsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit c07b84f

Please sign in to comment.