Created
August 22, 2019 00:10
-
-
Save Jimmydalecleveland/513ba0c4f5eba099aeb6f044d992fbc4 to your computer and use it in GitHub Desktop.
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
/** | |
* To use this function, pass in your damage as the first variable | |
* and your bonus (modifier) as the second variable. | |
* | |
* optional: Start the string with what happens to you for flavor. | |
* @example: | |
* doDamage`${18}${3}` | |
* doDamage`trip on a stone${7}${3}` | |
* */ | |
function doDamage(stringArray, damage, modifier) { | |
stringArray | |
const intro = stringArray[0] | |
? `You ${stringArray[0]}, and deal a` | |
: 'You deal a' | |
const adjective = damage > 15 ? 'crippling' : 'paltry' | |
return `${intro} ${adjective} ${damage} + ${modifier} damage.` | |
} | |
const myTest = doDamage`${18}${3}` | |
// You deal a crippling 18 + 3 damage. | |
const myTest2 = doDamage`trip on a stone${7}${3}` | |
//You trip on a stone, and deal a paltry 7 + 3 damage. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment