Created
August 16, 2023 14:09
-
-
Save devcem/51b3fd3b8ddde46815549411469a436e to your computer and use it in GitHub Desktop.
Balance.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calculateEnemyHealth(bowDamage, killCount, upgradeLevel, stage) { | |
// Base multiplier for the relationship between bow damage and enemy health | |
const baseMultiplier = 2; | |
// Define a scaling factor that will increase the difficulty based on kill count | |
const killScalingFactor = 1 + killCount * 0.05; // 5% increase in difficulty per kill | |
// Define a factor that reduces difficulty based on upgrade level | |
// This will apply a 10% decrease in difficulty per upgrade | |
let upgradeScalingFactor = 1 - upgradeLevel * 0.10; // 10% decrease in difficulty per upgrade | |
// Apply an additional reduction for every 3rd upgrade level | |
if (upgradeLevel % 3 === 0) { | |
const specialUpgradeReduction = 0.15; // Additional 15% reduction | |
upgradeScalingFactor *= (1 - specialUpgradeReduction); | |
} | |
// Define a factor for exponential stage increase | |
const stageScalingFactor = Math.pow(1.5, stage); | |
// Calculate enemy health, incorporating all factors | |
const enemyHealth = bowDamage * baseMultiplier * killScalingFactor * upgradeScalingFactor * stageScalingFactor; | |
return Math.round(enemyHealth); // Round the result to the nearest whole number | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment