Skip to content

Instantly share code, notes, and snippets.

@fenying
Last active August 12, 2019 08:11
Show Gist options
  • Save fenying/c410101ec385dbd44dcc5ad93d355e26 to your computer and use it in GitHub Desktop.
Save fenying/c410101ec385dbd44dcc5ad93d355e26 to your computer and use it in GitHub Desktop.
[MapleStory] Calculate ignore ratio of monster defense.
/**
* Calculate the ignore ratio of monster defense.
*
* @param base The base ignore ratio, (Value: 0 ~ 1)
* @param ignoreItems The items of ignore addition to be added, (Value: 0 ~ 1)
*/
function calcIgnoreMobDefnese(base, ignoreItems) {
return Math.floor(ignoreItems.reduce((p, v) => p + (1 - p) * v, base) * 100) / 100;
}
/**
* e.g. Now my ignore-ratio is 63%, If I get a new armors that add 45% and 15% ignore-ratio.
*/
console.log(calcIgnoreMobDefnese(0.63, [0.45, 0.15]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment