Traveller RPG Dice

by ledlogic

HTML

<h1>Traveller RPG Dice</h1>

<button onclick="addResult(d66())">
roll d66
</button>
<button onclick="addResult(d6()+d6())">
roll 2d6
</button>
<button onclick="addResult(d100())">
roll d100
</button>
<hr/>
<textarea id="output">
</textarea>

CSS

* {
  font-family: Bahnschrift;
}

#output {
  width: 100%;
  height:200px;
}

JavaScript

function d6() { return Math.round(Math.random() * 5 + 1); }
function d66() { return d6() * 10 + d6(); }
function d100() { return Math.round(Math.random() * 99 + 1); }
function addResult(v) {
    var output=document.getElementById('output');
    output.innerHTML = v + "\r\n" + output.innerHTML;
}