59 lines
1.2 KiB
Plaintext
59 lines
1.2 KiB
Plaintext
include "Tlbx GameplayKit.incl"
|
|
|
|
void local fn PrintCards( cards as CFArrayRef )
|
|
int c = 0
|
|
for CFStringRef card in cards
|
|
print card;@" ";
|
|
c ++
|
|
if ( c % 13 == 0 ) then c = 0 : print
|
|
next
|
|
end fn
|
|
|
|
void local fn PlayingCards
|
|
window 1, @"Playing cards", (0,0,600,400)
|
|
|
|
CFStringRef suit = @"CDHS", pip = @"A23456789TJQK"
|
|
CFMutableArrayRef cards = fn MutableArrayNew, p1 = fn MutableArrayNew, p2 = fn MutableArrayNew
|
|
int c = 0, d
|
|
|
|
print @"Deck:"
|
|
for int s = 0 to len(suit) - 1
|
|
for int p = 0 to len(pip) - 1
|
|
cards[c] = concat(pip[p],suit[s])
|
|
c++
|
|
next
|
|
next
|
|
fn PrintCards( cards )
|
|
|
|
print @"\nShuffled deck:"
|
|
cards = fn MutableArrayWithArray(fn ArrayShuffledArray(cards))
|
|
fn PrintCards( cards )
|
|
|
|
print @"\nDeal: "
|
|
print @" Player 1: ";
|
|
for d = 0 to 4
|
|
p1[d] = cards[0]
|
|
MutableArrayRemoveObjectAtIndex( cards, 0 )
|
|
print p1[d];@" ";
|
|
p2[d] = cards[0]
|
|
MutableArrayRemoveObjectAtIndex( cards, 0 )
|
|
next
|
|
|
|
print : print @" Player 2: ";
|
|
for d = 0 to 4
|
|
print p2[d];@" ";
|
|
next
|
|
|
|
print : print @"\nCurrent deck:"
|
|
c = 0
|
|
for CFStringRef card in cards
|
|
print card;@" ";
|
|
c ++
|
|
if ( c % 13 == 0 ) then c = 0 : print
|
|
next
|
|
end fn
|
|
|
|
fn PlayingCards
|
|
|
|
HandleEvents
|