| 
        
          | 
              
                | Author |  Topic  |  |  
                | eggyfartsJunior Member
 
   
 
                New Zealand200 Posts
 | 
                    
                      |  Posted - 27 May 2001 :  17:11:34   
 |  
                      | Ok, I have my very own snitz forum up and running at  http://builderscrack.cjb.net . Now i have constructed this simple blackjack game and I want to make it into a game for my forum. I have seen on another forum another game setup in the way i want and that is where before people actually play the game, they bet a certain ammount of money (fake) and if the win they get that ammount back and if they lose they get that ammount take off thier total. And when new users sign up they get a set ammount (i think it was 100) and the other thing they did was each time you posted a message on any forum, you get  a reputation point and each bet you make, you lose 1 point. The total ammount of money each person had was viewabel on the little sidebar each post had. Now i asked this guy if he could send the changes but he said he diidnt add comments when he put them in so he cant find them again. He said he added 2 new tabels to the DB and some stuff to post_info.asp . Can any of you guys help me because i dont know lots about asp and the users on my board wanna play a game so any help would be appreaciated. Sorry if you dont understand the post or there are spelling/grammer mistakes, just post your question and i willtype it out slowly and carefuly.
 
 Cheers,
 EggyFarts
 
 
 |  |  
                | eggyfartsJunior Member
 
   
 
                New Zealand200 Posts
 | 
                    
                      |  Posted - 27 May 2001 :  17:13:28   
 |  
                      | Here is the blackjack game source code. 
 
 
 
 <%
 
 Option Explicit
 
 
 '------------------------------------------------
 ' History Routines
 '------------------------------------------------
 sub ClearHistory
 
 Dim q
 For q = 1 to 10
 Session("DHistory" & q) = ""
 Session("UHistory" & q) = ""
 next
 
 end sub
 
 sub WriteHistory(Entity,Message)
 
 Dim q
 
 q = 1
 While Session( Left(Entity,1) & "History" & q) <> ""
 q = q + 1
 Wend
 Session( Left(Entity,1) & "History" & q) = Message
 
 end sub
 
 Function ReadHistory(Entity)
 
 Dim returnValue,q,currentmessage
 
 returnvalue = ""
 for q = 1 to 10
 currentmessage = Session( Left(Entity,1) & "History" & q)
 
 If currentmessage <> "" Then
 returnvalue = returnvalue & "- " & currentmessage & "<br>"
 end if
 next
 
 ReadHistory = returnValue
 
 end Function
 
 '------------------------------------------------
 ' Select a random card
 '------------------------------------------------
 function pickCard()
 
 Dim iRandom
 
 Randomize()
 iRandom = Int(13 * Rnd + 1)
 pickCard = iRandom
 
 end function
 
 
 '------------------------------------------------
 ' Select a random suit
 '------------------------------------------------
 function pickSuit()
 
 Dim iRandom
 
 Randomize()
 iRandom = Int(4 * Rnd + 1)
 
 if iRandom = 1 then
 pickSuit = "Spades"
 elseif iRandom = 2 then
 pickSuit = "Clubs"
 elseif iRandom = 3 then
 pickSuit = "Diamonds"
 else
 pickSuit = "Hearts"
 end if
 
 end function
 
 
 '------------------------------------------------
 ' Translate card number to words
 '------------------------------------------------
 function cardName(card)
 
 if card = 1 then
 cardName = "Ace"
 elseif card = 11 then
 cardName = "Jack"
 elseif card = 12 then
 cardName = "Queen"
 elseif card = 13 then
 cardName = "King"
 else
 cardName = card
 end if
 
 end function
 
 
 '------------------------------------------------
 ' Work out value of card
 '------------------------------------------------
 function cardValue(card)
 
 if card = 1 then
 cardValue = 11
 elseif card > 10 Then
 cardValue = 10
 else
 cardValue = card
 end if
 
 end function
 
 
 '------------------------------------------------
 ' Work out value of card
 '------------------------------------------------
 function selectCard(strWho)
 
 Dim iCardNum,theCard
 iCardNum = pickCard
 
 theCard = CardName(iCardNum)  & " of " & pickSuit
 
 Response.Write strWho & " picked a " & theCard & "<br>"
 selectCard = CardValue(iCardNum)
 
 WriteHistory strWho , theCard
 
 end function
 
 '------------------------------------------------
 ' Show current status on screen
 '------------------------------------------------
 sub ReportStatus
 
 Response.Write "<p>"
 Response.Write "<table border=3><tr><td>Player</td><td>Hand</td><td>Score</td></tr>"
 Response.Write "<tr><td>You</td><td>" & ReadHistory("User") & "</td>"
 Response.Write "<td>" & Session("User") & "</td></tr>"
 Response.Write "<tr><td>Dealer</td><td>" & ReadHistory("Dealer") & "</td>"
 Response.Write "<td>" & Session("Dealer") & "</td></tr></table>"
 
 end sub
 
 '------------------------------------------------
 ' Work out value of card
 '------------------------------------------------
 sub NewHand
 
 ClearHistory
 Session("Dealer") = 0
 Session("User") = 0
 
 Session("Dealer") = Session("Dealer") + SelectCard("Dealer")
 Session("User") = Session("User") + SelectCard("User")
 Session("GameOver") = False
 
 ReportStatus
 
 end Sub
 
 '------------------------------------------------
 ' Dealer Move
 '------------------------------------------------
 sub DealerMove
 
 while Session("Dealer") < 17
 Session("Dealer") = Session("Dealer") + SelectCard("Dealer")
 wend
 
 ReportStatus
 
 end sub
 
 
 '------------------------------------------------
 ' You Move
 '------------------------------------------------
 sub UserMove
 
 Session("User") = Session("User") + SelectCard("User")
 if Session("User") > 21 Then
 Response.Write "<h2>You busted! DAMM!</h2>"
 Session("GameOver") = True
 end if
 
 ReportStatus
 
 end sub
 
 
 '------------------------------------------------
 ' Get Game Status
 '------------------------------------------------
 Sub LookAtHands
 
 if Session("Dealer") > 21 Then
 Response.Write "<h2>House busts!  You win! YAY</H2>"
 elseif Session("User") > Session("Dealer") Then
 Response.Write "<h2>You win! YAY</H2>"
 elseif Session("User") = Session("Dealer") Then
 Response.Write "<h2>Push!</H2>"
 else
 Response.Write "<h2>House wins!</H2>"
 end if
 Session("GameOver") = True
 
 End Sub
 
 
 ' Maincode starts here
 Dim action
 
 Response.Write "<center>"
 
 action = Request("action") & ""
 If action = "Hit Me" Then
 UserMove
 Elseif action = "Stand" Then
 DealerMove
 LookAtHands
 Else
 NewHand
 End If
 
 Response.Write "<form action=blacksource.asp>"
 If Session("GameOver") <> True Then
 Response.Write "<INPUT TYPE=SUBMIT NAME=action VALUE='Hit Me'>"
 Response.Write "<INPUT TYPE=SUBMIT NAME=action VALUE='Stand'>"
 End if
 Response.Write "<INPUT TYPE=SUBMIT NAME=action VALUE='New Hand'>"
 Response.Write "</FORM>"
 
 Response.Write "</center>"
 %>
 
 
 
 
 
 
 
 Cheers,
 EggyFarts
 
 
 |  
                      |  |  |  
                |  |  Topic  |  |  |  |