Last active
September 7, 2019 04:12
-
-
Save edvaldoszy/26f553f9e4a069803729b67fcf537432 to your computer and use it in GitHub Desktop.
Calcula a porcentagem de bloqueio de um personagem em Diablo II
This file contains hidden or 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
#!/usr/bin/env node | |
require('./diablo2-calc-max-block'); |
This file contains hidden or 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
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)); |
This file contains hidden or 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
{ | |
"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