Drawing cards.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2023-11-14 19:13:59 -05:00
parent edfe4740b8
commit 1be8c6ba58
5 changed files with 17 additions and 2 deletions

View File

@ -0,0 +1 @@
I represent a deck of cards. The terminology was taken from [Glossary of card game terms](https://en.wikipedia.org/wiki/Glossary_of_card_game_terms) in Wikipedia.

View File

@ -0,0 +1,6 @@
accessing
draw
| taken |
taken := self stock atRandom.
self drawn add: taken.
^ taken

View File

@ -0,0 +1,3 @@
accessing
drawn
^ drawn ifNil: [drawn := OrderedCollection new]

View File

@ -0,0 +1,3 @@
accessing
stock
^ stock := self cards copyWithoutAll: self drawn

View File

@ -1,12 +1,14 @@
{ {
"commentStamp" : "", "commentStamp" : "<historical>",
"super" : "Object", "super" : "Object",
"category" : "RoloLudo", "category" : "RoloLudo",
"classinstvars" : [ ], "classinstvars" : [ ],
"pools" : [ ], "pools" : [ ],
"classvars" : [ ], "classvars" : [ ],
"instvars" : [ "instvars" : [
"cards" "cards",
"drawn",
"stock"
], ],
"name" : "DeckOfCards", "name" : "DeckOfCards",
"type" : "normal" "type" : "normal"