Public Sub collect(ByVal nPlayer As Integer) 'this sub collects cards in from the designated player id and sets location values to . For i As Integer = 0 To 51 If activeDeck(i).PlayerID = CType(nPlayer, String) Then activeDeck(i).Location = "." activeDeck(i).PlayerID = "." End If Next End Sub
Public Function Deal(ByVal nPlayer As Integer) As String 'this sub deals a card to a nominated player and stores the player id in the active deck array Dim i As Integer = currentIndex
If activeDeck(i).Location = "." Then If currentIndex >= 51 Then currentIndex = 0 Else currentIndex = currentIndex + 1 End If activeDeck(i).Location = "+" activeDeck(i).PlayerID = CType(nPlayer, String) Return activeDeck(i).CardType End If End Function
Public Function returnCards(ByVal nplayer As Integer) As String Dim temp As String
For i As Integer = 0 To 51 If activeDeck(i).PlayerID = CType(nplayer, String) Then temp = temp & "," & activeDeck(i).CardType End If Next
Return temp End Function
Public Sub DrawCard(ByVal nCard As String, ByVal g As Graphics, ByVal x As Integer, ByVal y As Integer) Dim number As String 'will hold our face from our splitted string Dim isuit As String 'will hold our suit from our splited string Dim hdc As IntPtr = g.GetHdc() 'stores out gfx location
'split the string will be in the format ("Suit.Face") Dim temp() As String = Split(nCard, ".")
isuit = temp(0) number = temp(1)
'calls 2 routines to transform the suit/face to correct words nSuit = convertSuit(isuit) nFace = convertFace(number)
'draw our card and release the memory Try Dim Card As Integer = CType(Me.nFace, Integer) * 4 + nSuit cdtDrawExt(hdc, x, y, MyClass.width, MyClass.height, Card, 0, 0) Finally g.ReleaseHdc(hdc) End Try End Sub
Public Sub drawBack(ByVal style As cardback, ByVal g As Graphics, ByVal x As Integer, ByVal y As Integer) Dim hdc As IntPtr = g.GetHdc() Try cdtDraw(hdc, x, y, style, 1, 0) Finally g.ReleaseHdc(hdc) End Try End Sub
Public Sub Close() cdtTerm() End Sub
Private Function convertFace(ByVal iFace As String) As Face Select Case iFace Case "1" Return Face.Ace Case "2" Return Face.Two Case "3" Return Face.Three Case "4" Return Face.Four Case "5" Return Face.Five Case "6" Return Face.Six Case "7" Return Face.Seven Case "8" Return Face.Eight Case "9" Return Face.Nine Case "10" Return Face.Ten Case "11" Return Face.Jack Case "12" Return Face.Queen Case "13" Return Face.King End Select End Function
Private Function convertSuit(ByVal iSuit As String) As Suit Select Case iSuit Case "h" Return Suit.Heart Case "d" Return Suit.Club Case "s" Return Suit.Spade Case "c" Return Suit.Diamond End Select End Function
End Class
上一页 [1] [2] |