Skip to content

Instantly share code, notes, and snippets.

@edvaldoszy
Last active September 7, 2019 04:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edvaldoszy/26f553f9e4a069803729b67fcf537432 to your computer and use it in GitHub Desktop.
Save edvaldoszy/26f553f9e4a069803729b67fcf537432 to your computer and use it in GitHub Desktop.
Calcula a porcentagem de bloqueio de um personagem em Diablo II
#!/usr/bin/env node
require('./diablo2-calc-max-block');
const getopts = require('getopts');
function sumCharacterBlocking(values) {
if (Array.isArray(values)) {
return values.reduce((total, value) => total += value, 0);
} else {
return values;
}
}
const options = getopts(process.argv.slice(2), {
alias: {
blocking: 'b',
dexterity: 'd',
level: 'l',
},
default: {
blocking: 0,
dexterity: 0,
level: 1,
},
});
const blocking = sumCharacterBlocking(options.blocking);
const { dexterity, level } = options;
const totalCharacterBlocking = (blocking * (dexterity - 15)) / (level * 2);
console.log('Total Character Blocking:', Math.floor(totalCharacterBlocking));
{
"name": "diablo2-calc-max-block",
"version": "0.1.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"getopts": "2.2.5"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment