Extra practice
Try disabling the Take a card menu item in the BlackJackPlayerView visual part for the same conditions that prevent a drop. One way to do this is to create a boolean attribute in BlackJackPlayerView and enhance canTakeCard to set it. For example:
1. Use the Public Interface Editor to create canAcceptCard and its default scripts.
2. Go to the Script Editor and change the canTakeCard method as follows:
canTakeCard
"Answer false if the player has a 5-card trolley,
a winning hand (21), or is busted (over 21)."
| sum items result |
sum := 0.
items := (self subpartNamed: 'Container Details1') items.
items do: [:card | sum := sum + (card rank)].
result := (items size > 4 or: sum > 20]) not.
self canAcceptCard: result.
^result
3. Make the following connections from the Take a card menu choice:
a. From the enabled attribute to the canAcceptCard attribute.
b. From the clicked event to the canTakeCard script.
Last modified date: 01/29/2015