Tengo casi todo resuelto pero cuando llamo a la funcion "premios" no me funciona bien el programa... no se a q se debe :/ si saco esa linea vuelve a funcionar normal pero ovbiamente sin buscar los premios ¬¬.
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function tirardado()
{
var maximo = 3; // numero máximo de rondas o tiradas de dados
if (maximo != document.getElementById("ronda").value) // verifico que no hayan 3 tiradas en total
{
for(var i = 1; i < 6; i++)
{
if(document.getElementById("bloquear"+i).checked) // chekeo si hay dados bloqueados
{
}
else
{
document.getElementById("dado"+i).value = Math.ceil(Math.random()*6); // tiro los dados libres
premios(); // busco el premio con los dados actuales
}
}
document.getElementById("ronda").value ++; // le sumo 1 a la ronda actual
}
else
{
if(document.getElementById("ronda").value == 3)
{alert ("Se acabo el juego, si deseas jugar nuevamente haz clic en 'Volver a jugar' ")
document.getElementsByName("Tirar Dados()").disabled;
}
}
}
function resetear()
{
document.getElementById("tirar").reset();
document.getElementById("ronda").value = 0;
}
function premios() //aca buscamos los premios
{
var uno = 0;
var dos = 0 ;
var tres = 0;
var cuatro = 0;
var cinco = 0;
var seis = 0;
var puntaje = 0;
for (j=1;j<6;j++)
{
numero = Number(document.getElementById("dado").elements[k].value); //guardo el dato del dado para recorrerlo con el for buscando que numero cae,
switch (numero)
{
case 1 : uno++;
break;
case 2 : dos++;
break;
case 3 : tres++;
break;
case 4 : cuatro++;
break;
case 5 : cinco++;
break;
case 6 : seis++;
break;
}
if ((uno==5)||(dos==5)||(tres==5)||(cuatro==5)||(cinco==5)||(seis==5)) // si hay 5 iguales d algun numero es generala
{
alert("Generala!!!");
Number(document.getElementById("puntos").value)= Number(document.getElementById("puntos").value) +50;
} // le sumo 50 puntos x sacar generala
else if ((uno==4)||(dos==4)||(tres==4)||(cuatro==4)||(cinco==4)||(seis==4))
{
alert= ("Poker!!");
Number(document.getElementById("puntos").value)= Number(document.getElementById("puntos").value) +40;}
else if (((uno==3)||(dos==3)||(tres==3)||(cuatro==3)||(cinco==3)||(seis==3))&&((uno==2)||(dos==2)||(tres==2)||(cuatro==2)||(cinco==2)||(seis==2)))
{
alert("Full!!");
Number(document.getElementById("puntos").value)= Number(document.getElementById("puntos").value) +30;
}
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<style type="text/css">
#apDiv1 {
position: absolute;
width: 694px;
height: 904px;
z-index: 1;
left: 105px;
top: 2px;
}
</style>
</head>
<body>
<div id="apDiv1">
<form id="tirar">
<p>
<input type="text" id="dado1" value=0 readonly="readonly">
Dado 1
<input type="checkbox" name="dado1" id="bloquear1" />
<label for="dado1">Bloquear</label>
1
</p>
<p>
<input type="text" id="dado2" value=0 readonly="readonly">
Dado 2
<input type="checkbox" name="dado2" id="bloquear2" />
<label for="dado2">Bloquear</label>
2
</p>
<p>
<input type="text" id="dado3" value=0 readonly="readonly">
Dado 3
<input type="checkbox" name="dado3" id="bloquear3" />
<label for="dado3">Bloquear</label>
3
</p>
<p>
<input type="text" id="dado4" value=0 readonly="readonly" />
Dado 4
<input type="checkbox" name="dado4" id="bloquear4" />
<label for="dado4">Bloquear</label>
4
</p>
<p>
<input type="text" id="dado5" value=0 readonly="readonly" />
Dado 5
<input type="checkbox" name="dado5" id="bloquear5" />
<label for="dado5">Bloquear</label>
5
</p>
</form>
<p>
<input name="Tirar Dados" type="button" onclick="tirardado()" value="Tirar Dados"/>
<label for="Tiradas">Ronda N°</label>
<input name="Tiradas" type="text" id="ronda" value=0 readonly="readonly" />
Puntaje Actual
<label for="puntos"></label>
<input name="puntos" type="text" id="puntos" value=0 readonly="readonly" />
</p>
<input type="reset" name="resetear" id="resetear" value="Volver a Jugar" onclick="resetear()"/>
</form>
<p> </p>
</div>
</body>
</html>