munch
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

28 lines
714 B

  1. "use strict";
  2. function attack(attacker, defender, baseDamage) {
  3. let damage = Math.round((Math.random() * 0.5 - 0.25 + 1) * baseDamage);
  4. defender.health -= damage;
  5. return damage;
  6. }
  7. function punchAttack(attacker) {
  8. return {
  9. name: "Punch",
  10. desc: "Punch a nerd",
  11. attack: function(defender) {
  12. return "You punch the " + defender.description() + " for " + attack(attacker, defender, attacker.str) + " damage";
  13. }
  14. };
  15. }
  16. function flankAttack(attacker) {
  17. return {
  18. name: "Flank",
  19. desc: "Be sneaky",
  20. attack: function(defender) {
  21. return "You run around the " + defender.description() + " and attack for " + attack(attacker, defender, attacker.dex) + " damage";
  22. }
  23. };
  24. }