Skip to content

Commit

Permalink
autokeys: update key price when key rate changes
Browse files Browse the repository at this point in the history
  • Loading branch information
idinium96 committed Aug 6, 2020
1 parent fe7001d commit b3aba46
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/classes/MyHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export = class MyHandler extends Handler {

private isAcceptedWithInvalidItemsOrOverstocked = false;

private OldKeyPrices: { buy: Currencies; sell: Currencies };

recentlySentMessage: UnknownDictionary<number> = {};

constructor(bot: Bot) {
Expand Down Expand Up @@ -1646,6 +1648,21 @@ export = class MyHandler extends Handler {
const userMinReftoScrap = userPure.userMinReftoScrap;
const userMaxReftoScrap = userPure.userMaxReftoScrap;

const currKeyPrice = this.bot.pricelist.getKeyPrices();

if (currKeyPrice !== this.OldKeyPrices && !this.isUsingAutoPrice) {
// When scrap adjustment activated, if key rate changes, then it will force update key prices.
this.autokeysStatus = {
isBuyingKeys: false,
isBankingKeys: false,
checkAlertOnLowPure: false,
alreadyUpdatedToBank: false,
alreadyUpdatedToBuy: false,
alreadyUpdatedToSell: false
};
this.OldKeyPrices = { buy: currKeyPrice.buy, sell: currKeyPrice.sell };
}

if (isNaN(userMinKeys) || isNaN(userMinReftoScrap) || isNaN(userMaxReftoScrap)) {
log.warn(
"You've entered a non-number on either your MINIMUM_KEYS/MINIMUM_REFINED/MAXIMUM_REFINED variables, please correct it. Autokeys is disabled until you correct it."
Expand Down

0 comments on commit b3aba46

Please sign in to comment.