123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <style type="text/css">
- #code {
- position: fixed;
- top: 0px;
- right: 1ex;
- }
- textarea {
- width: 400px;
- height: 60px;
- }
- </style>
- </head>
- <body>
- <b>Name of this Description:</b><input type="text" id="name" value="Unnamed" /><br/>
- <b>Attacker:</b><input type="text" id="attacker" value="Person" /><br/>
- <b>Target:</b><input type="text" id="target" value="Person" /><br/>
- <b>Weapon(s):</b><input type="text" id="weapons" value="Thing" /><br/>
- <br/><b>Description on Miss:</b><br/>
- <textarea id="missDesc"></textarea><br/>
- <br/><b>Description on Critical Hit:</b><br/>
- <textarea id="critDesc"></textarea><br/>
- <br/><b>Description on Hit:</b><br/>
- <textarea id="hitDesc"></textarea><br/>
- <br/><b>Description on Knocked Down:</b><br/>
- <textarea id="knockedDesc"></textarea><br/>
- <br/><b>Description on Knocked Off:</b><br/>
- <textarea id="koDesc"></textarea><br/>
- <br/><b>Description on Killed:</b><br/>
- <textarea id="killedDesc"></textarea><br/>
- <pre id="code">
- (new CombatDescription("<span id="nameCode"></span>"))
- .setDescriptionFunction((actor, target, weapons, markers) => {
- let say = new Say();
- if (markers.includes(CombatHit.MISS)) {
- say.add(<span id="missCode"></span>);
- } else if (markers.includes(CombatHit.HIT)) {
- say.add(<span id="hitCode"></span>);
- } else if (markers.includes(CombatHit.CRITICAL)) {
- say.add(<span id="criticalCode"></span>);
- }
- say.add(" ");
- if (markers.includes(CombatResult.KILLED)) {
- say.add(<span id="killedCode"></span>);
- } else if (markers.includes(CombatResult.KNOCKED_OFF)) {
- say.add(<span id="koCode"></span>);
- } else if (markers.includes(CombatResult.KNOCKED)) {
- say.add(<span id="knockedCode"></span>);
- }
- return say;
- })
- .addUnit()
- .setActor(<span id="attackerCode"></span>)
- .setTarget(<span id="targetCode"></span>)
- .setWeapon(<span id="weaponCode"></span>)
- .addMarker(AdaptiveDifferential.FULLYADAPTIVE(CombatHit.MISS, CombatHit.HIT, CombatHit.CRITICAL))
- .addMarker(AdaptiveDifferential.FULLYADAPTIVE(CombatResult.KNOCKED, CombatResult.KILLED, CombatResult.KNOCKED_OFF))
- ;
- </pre>
- <script type="text/javascript">
- function updateCode () {
- document.getElementById("nameCode").innerText = document.getElementById("name").value;
- document.getElementById("missCode").innerText = document.getElementById("missDesc").value;
- document.getElementById("hitCode").innerText = document.getElementById("hitDesc").value;
- document.getElementById("criticalCode").innerText = document.getElementById("critDesc").value;
- document.getElementById("killedCode").innerText = document.getElementById("killedDesc").value;
- document.getElementById("koCode").innerText = document.getElementById("koDesc").value;
- document.getElementById("knockedCode").innerText = document.getElementById("knockedDesc").value;
- document.getElementById("attackerCode").innerText = document.getElementById("attacker").value;
- document.getElementById("targetCode").innerText = document.getElementById("target").value;
- document.getElementById("weaponCode").innerText = document.getElementById("weapons").value;
- }
- updateCode();
- let inputs = document.getElementsByTagName("input");
- let textareas = document.getElementsByTagName("textarea");
- (new Array(...inputs, ...textareas)).forEach(element => {
- element.addEventListener("keyup", updateCode);
- });
- </script>
- </body>
- </html>
|