Skip to content
Permalink
Browse files

bugfix booster estimate accounts for owned wildcards

  • Loading branch information...
lusbenjamin committed Jul 19, 2019
1 parent d0b4893 commit 231ce368287970fb297da36f9115d1f3d15cc166
Showing with 12 additions and 4 deletions.
  1. +12 −4 shared/util.js
@@ -367,18 +367,26 @@ function getCardsMissingCount(deck, grpid) {

//
exports.getBoosterCountEstimate = getBoosterCountEstimate;
function getBoosterCountEstimate(wildcards) {
function getBoosterCountEstimate(neededWildcards) {
let boosterCost = 0;
let boosterEstimates = {
const boosterEstimates = {
common: 3.36,
uncommon: 2.6,
rare: 5.72,
mythic: 13.24
};
const ownedWildcards = {
common: pd.economy.wcCommon,
uncommon: pd.economy.wcUncommon,
rare: pd.economy.wcRare,
mythic: pd.economy.wcMythic
};
for (let rarity in boosterEstimates) {
// accept either short or long form of keys in argument
let shortForm = rarity[0]; // grab first letter
let missing = wildcards[rarity] || wildcards[shortForm] || 0;
const shortForm = rarity[0]; // grab first letter
const needed = neededWildcards[rarity] || neededWildcards[shortForm] || 0;
const owned = ownedWildcards[rarity] || ownedWildcards[shortForm] || 0;
const missing = Math.max(0, needed - owned);
boosterCost = Math.max(boosterCost, boosterEstimates[rarity] * missing);
}
return Math.round(boosterCost);

0 comments on commit 231ce36

Please sign in to comment.
You can’t perform that action at this time.