Advertisement
ambosdavid

prisoners

Mar 22nd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. <!doctype html>
  2. <!-- Instructions: All 6 mid boxes must add up to 6, if not you'll get an alert(); message. Once all six boxes match up, then hit roll and release your prisoners laddy. -->
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <title>Release The Prisoners</title>
  7. <style type="text/css">
  8. body {
  9. background-color: rgba(32,211,233,1);
  10. }
  11. div {
  12. text-align: center;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <h2 align="center">Release The Prisoners Game</h2>
  18. <div>
  19. <input type="number" min="0" max="6" value="0" id="cell1" /><br>
  20. <input type="text" id="n0" value="0" />
  21. <input type="text" id="n1" value="0" />
  22. <input type="text" id="n2" value="0" />
  23. <input type="text" id="n3" value="0" />
  24. <input type="text" id="n4" value="0" />
  25. <input type="text" id="n5" value="0" /><br>
  26. <input type="text" id="die1" readonly />
  27. <th><input type="button" value="Roll" onClick="roll();" /></th>
  28. <script>
  29. var six = false;
  30. function roll() {
  31. var n0 = parseInt(document.getElementById("n0").value);
  32. var n1 = parseInt(document.getElementById("n1").value);
  33. var n2 = parseInt(document.getElementById("n2").value);
  34. var n3 = parseInt(document.getElementById("n3").value);
  35. var n4 = parseInt(document.getElementById("n4").value);
  36. var n5 = parseInt(document.getElementById("n5").value);
  37. if (n0+n1+n2+n3+n4+n5 == 6) {
  38. six = true;
  39. }
  40. if (six) {
  41. var r0 = Math.floor(Math.random() * 6);
  42. var r1 = Math.floor(Math.random() * 6);
  43. var diff = Math.abs(r0 - r1);
  44. if (diff < 0) { diff = diff * -1; }
  45. document.getElementById("n" + diff).value = "0"
  46. document.getElementById("cell1").value = (n0+n1+n2+n3+n4+n5);
  47. document.getElementById("die1").value = r0 + ", " + r1;
  48. } else {
  49. alert("Numbers Do not add up to 6 OR You clearly did not read the instructions.");
  50. }
  51. }
  52. </script>
  53. <h2>Press f5 to Restart / Refresh</h2>
  54. </div>
  55. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement