Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <!-- 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. -->
- <html>
- <head>
- <meta charset="utf-8">
- <title>Release The Prisoners</title>
- <style type="text/css">
- body {
- background-color: rgba(32,211,233,1);
- }
- div {
- text-align: center;
- }
- </style>
- </head>
- <body>
- <h2 align="center">Release The Prisoners Game</h2>
- <div>
- <input type="number" min="0" max="6" value="0" id="cell1" /><br>
- <input type="text" id="n0" value="0" />
- <input type="text" id="n1" value="0" />
- <input type="text" id="n2" value="0" />
- <input type="text" id="n3" value="0" />
- <input type="text" id="n4" value="0" />
- <input type="text" id="n5" value="0" /><br>
- <input type="text" id="die1" readonly />
- <th><input type="button" value="Roll" onClick="roll();" /></th>
- <script>
- var six = false;
- function roll() {
- var n0 = parseInt(document.getElementById("n0").value);
- var n1 = parseInt(document.getElementById("n1").value);
- var n2 = parseInt(document.getElementById("n2").value);
- var n3 = parseInt(document.getElementById("n3").value);
- var n4 = parseInt(document.getElementById("n4").value);
- var n5 = parseInt(document.getElementById("n5").value);
- if (n0+n1+n2+n3+n4+n5 == 6) {
- six = true;
- }
- if (six) {
- var r0 = Math.floor(Math.random() * 6);
- var r1 = Math.floor(Math.random() * 6);
- var diff = Math.abs(r0 - r1);
- if (diff < 0) { diff = diff * -1; }
- document.getElementById("n" + diff).value = "0"
- document.getElementById("cell1").value = (n0+n1+n2+n3+n4+n5);
- document.getElementById("die1").value = r0 + ", " + r1;
- } else {
- alert("Numbers Do not add up to 6 OR You clearly did not read the instructions.");
- }
- }
- </script>
- <h2>Press f5 to Restart / Refresh</h2>
- </div>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement