CombatDescriptionGenerator.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style type="text/css">
  7. #code {
  8. position: fixed;
  9. top: 0px;
  10. right: 1ex;
  11. }
  12. textarea {
  13. width: 400px;
  14. height: 60px;
  15. }
  16. </style>
  17. </head>
  18. <body>
  19. <b>Name of this Description:</b><input type="text" id="name" value="Unnamed" /><br/>
  20. <b>Attacker:</b><input type="text" id="attacker" value="Person" /><br/>
  21. <b>Target:</b><input type="text" id="target" value="Person" /><br/>
  22. <b>Weapon(s):</b><input type="text" id="weapons" value="Thing" /><br/>
  23. <br/><b>Description on Miss:</b><br/>
  24. <textarea id="missDesc"></textarea><br/>
  25. <br/><b>Description on Critical Hit:</b><br/>
  26. <textarea id="critDesc"></textarea><br/>
  27. <br/><b>Description on Hit:</b><br/>
  28. <textarea id="hitDesc"></textarea><br/>
  29. <br/><b>Description on Knocked Down:</b><br/>
  30. <textarea id="knockedDesc"></textarea><br/>
  31. <br/><b>Description on Knocked Off:</b><br/>
  32. <textarea id="koDesc"></textarea><br/>
  33. <br/><b>Description on Killed:</b><br/>
  34. <textarea id="killedDesc"></textarea><br/>
  35. <pre id="code">
  36. (new CombatDescription("<span id="nameCode"></span>"))
  37. .setDescriptionFunction((actor, target, weapons, markers) => {
  38. let say = new Say();
  39. if (markers.includes(CombatHit.MISS)) {
  40. say.add(<span id="missCode"></span>);
  41. } else if (markers.includes(CombatHit.HIT)) {
  42. say.add(<span id="hitCode"></span>);
  43. } else if (markers.includes(CombatHit.CRITICAL)) {
  44. say.add(<span id="criticalCode"></span>);
  45. }
  46. say.add(" ");
  47. if (markers.includes(CombatResult.KILLED)) {
  48. say.add(<span id="killedCode"></span>);
  49. } else if (markers.includes(CombatResult.KNOCKED_OFF)) {
  50. say.add(<span id="koCode"></span>);
  51. } else if (markers.includes(CombatResult.KNOCKED)) {
  52. say.add(<span id="knockedCode"></span>);
  53. }
  54. return say;
  55. })
  56. .addUnit()
  57. .setActor(<span id="attackerCode"></span>)
  58. .setTarget(<span id="targetCode"></span>)
  59. .setWeapon(<span id="weaponCode"></span>)
  60. .addMarker(AdaptiveDifferential.FULLYADAPTIVE(CombatHit.MISS, CombatHit.HIT, CombatHit.CRITICAL))
  61. .addMarker(AdaptiveDifferential.FULLYADAPTIVE(CombatResult.KNOCKED, CombatResult.KILLED, CombatResult.KNOCKED_OFF))
  62. ;
  63. </pre>
  64. <script type="text/javascript">
  65. function updateCode () {
  66. document.getElementById("nameCode").innerText = document.getElementById("name").value;
  67. document.getElementById("missCode").innerText = document.getElementById("missDesc").value;
  68. document.getElementById("hitCode").innerText = document.getElementById("hitDesc").value;
  69. document.getElementById("criticalCode").innerText = document.getElementById("critDesc").value;
  70. document.getElementById("killedCode").innerText = document.getElementById("killedDesc").value;
  71. document.getElementById("koCode").innerText = document.getElementById("koDesc").value;
  72. document.getElementById("knockedCode").innerText = document.getElementById("knockedDesc").value;
  73. document.getElementById("attackerCode").innerText = document.getElementById("attacker").value;
  74. document.getElementById("targetCode").innerText = document.getElementById("target").value;
  75. document.getElementById("weaponCode").innerText = document.getElementById("weapons").value;
  76. }
  77. updateCode();
  78. let inputs = document.getElementsByTagName("input");
  79. let textareas = document.getElementsByTagName("textarea");
  80. (new Array(...inputs, ...textareas)).forEach(element => {
  81. element.addEventListener("keyup", updateCode);
  82. });
  83. </script>
  84. </body>
  85. </html>