Anonymous user
Go Fish/PureBasic: Difference between revisions
m
no edit summary
mNo edit summary |
mNo edit summary |
||
Line 12:
Structure _membersCardCollectionClass
*vtable.i
card.i[#MaxCards] ;collection content, stores rank# for each card, suits aren't used
EndStructure
Line 89:
Protected i
If isDeck
*this\
For i = 0 To #MaxCards - 1
*this\card[i] = (i % #NumCardRanks) + 1
Next
Else
*this\
EndIf
EndProcedure
Procedure CC_countCards(*this._membersCardCollectionClass)
ProcedureReturn *this\
EndProcedure
Procedure CC_countMatchingCards (*this._membersCardCollectionClass, rank)
Protected i, count
For i = 0 To *this\
If *this\card[i] = rank
count + 1
Line 120:
Procedure CC_pushCard(*this._membersCardCollectionClass, rank)
If *this\
*this\
*this\card[*this\
EndIf
EndProcedure
Line 128:
Procedure CC_popCard(*this._membersCardCollectionClass)
Protected rank
If *this\
rank = *this\card[*this\
*this\
EndIf
ProcedureReturn rank ;returns #Null if no cards are in collection
Line 139:
Protected i
For i = *this\
If *this\card[i] = rank
If *this\
MoveMemory(@*this\card[i + 1], @*this\card[i], SizeOf(Integer) * *this\
EndIf
*this\
EndIf
Next
Line 153:
Protected i, cardsTransfered, *src._membersCardCollectionClass = *source, blankcard
If *source <> #Null
For i = *src\
If *src\card[i] = rank
*this\
*this\card[*this\
If *src\
MoveMemory(@*src\card[i + 1], @*src\card[i], SizeOf(Integer) * (*src\
EndIf
*src\
cardsTransfered + 1
EndIf
Line 171:
Procedure CC_shuffle(*this._membersCardCollectionClass)
Protected w, i
If *this\
Dim shuffled(*this\
For i = *this\
w = Random(i)
shuffled(i) = *this\card[w]
Line 182:
Next
For i = 0 To *this\
*this\card[i] = shuffled(i)
Next
Line 191:
Protected i, output$
For i = 0 To *this\
output$ + StringField(#ShortCardRanks$, *this\card[i],";")
If i <> *this\
Next
ProcedureReturn output$
Line 200:
Procedure CC_sortCards(*this._membersCardCollectionClass)
Protected low, high
Protected firstIndex, lastIndex = *this\
If lastIndex > firstIndex + 1
|