summaryrefslogtreecommitdiff
path: root/resources/js/formula.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/js/formula.js')
-rw-r--r--resources/js/formula.js82
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);
+}