ODOBERANIE ZAPALIEK

ID
Nazov / Name:
Popis / Description:
Dlzka / Length:
Testovane pod / Tested under:

 

104
p104.html / p104.zip
Hra odoberanie zapaliek
2740b
NN 4.04, IE 4.0

UKAZKA / CLICK HERE

Zdrojovy tvar / Source code:

<html> <head> <title> JavaScript DESTINATION - P104 </title> <script language="JavaScript"> <!-- function welcome() { document.game.help.value=" Prosim udaj pocet zapaliek a stlac Start"; document.game.number.focus(); window.defaultStatus="JavaScript - Zapalky "; } function bye() { window.defaultStatus=""; } function come_on() { if(document.game.number.value<5) alert("Pocet musi byt vacsi 4"); else { document.game.help.value=" Si na tahu. Vyber si 1, 2 alebo 3."; document.game.count.value=document.game.number.value; } } function letsgo(yourchoice) { var date=new Date(),mychoice; if(document.game.count.value-yourchoice<=1) { document.game.help.value=" Vyhral si !"; document.game.count.value=1; } else { if(document.game.count.value%4==0) { if(yourchoice==1) mychoice=2; else { if(date.getSeconds()%2==0) mychoice=3; else mychoice=1; } } else if(document.game.count.value%4==1) mychoice=4-yourchoice; else if(document.game.count.value%4==2) { if(yourchoice==2) mychoice=3; else { if(date.getSeconds()%2==0) mychoice=1; else mychoice=2; } } else { if(yourchoice==1) mychoice=1; else { if(date.getSeconds()%2==0) mychoice=2; else mychoice=3; } } if(document.game.count.value-yourchoice<4) mychoice=document.game.count.value-yourchoice-1; document.game.count.value-=yourchoice+mychoice; document.game.me.value=" "+mychoice; if(document.game.count.value==1) document.game.help.value=" Zobral som "+mychoice+" zapaliek a vyhral som !"; else document.game.help.value=" Vzal som "+mychoice+" zapaliek. Si opat na tahu."; } } // --> </script> </head> <body onload="welcome()" onunload="bye()"> <center> <h1>Hra: Zapalky</h1> <form name="game"> <table border="3" cellpadding="0" cellspacing="2"> <tr> <td align="left">Kolko zapaliek ?</td> <td align="right"><input type="text" name="number" size="10"><input type="button" name="start" value=" Start " onclick="if(confirm('Vazne chces spustit hru znovu ?')) come_on()"></td> </tr> <tr> <td align="center" colspan="2"><input type="text" name="help" size="55"></td> </tr> <tr> <td align="left">Pocitadlo:</td> <td align="right"><input type="text" name="count" size="10"></td> </tr> <tr> <td align="left">Tvoja volba:</td> <td align="right"><input type="button" name="one" value=" 1 " onclick="letsgo(1)"><input type="button" name="two" value=" 2 " onclick="letsgo(2)"><input type="button" name="three" value=" 3 " onclick="letsgo(3)"></td> </tr> <tr> <td align="left">Moja volba:</td> <td align="right"><input type="text" name="me" size="3"></td> </tr> </table> </form> </center> </body> </html>
[ Navrat / BACK ]