fork(1) download
  1. var atktypes, microMonster, neuwurd, np, randint;
  2.  
  3. microMonster = function(hd) {
  4. hd = hd * 1;
  5. return "Name:" + neuwurd().ucfirst() + "\n" + "HD:" + hd + " (" + (Math.floor(hd * 4.5) + randint(hd * 4)) + "hp), AC:" + (randint(5) + hd + 10) + ", Attack:" + atktypes.split(" ").randItem() + " +" + (hd + randint(4)) + " (" + (randint(2) + 1) + "d" + (2 * (randint(6) + 1)) + ")\n";
  6. };
  7.  
  8. randint = function(n) {
  9. return Math.floor(Math.random() * n);
  10. };
  11.  
  12. neuwurd = function() {
  13. var w;
  14. w = "W";
  15. while (w.length < 40 && w.match(/[A-Z]/)) {
  16. w = w.replace(/([A-Z])/, function(m) {
  17. return np[m].split(" ").randItem();
  18. });
  19. }
  20. return w;
  21. };
  22.  
  23. np = {
  24. W: "CT CT CX CDF CVFT CDFU CTU IT ICT A",
  25. A: "KVKVtion",
  26. K: "b c d f g j l m n p qu r s t v sP",
  27. I: "ex in un re de",
  28. T: "VF VEe",
  29. U: "er ish ly en ing ness ment able ive",
  30. C: "b c ch d f g h j k l m n p qu r s sh t th v w y sP Rr Ll",
  31. E: "b c ch d f g dg l m n p r s t th v z",
  32. F: "b tch d ff g gh ck ll m n n ng p r ss sh t tt th x y zz rR sP lL",
  33. P: "p t k c",
  34. Q: "b d g",
  35. L: "b f k p s",
  36. R: "P Q f th sh",
  37. V: "a e i o u",
  38. D: "aw ei ow ou ie ea ai oy",
  39. X: "e i o aw ow oy"
  40. };
  41.  
  42. atktypes = "Bite Claw Slam Gore Sting Tentacle Shock";
  43.  
  44. atktypes = atktypes + " Weapon Weapon Weapon Weapon Weapon Weapon";
  45.  
  46. Array.prototype.randItem = function() {
  47. return this[randint(this.length)];
  48. };
  49.  
  50. String.prototype.ucfirst = function() {
  51. return this.substring(0, 1).toUpperCase() + this.substring(1);
  52. };
  53.  
  54. print(microMonster(1));
  55. print(microMonster(1));
  56. print(microMonster(1));
  57. print(microMonster(1));
  58. print(microMonster(1));
  59. print(microMonster(1));
  60. print(microMonster(1));
  61. print(microMonster(1));
  62. print(microMonster(1));
  63. print(microMonster(1));
  64.  
Success #stdin #stdout 0.02s 5056KB
stdin
Standard input is empty
stdout
Name:Spuff
HD:1 (5hp), AC:13, Attack:Tentacle +1 (2d6)

Name:Jalition
HD:1 (7hp), AC:13, Attack:Weapon +2 (2d12)

Name:Deheze
HD:1 (6hp), AC:14, Attack:Sting +1 (2d8)

Name:Yithe
HD:1 (7hp), AC:11, Attack:Weapon +4 (2d10)

Name:Rowt
HD:1 (6hp), AC:11, Attack:Weapon +4 (2d2)

Name:Shienish
HD:1 (4hp), AC:14, Attack:Sting +2 (2d12)

Name:Stuzz
HD:1 (4hp), AC:12, Attack:Weapon +1 (1d12)

Name:Hone
HD:1 (7hp), AC:12, Attack:Gore +2 (1d10)

Name:Gayave
HD:1 (6hp), AC:15, Attack:Gore +4 (1d10)

Name:Powp
HD:1 (5hp), AC:11, Attack:Weapon +4 (2d12)