Skip to content

Instantly share code, notes, and snippets.

@zachwhalen
Last active December 28, 2015 13:39
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 zachwhalen/7508906 to your computer and use it in GitHub Desktop.
Save zachwhalen/7508906 to your computer and use it in GitHub Desktop.
The core combat code for the MaryWashemon battle function
// left attacks right
// this is from patrick's code
// the 10 value below acts as the gas peddle
var modifier = Math.floor((Math.random() * ((left.attack - right.defense) + 10)));
var rightDamage = modifier * left.lvl + 1;
// right takes damage
right.hp -= rightDamage;
// right attacks left
var modifier = Math.floor((Math.random() * ((right.attack - left.defense) + 10)));
var leftDamage = modifier * right.lvl + 1;
// left takes damage
left.hp -= leftDamage;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment