var iConta=0; function calculosPrincipales() { var iFue, iCon, iDes, iApa, iTam, iInte, iEdu, iPod; iniciaMarcador(); contaPJ(); document.caract.nomInv.value=''; document.caract.ocup.value=''; document.caract.estudios.value=''; document.caract.lugar.value=''; //document.caract.rabo.value=''; //document.caract.bRabo.disabled=false; document.caract.bsex[0].checked=true; document.caract.botonRestarAnyos.disabled=false; document.caract.botonSumarAnyos.disabled=false; document.caract.botoEstAdic.disabled=false; document.caract.botonPermuta.disabled=false; document.caract.botonPermuta2.disabled=false; document.caract.botonImprimir.disabled=false; for (var i=0 ; i<10 ; i++) { document.caract.arrayBox[i].disabled = false; document.caract.arrayBox[i].checked = false; } //tirada de fue document.caract.fue.value=tira3D6ySuma(); //tirada de con document.caract.con.value=tira3D6ySuma(); //tirada de pod y cálculo de la COR document.caract.pod.value=tira3D6ySuma(); document.caract.cor.value=document.caract.pod.value*5; //tirada de des document.caract.des.value=tira3D6ySuma(); //tirada de apa document.caract.apa.value=tira3D6ySuma(); //tirada de tam document.caract.tam.value=tira2D6ySuma()+6; //tirada de int document.caract.inte.value=tira2D6ySuma()+6; //tirada de edu y cálculo de Conocimientos document.caract.edu.value=tira3D6ySuma()+6; document.caract.cono.value=document.caract.edu.value*5; iFue=parseInt(document.caract.fue.value); iCon=parseInt(document.caract.con.value); iDes=parseInt(document.caract.des.value); iApa=parseInt(document.caract.apa.value); iTam=parseInt(document.caract.tam.value); iInte=parseInt(document.caract.inte.value); iEdu=parseInt(document.caract.edu.value); iPod=parseInt(document.caract.pod.value); calPtosVida(iCon, iTam); calBoni(iFue, iTam); calIngresos(); otrosCalculos(iEdu, iInte); } function calculosPrincipalesEsp() { var iFue, iCon, iDes, iApa, iTam, iInte, iEdu, iPod; iniciaMarcador(); contaPJ(); document.caract.nomInv.value=''; document.caract.ocup.value=''; document.caract.estudios.value=''; document.caract.lugar.value=''; document.caract.rabo.value=''; document.caract.bRabo.disabled=false; document.caract.bsex[0].checked=true; document.caract.botonRestarAnyos.disabled=false; document.caract.botonSumarAnyos.disabled=false; document.caract.botoEstAdic.disabled=false; document.caract.botonPermuta.disabled=true; document.caract.botonPermuta2.disabled=true; document.caract.botonImprimir.disabled=false; for (var i=0 ; i<10 ; i++) { document.caract.arrayBox[i].disabled = true; document.caract.arrayBox[i].checked = false; } do { //tirada de fue document.caract.fue.value=tira3D6ySuma(); } while (document.caract.fue.value<10) do { //tirada de con document.caract.con.value=tira3D6ySuma(); } while (document.caract.con.value<10) do { //tirada de pod y cálculo de la COR document.caract.pod.value=tira3D6ySuma(); document.caract.cor.value=document.caract.pod.value*5; } while (document.caract.pod.value<10) do { //tirada de des document.caract.des.value=tira3D6ySuma(); } while (document.caract.des.value<10) do { //tirada de apa document.caract.apa.value=tira3D6ySuma(); } while (document.caract.apa.value<8) do { //tirada de tam document.caract.tam.value=tira2D6ySuma()+6; } while (document.caract.tam.value<10) do { //tirada de int document.caract.inte.value=tira2D6ySuma()+6; } while (document.caract.inte.value<10) do { //tirada de edu y cálculo de Conocimientos document.caract.edu.value=tira3D6ySuma()+6; document.caract.cono.value=document.caract.edu.value*5; } while (document.caract.edu.value<10) iFue=parseInt(document.caract.fue.value); iCon=parseInt(document.caract.con.value); iDes=parseInt(document.caract.des.value); iApa=parseInt(document.caract.apa.value); iTam=parseInt(document.caract.tam.value); iInte=parseInt(document.caract.inte.value); iEdu=parseInt(document.caract.edu.value); iPod=parseInt(document.caract.pod.value); calPtosVida(iCon, iTam); iPtosVida=calPtosVida(iCon, iTam); calBoni(iFue, iTam); calIngresos(); otrosCalculos(iEdu, iInte); //Aviso de buen PJ if (document.caract.fue.value>10 && document.caract.con.value>10 && document.caract.pod.value>13 && document.caract.des.value>10 && document.caract.apa.value>=8 && document.caract.tam.value>10 && document.caract.inte.value>11 && document.caract.edu.value>16 && iPtosVida>14) { window.alert("PJ potente!"); window.alert("A saco!"); window.alert("Eres una máquina"); iConta=iConta+1; if (iConta==4) { window.alert("Modo 'Special Roll' agotado"); document.caract.bCalcEsp.disabled=true; document.caract.bCalc.focus(); } } } function calPtosVida(iCon, iTam) { var iPtosVida; document.caract.ptosVida.value=Math.ceil((iCon+iTam)/2); iPtosVida=parseInt(document.caract.ptosVida.value); return(iPtosVida); } function calBoni(iFue, iTam) { if (iFue+iTam>=13 && iFue+iTam<=16) { document.caract.dbonus.value='-1D4'; } else { if(iFue+iTam>=17 && iFue+iTam<=24) { document.caract.dbonus.value='0'; } else { if(iFue+iTam>=25 && iFue+iTam<=32) { document.caract.dbonus.value='+1D4'; } else { if(iFue+iTam>=33 && iFue+iTam<=40) { document.caract.dbonus.value='+1D6'; } } } } } function calIngresos() { var iDado10=Math.floor((Math.random())*10+1); switch (iDado10) { case 1: document.caract.ingresos.value='$4500'; break; case 2: document.caract.ingresos.value='$5500'; break; case 3: document.caract.ingresos.value='$6500'; break; case 4: document.caract.ingresos.value='$7500'; break; case 6: document.caract.ingresos.value='$8500'; break; case 7: document.caract.ingresos.value='$9500'; break; case 8: document.caract.ingresos.value='$10500'; break; case 9: document.caract.ingresos.value='$11500'; break; case 10: document.caract.ingresos.value='$12500'; break; } } function otrosCalculos(iEdu, iInte) { //Puntos de ocupación document.caract.ptosOcup.value=iEdu*20; //Intereses personales document.caract.interPers.value=iInte*10; //Cálculo edad document.caract.edad.value=iEdu+6; } function anadirAnyos(edadObj) { var edadObj; var iEdad=parseInt(edadObj); var iEdu=parseInt(document.caract.edu.value); var iEdadMayor; document.caract.edu.value=iEdu+1; recalcPtosOcup(document.caract.edu.value); document.caract.edad.value=iEdad+10; iEdadMayor=document.caract.edad.value; if (iEdadMayor>=40) { restaCaract(); } if(document.caract.botonRestarAnyos.disabled && iEdad>(iEdu+6) ) { document.caract.botonRestarAnyos.disabled=false; } if (iEdadMayor>=70) { window.alert("Límite de edad permitido"); document.caract.botonSumarAnyos.disabled=true; } if(document.caract.botonRestarAnyos.disabled) { document.caract.botonRestarAnyos.disabled=false; } } function restarAnyos(edadObj) { var edadObj; var iEdad=parseInt(edadObj); var iEdu=parseInt(document.caract.edu.value); var iEdadMenor; document.caract.edu.value=iEdu-1; recalcPtosOcup(document.caract.edu.value); document.caract.edad.value=iEdad-10; iEdadMenor=parseInt(document.caract.edad.value); if(iEdadMenor>=30) { sumaCaract(); } if(document.caract.botonSumarAnyos.disabled && (iEdu-1)<70 ) { document.caract.botonSumarAnyos.disabled=false; } if (iEdadMenor0) { estado = statusMarcador(); if(pasos[iContFilas][iContCol-1] == 's' || estado=="lleno") { recuperar(); } else { estado = statusMarcador(); writeArrays(estado); estado = statusMarcador(); readed = readMarcador(estado); switch(readed) { case 1: document.caract.fue.value=iFue-1; break; case 2: document.caract.con.value=iCon-1; break; case 3: document.caract.des.value=iDes-1; break; case 4: document.caract.apa.value=iApa-1; break; } } } else { //S'escriu el primer registre a paso estado = statusMarcador(); writeArrays(estado); estado = statusMarcador(); readed = readMarcador(estado); switch(readed) { case 1: document.caract.fue.value=iFue-1; break; case 2: document.caract.con.value=iCon-1; break; case 3: document.caract.des.value=iDes-1; break; case 4: document.caract.apa.value=iApa-1; break; } } iContCol=iContCol+1; } /*******************************************/ /************FUNCIÓ QUE SUMA CARACT.*******/ /*******************************************/ function sumaCaract() { var iFue=parseInt(document.caract.fue.value); var iCon=parseInt(document.caract.con.value); var iDes=parseInt(document.caract.des.value); var iApa=parseInt(document.caract.apa.value); pasos[iContFilas][iContCol]='s'; pasos[iContFilas+1][iContCol]=document.caract.edad.value; estado = statusMarcador(); if(pasos[iContFilas][iContCol-1] == 's' || estado=="lleno") { recuperar(); } else { estado = statusMarcador(); readed = readMarcador(estado); switch(readed) { case 1: document.caract.fue.value=iFue+1; break; case 2: document.caract.con.value=iCon+1; break; case 3: document.caract.des.value=iDes+1; break; case 4: document.caract.apa.value=iApa+1; break; } } iContCol=iContCol+1; } /*******************************************************/ /************FUNCIÓ QUE DONA L'ESTAT DEL MARCADOR*******/ /*******************************************************/ function statusMarcador() { if(marcador[0]==0 && marcador[1]==0 && marcador[2]==0 && marcador[3]==0) { return("vacio"); } if(marcador[0]!=0 && marcador[1]==0 && marcador[2]==0 && marcador[3]==0) { return("vacio123"); } if(marcador[0]!=0 && marcador[1]!=0 && marcador[2]==0 && marcador[3]==0) { return("vacio23"); } if(marcador[0]!=0 && marcador[1]!=0 && marcador[2]!=0 && marcador[3]==0) { return("vacio3"); } if(marcador[0]!=0 && marcador[1]!=0 && marcador[2]!=0 && marcador[3]!=0) { return("lleno"); } } /*******************************************************/ /************FUNCIÓ QUE ESCRIU SOBRE ELS ARRAYS*********/ /*******************************************************/ function writeArrays(status) { var status; var resultado = Math.floor((Math.random())*4+1); pasos[iContFilas+2][iContCol]=resultado; if(status=="vacio") {marcador[0]=resultado;} if(status=="vacio123") {marcador[1]=resultado;} if(status=="vacio23") {marcador[2]=resultado;} if(status=="vacio3") {marcador[3]=resultado;} } /*******************************************************/ /************FUNCIÓ QUE LLEGEIX EL MARCADOR*************/ /*******************************************************/ function readMarcador(status) { var status; if(status=="vacio123") {return(marcador[0]);} if(status=="vacio23") {return(marcador[1]);} if(status=="vacio3") {return(marcador[2]);} if(status=="lleno") {return(marcador[3]);} } /************************************************************/ /************FUNCIÓ QUE RECUPERA UN CERT ESTAT DE "PASOS"****/ /************************************************************/ function recuperar() { var index , n, read1D4, i; var iFue=parseInt(document.caract.fue.value); var iCon=parseInt(document.caract.con.value); var iDes=parseInt(document.caract.des.value); var iApa=parseInt(document.caract.apa.value); /************************************************/ /******************1ªpart:***********************/ /************************************************/ //Si l'estat actual és s/n, recupera l'estat r/n+10 més pròxim. En aquest //últim estat, es llegeix el nombre de caract. associat i se li SUMA //a la caract. en qüestió un 1; //si l'estat actual és s/n... if(pasos[iContFilas][iContCol]=='s') { //Per recuperar un estat r/n+10 s'ha de llegir la fila i //columna on es troba r/n+10 i inferir la tercera fila. //llegeixo l'any n de l'estat s/n n=parseInt(pasos[iContFilas+1][iContCol]); index=iContCol; //deifinr un for que llegeixi la segona fila de l'array for(i=(index-1); i>-1; i--) { if(pasos[0][i]=='r' && pasos[1][i]==n+10) { var guardaIndex=i; } } read1D4= pasos[2][guardaIndex]; //càlculs pertinents segons reultats anteriors switch(read1D4) { case 1: document.caract.fue.value=iFue+1; break; case 2: document.caract.con.value=iCon+1; break; case 3: document.caract.des.value=iDes+1; break; case 4: document.caract.apa.value=iApa+1; break; } } /************************************************/ /******************2ªpart:***********************/ /************************************************/ //Si l'estat actual és r/n, recupera l'estat r/n més pròxim. En aquest //últim estat, es llegeix el nombre de caract. associat i se li RESTA //a la caract. en qüestió un 1. A més, es copia el nombre de caract. //de l’estat recuperat a l’estat actual; //si l'estat actual és r/n... if(pasos[iContFilas][iContCol]=='r') { //Per recuperar un estat r/n + próxim s'ha de llegir la fila i //columna on es troba r/n i inferir la tercera fila. //llegeixo l'any n de l'estat r/n n=parseInt(pasos[iContFilas+1][iContCol]); index=iContCol; //deifinr un for que llegeixi la segona fila de l'array for(i=(index-1); i>-1; i--) { if(pasos[0][i]=='r' && pasos[1][i]==n) { var guardaIndex=i; } } read1D4= pasos[2][guardaIndex]; //càlculs pertinents segons reultats anteriors switch(read1D4) { case 1: document.caract.fue.value=iFue-1; break; case 2: document.caract.con.value=iCon-1; break; case 3: document.caract.des.value=iDes-1; break; case 4: document.caract.apa.value=iApa-1; break; } //Es copia el nombre de caract. de l’estat //recuperat a l’estat actual pasos[iContFilas+2][iContCol]=read1D4; } } function estudiosAdic(inteObj) { var inteObj; var iInte=parseInt(inteObj); var iDado100=Math.floor((Math.random())*100); var iEdu=parseInt(document.caract.edu.value); var iInterPers=parseInt(document.caract.interPers.value); var iEdad=parseInt(document.caract.edad.value); if(iDado100<=iInte*5) { window.alert("Extra de +1 a Edu y +10 a Intereses Personales!!"); document.caract.edu.value=iEdu+1; document.caract.cono.value=(iEdu+1)*5; document.caract.interPers.value=iInterPers+10; document.caract.botoEstAdic.disabled=true; document.caract.edad.value=iEdad+1; } else { window.alert("No tuviste suerte..."); document.caract.botoEstAdic.disabled=true; } } function tira3D6ySuma() { var iDado1,iDado2,iDado3; iDado1 = Math.floor((Math.random())*6+1); iDado2 = Math.floor((Math.random())*6+1); iDado3 = Math.floor((Math.random())*6+1); return(iDado1+iDado2+iDado3); } function tira2D6ySuma() { var iDado1,iDado2; iDado1 = Math.floor((Math.random())*6+1); iDado2 = Math.floor((Math.random())*6+1); return(iDado1+iDado2); } function recalcPtosOcup(EduObj) { var EduObj; var iEdu=parseInt(EduObj); document.caract.ptosOcup.value=iEdu*20; //También recalcula Conocimientos document.caract.cono.value=iEdu*5; } function permutaciones3D6(inputArray) { var iMarca1erGrupo; var iMarca2ndoGrupo; var oCadena; var iTam=parseInt(document.caract.tam.value); var iCon, iFue; var iCont=0; permutados=new Array(document.caract.fue, document.caract.fue, document.caract.con, document.caract.con, document.caract.pod, document.caract.pod, document.caract.des, document.caract.des, document.caract.apa, document.caract.apa ); //Primera columna if (inputArray[0].checked == true) { iMarca1erGrupo=0; iCont=iCont+1; } if (inputArray[2].checked == true) { iMarca1erGrupo=2; iCont=iCont+1; } if (inputArray[4].checked == true) { iMarca1erGrupo=4; iCont=iCont+1; } if (inputArray[6].checked == true) { iMarca1erGrupo=6; iCont=iCont+1; } if (inputArray[8].checked == true) { iMarca1erGrupo=8; iCont=iCont+1; } if(iCont>1) { window.alert("No se pueden marcar más de 2 características de una misma columna (A)."); inputArray[0].checked = false; inputArray[2].checked = false; inputArray[4].checked = false; inputArray[6].checked = false; inputArray[8].checked = false; } iCont=0; //Segona columna if (inputArray[1].checked == true) { iMarca2ndoGrupo=1; iCont=iCont+1; } if (inputArray[3].checked == true) { iMarca2ndoGrupo=3; iCont=iCont+1; } if (inputArray[5].checked == true) { iMarca2ndoGrupo=5; iCont=iCont+1; } if (inputArray[7].checked == true) { iMarca2ndoGrupo=7; iCont=iCont+1; } if (inputArray[9].checked == true) { iMarca2ndoGrupo=9; iCont=iCont+1; } if(iCont>1){ window.alert("No se pueden marcar más de 2 características de una misma columna (B)."); inputArray[1].checked = false; inputArray[3].checked = false; inputArray[5].checked = false; inputArray[7].checked = false; inputArray[9].checked = false; } oCadena=permutados[iMarca1erGrupo].value; permutados[iMarca1erGrupo].value=permutados[iMarca2ndoGrupo].value; permutados[iMarca2ndoGrupo].value=oCadena; iFue=parseInt(permutados[0].value); iCon=parseInt(permutados[3].value); calPtosVida(iCon, iTam); calBoni(iFue, iTam); document.caract.cor.value=(parseInt(permutados[4].value))*5; } function permutaciones2D6() { var sAlmacena; var iTam=parseInt(document.caract.tam.value); var iCon=parseInt(document.caract.con.value); var iFue=parseInt(document.caract.fue.value); var iInte=parseInt(document.caract.inte.value); sAlmacena=document.caract.tam.value; document.caract.tam.value=document.caract.inte.value; document.caract.inte.value=sAlmacena; calPtosVida(iCon, iTam); calBoni(iFue, iTam); document.caract.interPers.value=iInte*10; } function imprimir() { window.open('resumen.html'); } function tirarRabo() { var iDado20 = parseInt(Math.floor((Math.random())*20+1)); document.caract.rabo.value=iDado20; if (iDado20>0 && iDado20<=5) { window.alert("Retractil"); document.caract.bRabo.disabled=true; } else { if (iDado20>5 && iDado20<15) { window.alert("Normalillo"); document.caract.bRabo.disabled=true; } else { if (iDado20>15 && iDado20<=20) { window.alert("Eres una máquina!"); document.caract.bRabo.disabled=true; } } } } var iContPJ=0; function contaPJ() { iContPJ=iContPJ+1; document.caract.contPJ.value=iContPJ; }