diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-08-23 20:29:07 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-08-23 20:29:07 +0200 |
commit | 7b1c251fcb085dc37de439ea1137373f1905d82e (patch) | |
tree | 32e3f2cd4367507726af6d0172e9621a37dff576 /resources/js/formula.js | |
parent | 4dd1a344c6474087a3f8782dd54f5c7b4acc67ed (diff) |
areas and capture and more
Diffstat (limited to 'resources/js/formula.js')
-rw-r--r-- | resources/js/formula.js | 82 |
1 files changed, 79 insertions, 3 deletions
diff --git a/resources/js/formula.js b/resources/js/formula.js index 7223cb8..f28ce2d 100644 --- a/resources/js/formula.js +++ b/resources/js/formula.js @@ -95,13 +95,89 @@ function calculateAwardedExperience (opposingMonster, participants) { /** * @param {Monster} opposingMonster * - * @returns {number[]} + * @returns {number} */ function calculateAwardedMoney (opposingMonster) { let money = opposingMonster.level * opposingMonster.moneyModifier; - const baseDecimalDiff = 2 - DB.currencies.map[Memory.state.Settings.currency].decimals; - money = money * Math.pow(10, baseDecimalDiff); + money = convertToCurrencyBase(money); return money; } + +/** + * @param {Monster} playerMonster + * @param {Monster} opposingMonster + * @param {Item} ball + * + * @returns {boolean} + */ +function checkCapture (playerMonster, opposingMonster, ball) { + const MAX_CATCH_RATE = 255; + const MAX_ATTEMPT_RATE = 65536; + const ATTEMPT_CONSTANT = 524325; + + // status effect + let STATUS_MODIFER = 1.0; + if (opposingMonster.statusEffect && opposingMonster.statusEffect.category === 'negative') { + STATUS_MODIFER = 1.2; + } + + // ball + let BALL_MODIFIER = 1.0; + if (ball.slug === 'tuxeball_wood') { + if (opposingMonster.types.includes(ElementType.wood)) { + BALL_MODIFIER = 1.5 + } else { + BALL_MODIFIER = 0.2; + } + } + else if (ball.slug === 'tuxeball_fire') { + if (opposingMonster.types.includes(ElementType.fire)) { + BALL_MODIFIER = 1.5 + } else { + BALL_MODIFIER = 0.2; + } + } + else if (ball.slug === 'tuxeball_earth') { + if (opposingMonster.types.includes(ElementType.earth)) { + BALL_MODIFIER = 1.5 + } else { + BALL_MODIFIER = 0.2; + } + } + else if (ball.slug === 'tuxeball_metal') { + if (opposingMonster.types.includes(ElementType.metal)) { + BALL_MODIFIER = 1.5 + } else { + BALL_MODIFIER = 0.2; + } + } + else if (ball.slug === 'tuxeball_water') { + if (opposingMonster.types.includes(ElementType.water)) { + BALL_MODIFIER = 1.5 + } else { + BALL_MODIFIER = 0.2; + } + } + + // calculate + const catchCheck = Math.max( + (3 * opposingMonster.hp - 2 * playerMonster.hp) + * opposingMonster.catch_rate + * STATUS_MODIFER + * BALL_MODIFIER + / (3 * opposingMonster.hp), + 1 + ); + + let attemptCheck = ATTEMPT_CONSTANT / ( + Math.sqrt(Math.sqrt(MAX_CATCH_RATE / catchCheck)) * 8 + ) + + const catchResistance = Math.random() * (opposingMonster.upper_catch_resistance - opposingMonster.lower_catch_resistance) + opposingMonster.lower_catch_resistance; + + attemptCheck = attemptCheck * catchResistance; + + return Math.random() * MAX_ATTEMPT_RATE > Math.round(attemptCheck); +} |