<%
*********************************************
this is a simple game of rock scissors paper
feel free to do whatever you like with this
script! -ian s. carroll
*********************************************
*********************************************
this function generates a random number
*********************************************
function computerchooses()
dim randomnum
dim choice
randomize
randomnum = int(rnd*15)+1
if randomnum = 1 or randomnum = 3 or randomnum = 7 or randomnum = 8 or randomnum = 15 or randomnum = 12 then
choice = "r"
elseif randomnum = 2 or randomnum = 6 or randomnum = 11 or randomnum = 13 then
choice = "s"
else
choice = "p"
end if
computerchooses = choice
end function
*********************************************
this function simply determines the winner
of the game
*********************************************
sub determinewinner(playerchoice, computerchoice)
const rock = "r"
const scissor = "s"
const paper = "p"
dim tempplayer, tempcomputer
if playerchoice = rock then
if computerchoice = scissor then
%>
<p><center>
<img src="images/rock_beats_scissors.gif"><br>
your rock crushed the computers scissors!"</center>
<%
end if
elseif playerchoice = scissor then
if computerchoice = paper then
%>
<p><center>
<img src="images/scissors_beats_paper.gif"><br>
your scissors cut up the computers paper!</center>
<%
end if
elseif playerchoice = paper then
if computerchoice = rock then
%>
<p><center>
<img src="images/paper_beats_rock.gif"><br>
your paper stumped the computers rock!</center>
<%
end if
elseif playerchoice = computerchoice then
%>
<p><center>
<img src="images/tie.gif"><br>
we seem to have a tie!</center>
<%
end if
if computerchoice = rock then
if playerchoice = scissor then
%>
<p><center>
<img src="images/rock_beats_scissors.gif"><br>
the computers rock crushed your scissors!</center>
<%
elseif playerchoice = computerchoice then
%>
<p><center>
<img src="images/tie.gif"><br>
we seem to have a tie!</center>
<%
end if
elseif computerchoice = scissor then
if playerchoice = paper then
%>
<p><center>
<img src="images/scissors_beats_paper.gif"><br>
the computers scissor cut up your paper!</center>
<%
elseif playerchoice = computerchoice then
%>
<p><center>
<img src="images/tie.gif"><br>
we seem to have a tie!</center>
<%
end if
elseif computerchoice = paper then
if playerchoice = rock then
%>
<p><center>
<img src="images/paper_beats_rock.gif"><br>
the computers paper stumped your rock!</center>
<%
elseif playerchoice = computerchoice then
%>
<p><center>
<img src="images/tie.gif"><br>
we seem to have a tie!</center>
<%
end if
elseif computerchoice = playerchoice then
%>
<p><center>
<img src="images/tie.gif"><br>
we seem to have a tie!</center>
<%
end if
end sub
*********************************************
this function will cause the game to
execute unless a different action was chosen
*********************************************
sub playgame()
%>
<center><h1>welcome to the famous game: rock, scissors, paper!<br>
good luck!</h1><br><br>
<h3>please choose your weapon:</h3><br>
<form action="index.asp?action=winner" method="post">
<table>
<tr valign=top>
<td>rock</td>
<td><input type="radio" name="playerselect" value="r"></td>
</tr>
<tr valign=top>
<td>scissor</td>
<td><input type="radio" name="playerselect" value="s"></td>
</tr>
<tr valignn=top>
<td>paper</td>
<td><input type="radio" name="playerselect" value="p"></td>
</tr>
</table>
<input type="submit" value="play game">
</center>
<%
end sub
********************************************
this function will be run if the game is
played
********************************************
sub playagain()
%>
<center>would you like to play this game again?</center>
<br>
<center><a href="index.asp">yes</a><br><a href="index.asp?action=gameover">no</a><br></center>
<%
end sub
*********************************************
this function will be displayed will the
person chooses to end the game
*********************************************
sub endgame()
response.buffer = true
response.redirect "http://www.luckybbs.com"
end sub
*********************************************
the basic run-time script
*********************************************
dim player, computer
dim gameaction
gameaction = request.querystring("action")
select case gameaction
case "winner"
player = request.form("playerselect")
computer = computerchooses
determinewinner player, computer
response.write "<br><br>"
playagain
case "again"
playagain
case "gameover"
endgame
case else
playgame
end select
%>
