Skip to content

Instantly share code, notes, and snippets.

@Jimmydalecleveland
Created August 22, 2019 00:10
Show Gist options
  • Save Jimmydalecleveland/513ba0c4f5eba099aeb6f044d992fbc4 to your computer and use it in GitHub Desktop.
Save Jimmydalecleveland/513ba0c4f5eba099aeb6f044d992fbc4 to your computer and use it in GitHub Desktop.
/**
* 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