Post by Fox. on Nov 19, 2014 11:48:04 GMT -8
So, I've touched on this last year, but I never got around to finishing any amount of code for the actual dice roll. I've gotten the html/javascript written for it (see attached) and was wondering if Chris's thread here was still the main reference to add a UBBC button to the tray. It's a very roughed up code (do you see all of the if statements?!) and I'm still learning the finer points of Javascript so if you have any suggestions for the code itself, I'm all ears!
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
div.dice{
float:left;
width:32px;
background:#F5F5F5;
border:#999 1px solid;
padding:10px;
font-size:24px;
text-align:center;
margin:5px;
}
</style>
<script>
function rollDice(){
var die1 = document.getElementById("die1");
var status = document.getElementById("status");
var d1 = Math.floor(Math.random() * 220) + 1;
var status2 = document.getElementById("status2");
die1.innerHTML = d1;
status.innerHTML = "You've dealt "+d1+" damage.";
if(d1 >= 1 && d1 <= 11){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Small Cut | " +
"Blunt (Ex. Mace): Light Bruising"
}
if(d1 >= 11 && d1 <= 21){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Small Cut | " +
"Blunt (Ex. Mace): Light Bruising"
}
if(d1 >= 21 && d1 <= 31){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Small Cut | " +
"Blunt (Ex. Mace): Light Bruising"
}
if(d1 >= 41 && d1 <= 51){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Cut to the bone on minor limb (Linger effect | Attacked Tribute is bleeding heavily) | " +
"Blunt (Ex. Mace): Small Fracture (Linger Effect | Attacked Tribute is in pain and moves slightly slower.)"
}
if(d1 >= 51 && d1 <= 61){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Small Gash | " +
"Blunt (Ex. Mace): Bruising"
}
if(d1 >= 61 && d1 <= 71){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Cut | " +
"Blunt (Ex. Mace): Hit"
}
if(d1 >= 71 && d1 <= 81){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Cut | " +
"Blunt (Ex. Mace): Hit"
}
if(d1 >= 81 && d1 <= 91){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Slash | " +
"Blunt (Ex. Mace): Hit"
}
if(d1 >= 91 && d1 <= 101){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Cut Minor Tendon/Muscle (Linger Effect | Near no movement in the damaged area until tended to.) | " +
"Blunt (Ex. Mace): Fracture (Linger Effect | Near no movement in the damaged area until tended to.)"
}
if(d1 >= 101 && d1 <= 111){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Slash | " +
"Blunt (Ex. Mace): Hit"
}
if(d1 >= 111 && d1 <= 121){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Slash | " +
"Blunt (Ex. Mace): Hit"
}
if(d1 >= 121 && d1 <= 131){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Slash | " +
"Blunt (Ex. Mace): Hit"
}
if(d1 >= 131 && d1 <= 141){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Slash | " +
"Blunt (Ex. Mace): Hit"
}
if(d1 >= 141 && d1 <= 151){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Slash | " +
"Blunt (Ex. Mace): Hit"
}
if(d1 >= 151 && d1 <= 161){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Slash | " +
"Blunt (Ex. Mace): Hit"
}
if(d1 >= 161 && d1 <= 171){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Cut Minor Tendon/Muscle (Linger Effect | Near no movement in the damaged area until tended to.) | " +
"Blunt (Ex. Mace): Blunt Weapon: Fracture (Linger Effect | Near no movement in the damaged area until tended to.)"
}
if(d1 >= 171 && d1 <= 181){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Slash | " +
"Blunt (Ex. Mace): Hit"
}
if(d1 >= 181 && d1 <= 191){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Slash | " +
"Blunt (Ex. Mace): Hit"
}
if(d1 >= 191 && d1 <= 201){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Slash | " +
"Blunt (Ex. Mace): Hit"
}
if(d1 >= 201 && d1 <= 211){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Slash | " +
"Blunt (Ex. Mace): Hit"
}
if(d1 >= 211 && d1 <= 221){
status2.innerHTML = "Sharp/Edged (Ex. Sword): Lose SMALL Limb (Ex. Finger). (Linger Effect | Can not be fixed other than bleeding stopped. | " +
"Blunt (Ex. Mace): Shattered bone (Limb or minor part of the body). (Linger Effect | Can not be fixed other than a splint.)"
}
}
</script>
</head>
<body>
<div id="die1" class="dice">0</div>
<br>
<button onclick="rollDice()">Large Weapon</button>
<h2 id="status" style="clear:left;"></h2>
<h2 id="status2" style="clear:left;"></h2>
</body>
</html>