Thursday, April 14, 2011

Showing a Hand

We have created a word to display the cards in a specific hand:
: ?emptyhand
gethandcardcount 0=
;

: showhand
?emptyhand if
." Empty Hand "
else
gethandcardcount 0 do
dup
i
swap
+
c@ . ." "
loop
then
;

The use for this word is similiar to that of the drawcard word... simply push the hand in question to the stack and the the showhand word, as follows:
playerhand showhand

Below is a screen capture of drawcard and showhand in action.

No comments:

Post a Comment