Difference between revisions of "Widget:AdventurerPageStatsCalculatorTest"

From Dragalia Lost Wiki
Jump to navigation Jump to search
imported>Elaeagnifolia
imported>Elaeagnifolia
 
(18 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
const MIN_LEVEL = 1;
 
const MIN_LEVEL = 1;
 
const MAX_LEVEL = 80;
 
const MAX_LEVEL = 80;
 +
const SPIRAL_MAX_LEVEL = 100;
 
const MIN_HP = [<!--{$minHp3}-->,<!--{$minHp4}-->,<!--{$minHp5}-->];
 
const MIN_HP = [<!--{$minHp3}-->,<!--{$minHp4}-->,<!--{$minHp5}-->];
 
const MAX_HP = <!--{$maxHp}-->;
 
const MAX_HP = <!--{$maxHp}-->;
 +
const ADD_MAX_HP = <!--{$addMaxHp1}-->;
 
const MIN_STR = [<!--{$minStr3}-->,<!--{$minStr4}-->,<!--{$minStr5}-->];
 
const MIN_STR = [<!--{$minStr3}-->,<!--{$minStr4}-->,<!--{$minStr5}-->];
 
const MAX_STR = <!--{$maxStr}-->;
 
const MAX_STR = <!--{$maxStr}-->;
const NAT_RARITY = <!--{$rarity}-->;;
+
const ADD_MAX_STR = <!--{$addMaxAtk1}-->;
 +
const NAT_RARITY = <!--{$rarity}-->;
 +
const HAS_SPIRAL_LIMIT_BREAK = <!--{$maxLimitBreakCount}--> == 5;
  
 
// Load modules, init, etc.
 
// Load modules, init, etc.
Line 17: Line 21:
 
// Initialize the empty divs with content
 
// Initialize the empty divs with content
 
function init() {
 
function init() {
 +
  let maxLevel = MAX_LEVEL;
 +
  if (HAS_SPIRAL_LIMIT_BREAK) {
 +
    maxLevel = SPIRAL_MAX_LEVEL;
 +
  }
 +
 +
  // Create the rarity radio buttons
 
   if (NAT_RARITY == 3) {
 
   if (NAT_RARITY == 3) {
 
     document.getElementById("adv-rarity-input-3").innerHTML = '<input type="radio" value=3 name="rarity" oninput="calcStats()"><label for="adv-rarity-input-3">3★</label>';
 
     document.getElementById("adv-rarity-input-3").innerHTML = '<input type="radio" value=3 name="rarity" oninput="calcStats()"><label for="adv-rarity-input-3">3★</label>';
Line 24: Line 34:
 
   }
 
   }
 
   document.getElementById("adv-rarity-input-5").innerHTML = '<input type="radio" value=5 name="rarity" oninput="calcStats()" checked=1><label for="adv-rarity-input-5">5★</label>';
 
   document.getElementById("adv-rarity-input-5").innerHTML = '<input type="radio" value=5 name="rarity" oninput="calcStats()" checked=1><label for="adv-rarity-input-5">5★</label>';
   document.getElementById("adv-level-input").innerHTML = '<label for="adv-level-input-field" style="font-weight:bold;">Level</label><input type="number" id="adv-level-input-field" value=80 min=1 max=80 style="width:40px; text-align:center; margin-left:5px;" oninput="calcStats()">';
+
   document.getElementById("adv-level-input").innerHTML = '<label for="adv-level-input-field" style="font-weight:bold;">Level</label><input type="number" id="adv-level-input-field" value=' + maxLevel + ' min=1 max=' + maxLevel + ' style="width:40px; text-align:center; margin-left:5px;" oninput="calcStats()">';
 
}
 
}
  
Line 30: Line 40:
 
function calcStats() {
 
function calcStats() {
 
   // Get the level and rarity
 
   // Get the level and rarity
   var levelInput = document.getElementById('adv-level-input-field');
+
   let levelInput = document.getElementById('adv-level-input-field');
   var level = levelInput.value;
+
   let level = levelInput.value;
   var rarity = document.querySelector('input[name = "rarity"]:checked').value;
+
   let rarity = document.querySelector('input[name = "rarity"]:checked').value;
  
 
   // Manually set the level cap if we're dealing with a lower rarity
 
   // Manually set the level cap if we're dealing with a lower rarity
Line 50: Line 60:
 
     case "5":
 
     case "5":
 
       if (level > MAX_LEVEL) {
 
       if (level > MAX_LEVEL) {
         level = MAX_LEVEL;
+
         if (HAS_SPIRAL_LIMIT_BREAK) {
        levelInput.value = MAX_LEVEL;
+
          if (level > SPIRAL_MAX_LEVEL) {
 +
            level = SPIRAL_MAX_LEVEL;
 +
            levelInput.value = SPIRAL_MAX_LEVEL;
 +
          }
 +
        } else {
 +
          level = MAX_LEVEL;
 +
          levelInput.value = MAX_LEVEL;
 +
        }
 
       }
 
       }
 
   }
 
   }
Line 57: Line 74:
 
   // Validate the level and rarity before calculating HP and Str
 
   // Validate the level and rarity before calculating HP and Str
 
   if(validateLevel(level) && validateRarity(rarity)) {
 
   if(validateLevel(level) && validateRarity(rarity)) {
     setHP(calculateHP(level, rarity), level)
+
     if (HAS_SPIRAL_LIMIT_BREAK) {
    setStr(calculateStr(level, rarity), level)
+
      // Level 80+ after Mana Spiral is unlocked has a different calc
 +
      setHP(calculateSpiralHP(level, rarity), level);
 +
      setStr(calculateSpiralStr(level, rarity), level);
 +
    } else {
 +
      setHP(calculateHP(level, rarity), level);
 +
      setStr(calculateStr(level, rarity), level);
 +
    }
 
   } else {
 
   } else {
 
     setHP("-");
 
     setHP("-");
Line 103: Line 126:
 
// Calculate the HP
 
// Calculate the HP
 
function calculateHP(level, rarity) {
 
function calculateHP(level, rarity) {
   var levelDiff = MAX_LEVEL - MIN_LEVEL;
+
   let levelDiff = MAX_LEVEL - MIN_LEVEL;
   var steps = (MAX_HP - MIN_HP[2]) / levelDiff;
+
   let steps = (MAX_HP - MIN_HP[2]) / levelDiff;
   var statGain = (level-1) * steps;
+
   let statGain = (level-1) * steps;
 
   return Math.ceil(MIN_HP[rarity-3] + statGain);
 
   return Math.ceil(MIN_HP[rarity-3] + statGain);
 
}
 
}
Line 111: Line 134:
 
// Calculate the Str
 
// Calculate the Str
 
function calculateStr(level, rarity) {
 
function calculateStr(level, rarity) {
   var levelDiff = MAX_LEVEL - MIN_LEVEL;
+
   let levelDiff = MAX_LEVEL - MIN_LEVEL;
   var steps = (MAX_STR - MIN_STR[2]) / levelDiff;
+
   let steps = (MAX_STR - MIN_STR[2]) / levelDiff;
   var statGain = (level-1) * steps;
+
   let statGain = (level-1) * steps;
 
   return Math.ceil(MIN_STR[rarity-3] + statGain);
 
   return Math.ceil(MIN_STR[rarity-3] + statGain);
 +
}
 +
 +
// Calculate the HP for Level 80+
 +
function calculateSpiralHP(level, rarity) {
 +
  let levelDiff = SPIRAL_MAX_LEVEL - MAX_LEVEL;
 +
  let steps = (ADD_MAX_HP - MAX_HP) / levelDiff;
 +
  let statGain = (level-80) * steps;
 +
  return Math.ceil(MAX_HP + statGain);
 +
}
 +
 +
// Calculate the Str for Level 80+
 +
function calculateSpiralStr(level, rarity) {
 +
  let levelDiff = SPIRAL_MAX_LEVEL - MAX_LEVEL;
 +
  let steps = (ADD_MAX_STR - MAX_STR) / levelDiff;
 +
  let statGain = (level-80) * steps;
 +
  return Math.ceil(MAX_STR + statGain);
 
}
 
}
 
</script>
 
</script>

Latest revision as of 23:47, 26 December 2019