Anonymous user
Playing cards: Difference between revisions
→{{header|PureBasic}}
Line 1,116:
Structure _membersDeckClass
*vtable.i
cards.card[#MaxCards] ;deck content
EndStructure
Interface
Init()
shuffle()
Line 1,132:
Static suits.s = "Diamonds Clubs Hearts Spades"
Protected c.s
If isAbbr
Line 1,157 ⟶ 1,156:
;isAbbr is #True if the card dealt is abbrieviated to 2 characters
Protected c.card
;deck is empty
c = *this\cards[*this\Size]▼
ProcedureReturn ""
▲ *this\Size - 1
Else
ProcedureReturn _formatCardInfo(@c, isAbbr)▼
*this\size - 1
▲ ProcedureReturn _formatCardInfo(@c, isAbbr)
EndIf
EndProcedure
Line 1,167 ⟶ 1,170:
Protected i
For i = 0 To *this\
Print(_formatCardInfo(@*this\cards[i], isAbbr))
If i <> *this\
Next
PrintN("")
Line 1,177 ⟶ 1,180:
;works with decks of any size
Protected w, i
Dim shuffled.card(*this\
For i = *this\
w = Random(i)
shuffled(i) = *this\cards[w]
Line 1,188 ⟶ 1,191:
Next
For i = 0 To *this\
*this\cards[i] = shuffled(i)
Next
Line 1,197 ⟶ 1,200:
If *newDeck
*newDeck\vtable = ?vTable_deckClass
*newDeck\
setInitialValues(*newDeck)
EndIf
Line 1,219 ⟶ 1,222:
OpenConsole()
Define deck.
Define deck2.
If deck = 0 Or deck2 = 0
|