• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

ASP作的剪包锤游戏

发布: 2007-7-14 19:37 | 作者: 佚名    | 来源: 网络转载     | 查看: 11次 | 进入软件测试论坛讨论

领测软件测试网 <%
'*********************************************
' 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="/Files/BeyondPic/2005-12/8/051280843523419.gif"><BR>
Your ROCK crushed the computer's SCISSORS!"</CENTER>
<%
End If

ElseIf playerChoice = Scissor Then

If computerChoice = Paper Then
%>
<P><CENTER>
<IMG src="/Files/BeyondPic/2005-12/8/0512808435359102.gif"><BR>
Your SCISSORS cut up the computer's PAPER!</CENTER>
<%
End If

ElseIf playerChoice = Paper Then

If computerChoice = Rock Then
%>
<P><CENTER>
<IMG src="/Files/BeyondPic/2005-12/8/0512808435348770.gif"><BR>
Your PAPER stumped the computer's ROCK!</CENTER>
<%
End If

ElseIf playerChoice = computerChoice Then
%>
<p><CENTER>
<IMG src="/Files/BeyondPic/2005-12/8/0512808435367890.gif"><BR>
We seem to have a tie!</CENTER>
<%
End If


If computerChoice = Rock Then

If playerChoice = Scissor Then
%>
<P><CENTER>
<IMG src="/Files/BeyondPic/2005-12/8/051280843523419.gif"><BR>
The computer's ROCK crushed your SCISSORS!</CENTER>
<%
ElseIf playerChoice = computerChoice Then
%>
<P><CENTER>
<IMG src="/Files/BeyondPic/2005-12/8/0512808435367890.gif"><BR>
We seem to have a tie!</CENTER>
<%
End If

ElseIf computerChoice = Scissor Then

If playerChoice = Paper Then
%>
<P><CENTER>
<IMG src="/Files/BeyondPic/2005-12/8/0512808435321071.gif"><BR>
The computer's SCISSOR cut up your PAPER!</CENTER>
<%
ElseIf playerChoice = computerChoice Then
%>
<P><CENTER>
<IMG src="/Files/BeyondPic/2005-12/8/0512808435367890.gif"><BR>
We seem to have a tie!</CENTER>
<%
End If

ElseIf computerChoice = Paper Then

If playerChoice = Rock Then
%>
<P><CENTER>
<IMG src="/Files/BeyondPic/2005-12/8/0512808435348770.gif"><BR>
The computer's PAPER stumped your ROCK!</CENTER>
<%

ElseIf playerChoice = computerChoice Then
%>
<P><CENTER>
<IMG src="/Files/BeyondPic/2005-12/8/0512808435367890.gif"><BR>
We seem to have a tie!</CENTER>
<%
End If
ElseIf computerChoice = playerChoice Then
%>
<P><CENTER>
<IMG src="/Files/BeyondPic/2005-12/8/0512808435367890.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
%>


文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网