munch
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

45 行
1.3 KiB

  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. attackPlayer: function(defender) {
  15. return "The " + attacker.description() + " punches you for " + attack(attacker, defender, attacker.str) + " damage";
  16. }
  17. };
  18. }
  19. function flankAttack(attacker) {
  20. return {
  21. name: "Flank",
  22. desc: "Be sneaky",
  23. attack: function(defender) {
  24. return "You run around the " + defender.description() + " and attack for " + attack(attacker, defender, attacker.dex) + " damage";
  25. },
  26. attackPlayer: function(defender) {
  27. return "The " + attacker.description() + " runs past you, then turns and hits you for " + attack(attacker, defender, attacker.str) + " damage";
  28. }
  29. };
  30. }
  31. function devourPlayer(attacker) {
  32. return {
  33. name: "Devours YOU!",
  34. desc: "You won't see this",
  35. attackPlayer: function(defender) {
  36. changeMode("eaten");
  37. return "The voracious " + attacker.description() + " pins you down and devours you in seconds.";
  38. }
  39. }
  40. }