Adding the scripts
Switch to the Script Editor and add the following public instance scripts:
suits
"Answer an ordered collection of cards,
one for each suit in the discard deck, with a blank faceValue."
| aDictionary anOC |
anOC := OrderedCollection new.
aDictionary := Dictionary new.
"Determine the unique suits and their associated icons."
((self subpartNamed: 'Discard Deck') deck) do: [:card |
aDictionary at: (card suit) put: (card icon)].
"Create a card to represent each suit in the deck."
aDictionary keysAndValuesDo: [:suit :icon |
anOC add: (Card new
suit: suit;
faceValue: ' ';
faceUp: true;
rank: 0;
icon: icon;
flippedIcon: nil;
hasChildren: true )].
^anOC
The suits script is used to establish the root structure for the tree.
childrenRequested: callData
"Answer the ordered collection of all cards in the deck
whose suit matches the input item's suit."
| anOC suit |
anOC := OrderedCollection new.
suit := callData item suit.
(self subpartNamed: 'Discard Deck') deck do: [:card |
card suit = suit ifTrue: anOC add: card]].
callData children: anOC
The childrenRequested: script sets the callData parameter's children attribute.
Last modified date: 01/29/2015