轉帖一個ASP作的剪包錘遊戲

來源:互聯網
上載者:User
<%
'*********************************************
' 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=http://www.163design.net/a/y/"images/rock_beats_scissors.gif"><BR>
            Your ROCK crushed the computer's SCISSORS!"</CENTER>
            <%
        End If
    
    ElseIf playerChoice = Scissor Then
        
        If computerChoice = Paper Then
            %>
            <P><CENTER>
            <IMG SRC=http://www.163design.net/a/y/"images/scissors_beats_paper.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=http://www.163design.net/a/y/"images/paper_beats_rock.gif"><BR>
            Your PAPER stumped the computer's ROCK!</CENTER>
            <%
        End If

    ElseIf playerChoice = computerChoice Then
        %>
        <p><CENTER>
        <IMG SRC=http://www.163design.net/a/y/"images/tie.gif"><BR>
        We seem to have a tie!</CENTER>
        <%
    End If


    If computerChoice = Rock Then

        If playerChoice = Scissor Then
           &nb



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.