From 4200c9d09dd21d0d86daf76c8ce5f2e12a89f82e Mon Sep 17 00:00:00 2001 From: Tekaoh <45337851+Tekaoh@users.noreply.github.com> Date: Wed, 15 Apr 2020 16:38:00 -0400 Subject: [PATCH] Future prices for minimum and maximum columns Closes mikebryant/ac-nh-turnip-prices#43 --- js/predictions.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/js/predictions.js b/js/predictions.js index f1410a6..01595b9 100644 --- a/js/predictions.js +++ b/js/predictions.js @@ -570,8 +570,15 @@ function analyze_possibilities(sell_prices, first_buy, previous_pattern) { var weekMins = []; var weekMaxes = []; for (let day of poss.prices.slice(2)) { - weekMins.push(day.min); - weekMaxes.push(day.max); + // Check for a future date by checking for a range of prices + if(day.min !== day.max){ + weekMins.push(day.min); + weekMaxes.push(day.max); + } else { + // If we find a set price after one or more ranged prices, the user has missed a day. Discard that data and start again. + weekMins = []; + weekMaxes = []; + } } poss.weekGuaranteedMinimum = Math.max(...weekMins); poss.weekMax = Math.max(...weekMaxes); @@ -609,7 +616,7 @@ function analyze_possibilities(sell_prices, first_buy, previous_pattern) { pattern_number: 4, prices: global_min_max, weekGuaranteedMinimum: Math.min(...generated_possibilities.map(poss => poss.weekGuaranteedMinimum)), - weekMax: Math.max(...generated_possibilities.map(poss => poss.weekMax)), + weekMax: Math.max(...generated_possibilities.map(poss => poss.weekMax)) }); return generated_possibilities;