Black Jack
Crystal Ball
Рулетка
Бесеница
Код:
<SCRIPT LANGUAGE="JavaScript">
var gameOver; var cardCount;
function Shuffle(max){
var num=Math.random()*max;
return Math.round(num)+1;
}
function getSuit(){
suit = Shuffle(4);
if(suit == 1) return "Spades";
if(suit == 2) return "Clubs";
if(suit == 3) return "Diamonds";
else return "Hearts";
}
function cardName(card){
if(card == 1) return "Ace";
if(card == 11) return "Jack";
if(card == 12) return "Queen";
if(card == 13) return "King";
return "" + card;
}
function cardValue(card,strWho){
if(card == 1) {
if(strWho =="You" && document.display.you.value >10){
document.display.say2.value=document.display.say2.value+" Low"; return 1;}
else return 11; }
if(card > 10) return 10;
return card;
}
function PickACard(strWho){
card = Shuffle(12);
suit = getSuit();
if(strWho =="You")
document.display.say2.value=(cardName(card) + " of " + suit);
else
document.display.say1.value=(cardName(card) + " of " + suit);
return cardValue(card,strWho);
}
function NewHand(form){
if(gameOver !=0)
{form.say1.value=("Hand in Play!"); form.say2.value=(""); return;}
else
{form.dealer.value = 0; form.you.value = 0; cardCount=0;
form.dealer.value = eval(form.dealer.value) + PickACard("Dealer");
form.you.value = eval(form.you.value) + PickACard("You");
gameOver= -1; cardCount+=1;}
}
function Dealer(form){
if (gameOver ==0)
{form.say1.value=("Deal the Cards!"); form.say2.value=(""); return;}
else
if(form.you.value<10)
{form.say1.value=("Not Below Ten!"); form.say2.value=("Take a Hit!"); return;}
else
if (cardCount <2)
{form.say1.value=("Minimum 2 Cards!"); form.say2.value=("Hit Again!"); return;}
else
while(form.dealer.value < 17)
{form.dealer.value = eval(form.dealer.value) + PickACard("Dealer");}
}
function User(form){
if (gameOver ==0)
{form.say1.value=("Deal the Cards!"); form.say2.value=(""); return;}
else
{cardCount+=1; form.say1.value=("You Get...");
form.you.value = eval(form.you.value) + PickACard("You");}
if(form.you.value > 21)
{form.say1.value=("You Busted!");
gameOver=0; form.numgames.value=eval(form.numgames.value)-1;}
}
function LookAtHands(form){
if (gameOver ==0 || form.you.value<10 || cardCount <2){return;}
else
if(form.dealer.value > 21)
{form.say1.value=("House Busts!"); form.say2.value=("You Win! $$$$$$");
gameOver=0; form.numgames.value=eval(form.numgames.value)+1;}
else
if(form.you.value > form.dealer.value)
{form.say1.value=("You Win!"); form.say2.value=("$$$$$$$$$$$$$$$");
gameOver=0; form.numgames.value=eval(form.numgames.value)+1;}
else
if(form.dealer.value == form.you.value)
{form.say1.value=("Game Tied!"); form.say2.value=("Try Again!");
gameOver=0; form.numgames.value=eval(form.numgames.value)-1;}
else
{form.say1.value=("House Wins!"); form.say2.value=("Tough Luck!");
gameOver=0; form.numgames.value=eval(form.numgames.value)-1;}
}
function setBj(){
gameOver=0; cardCount=0;
document.display.dealer.value="";
document.display.you.value="";
document.display.numgames.value="0";
document.display.say1.value=" Hit 'Deal'";
document.display.say2.value=" To Start!";
}
// End -->
</script>
<center>
<form name="display">
<table bgcolor="#c0c0c0" border="1" cellspacing="0" cellpadding="3">
<tr>
<td><center>Score:</center></td>
<td><center>Dealer</center></td>
<td><center><input type=text name="dealer" size="2"></center></td>
<td><center>Card(s): <input type=text name="say1" size="18" value=""></center></td>
</tr>
<tr>
<td><center><input type=text name="numgames" size="3" value="0"></center></td>
<td><center>Player</center></td>
<td><center><input type=text name="you" size="2"></center></td>
<td><center>Card(s): <input type=text name="say2" size="18" value=""></center></td>
</tr>
<tr>
<td><center><input type=button value="Deal" onClick="NewHand(this.form)"></center></td>
<td colspan=3><center>
<input type=button value="Stand" onClick="Dealer(this.form);LookAtHands(this.form);">
<input type=button value=" Hit " onClick="User(this.form)"></center></td></tr>
</table>
</form>
</center>
<p><center>
</center><p>
Crystal Ball
Код:
<table border="0" bgcolor="#000000" cellspacing="0" cellpadding="3">
<tr>
<td width="100%">
<p><font size="4" color="#FFFF00">Crystal Ball</font></p>
<font color="#CCCCFF">
<p>Please enter a yes/no question and it will respond</p>
<p>Warning: the crystal ball has a tendency to be sarcastic!</p>
<table width="40%" border="0">
<tr>
<td>
<form name="input1">
<input name="textfield" size=63>
</form>
</td>
</tr>
</table>
<table width="8%" border="0">
<tr>
<td>
<form>
<input type="button" name="button1" value="Ask Me!"
onClick="getAnswers()">
</form>
</td>
</tr>
</table>
<script language="JavaScript">
function getAnswers() {
time = new Date()
randominteger = time.getSeconds()
if (document.input1.textfield.value == "") {
alert("You dummy! You didn't enter anything into the Crystal Ball!!!")
return
}
if (randominteger <= 3) answer="Did you really think so? Hahaha, I'm laughing now at your pitiful chances."
if ((randominteger >= 4) && (randominteger <= 6)) answer ="Yeah, it it's got a 65% chance of happening."
if ((randominteger >= 7) && (randominteger <= 9)) answer ="Oh come on! No way!"
if ((randominteger >= 10) && (randominteger <= 12)) answer ="As sure as I'm made of glass, this is likely to happen."
if ((randominteger >= 13) && (randominteger <= 15)) answer ="Why are you asking A CRYSTAL BALL? Do you really believe the answers?"
if ((randominteger >= 16) && (randominteger <= 18)) answer ="Give me a break, give me a break, break me off a piece of that NO!"
if ((randominteger >= 19) && (randominteger <= 21)) answer ="Good chances lie on the horizon."
if ((randominteger >= 22) && (randominteger <= 24)) answer ="Ask me again, I am restless and overworked."
if ((randominteger >= 25) && (randominteger <= 27)) answer ="Do you know how the Crystal Ball works? There's your answer."
if ((randominteger >= 28) && (randominteger <= 30)) answer ="As the sun is hot, your answer is YES."
if ((randominteger >= 31) && (randominteger <= 33)) answer ="Did you get drunk last weekend? There's your answer."
if ((randominteger >= 34) && (randominteger <= 36)) answer ="Forget about it"
if ((randominteger >= 37) && (randominteger <= 39)) answer ="Yeah, it could happen. 80% chance."
if ((randominteger >= 40) && (randominteger <= 42)) answer ="Hitler has a better chance of raising from the dead."
if ((randominteger >= 43) && (randominteger <= 45)) answer ="If you really think so, then it shall be."
if ((randominteger >= 46) && (randominteger <= 48)) answer ="Who said ambiguous answers were bad? Not me, so YES!"
if ((randominteger >= 49) && (randominteger <= 51)) answer ="You think I'm going to answer that after a day of hard work? Ask again later."
if ((randominteger >= 52) && (randominteger <= 54)) answer ="If you own a pet, yes. Otherwise, no."
if ((randominteger >= 55) && (randominteger <= 57)) answer ="The sun will rise in the east and set in the west. Thank you Captain Obvious. YES!"
if ((randominteger >= 58) && (randominteger <= 60)) answer ="I'm laughing hard, very hard. You'd better ask again."
var newWindow = window.open("","Results","width=300,height=300")
newWindow.document.write("<html><body bgcolor='#000000' text='#FFFFCC' link='#00FFFF' alink='#000066' vlink='#6666FF'>")
newWindow.document.write("<P align='center'><font size='4' color='#FFFF00'>Your Question:</P><P></P><font size='3' color='#FFFFCC'>")
newWindow.document.write("<P align='center'>" + document.input1.textfield.value + "</P>")
newWindow.document.write("<P></P><P></P><P></P><P align='center'><font size='4' color='#FFFF00'>The Great Crystal Ball Has Answered:</P><P></P>")
newWindow.document.write("<font size='3' color='#FFFFCC'>")
newWindow.document.write("<P align='center'>" + answer + "</P>")
newWindow.document.write("<P></P><P></P><P align='center'><A HREF='javascript:window.close()'>Close Me</A></P>")
}
</script>
</font>
</td>
</tr>
</table>
Рулетка
Код:
<div align="center"><table border="0" width="350" cellspacing="0" cellpadding="0">
<form name="fire">
Load number of bullets (1-6):<br><input name="bullets" type="text" size=3 value=1><br>
<p>
<input name="message" type="button" value="Play Roulette!" onClick="fireit()">
</p>
</form>
<script>
function fireit(){
var theone=Math.floor(Math.random()*6)
if (theone<=document.fire.bullets.value-1)
alert("Bang. You\'re dead!")
else{
document.fire.message.value="Whew. Got lucky!"
setTimeout("document.fire.message.value='Play Roulette'",500)
}
}
</script></table></div>
Бесеница
Код:
<SCRIPT language=JavaScript type=text/javascript>
</SCRIPT>
<CENTER>
<H1>The Game Of Hangman</H1>
<P><B>Can You Get Any Of</B></P>
<P><B>The Fifteen Words</B></P></CENTER>
<HR>
<CENTER>
<FORM name=game><PRE><TEXTAREA cols=18 name=status onfocus=stayAway() rows=7></TEXTAREA>
</PRE>
<P><INPUT name=toGuess onfocus=stayAWAY()><B>Word to guess</B><BR></P>
<P> <INPUT
name=guessed onfocus=stayAway()><B> Letters guessed so far</B><BR></P>
<P><B>Enter your next guess.</B></P><INPUT onclick="guess('A')" type=button value=" A "><INPUT onclick="guess('B')" type=button value=" B "><INPUT onclick="guess('C')" type=button value=" C "><INPUT onclick="guess('D')" type=button value=" D "><INPUT onclick="guess('E')" type=button value=" E "><INPUT onclick="guess('F')" type=button value=" F "><INPUT onclick="guess('G')" type=button value=" G "><INPUT onclick="guess('H')" type=button value=" H "><INPUT onclick="guess('I')" type=button value=" I "><INPUT onclick="guess('J')" type=button value=" J "><INPUT onclick="guess('K')" type=button value=" K "><INPUT onclick="guess('L')" type=button value=" L "><INPUT onclick="guess('M')" type=button value=" M "><INPUT onclick="guess('N')" type=button value=" N "><INPUT onclick="guess('O')" type=button value=" O "><INPUT onclick="guess('P')" type=button value=" P "><INPUT onclick="guess('Q')" type=button value=" Q "><INPUT onclick="guess('R')" type=button value=" R "><INPUT onclick="guess('S')" type=button value=" S "><INPUT onclick="guess('T')" type=button value=" T "><INPUT onclick="guess('U')" type=button value=" U "><INPUT onclick="guess('V')" type=button value=" V "><INPUT onclick="guess('W')" type=button value=" W "><INPUT onclick="guess('X')" type=button value=" X "><INPUT onclick="guess('Y')" type=button value=" Y "><INPUT onclick="guess('Z')" type=button value=" Z ">
<P><INPUT name=restart onclick=startAgain() type=button value="-- Start Again --"></P>
<SCRIPT type=text/javascript>
</SCRIPT>
</FORM>
<HR>