From 1be8c6ba58e34c8f14a518f50b31f8adda75dfcc Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Tue, 14 Nov 2023 19:13:59 -0500 Subject: [PATCH] Drawing cards. --- RoloLudo.package/DeckOfCards.class/README.md | 1 + RoloLudo.package/DeckOfCards.class/instance/draw.st | 6 ++++++ RoloLudo.package/DeckOfCards.class/instance/drawn.st | 3 +++ RoloLudo.package/DeckOfCards.class/instance/stock.st | 3 +++ RoloLudo.package/DeckOfCards.class/properties.json | 6 ++++-- 5 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 RoloLudo.package/DeckOfCards.class/instance/draw.st create mode 100644 RoloLudo.package/DeckOfCards.class/instance/drawn.st create mode 100644 RoloLudo.package/DeckOfCards.class/instance/stock.st diff --git a/RoloLudo.package/DeckOfCards.class/README.md b/RoloLudo.package/DeckOfCards.class/README.md index e69de29..09049b0 100644 --- a/RoloLudo.package/DeckOfCards.class/README.md +++ b/RoloLudo.package/DeckOfCards.class/README.md @@ -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. diff --git a/RoloLudo.package/DeckOfCards.class/instance/draw.st b/RoloLudo.package/DeckOfCards.class/instance/draw.st new file mode 100644 index 0000000..279f882 --- /dev/null +++ b/RoloLudo.package/DeckOfCards.class/instance/draw.st @@ -0,0 +1,6 @@ +accessing +draw + | taken | + taken := self stock atRandom. + self drawn add: taken. + ^ taken \ No newline at end of file diff --git a/RoloLudo.package/DeckOfCards.class/instance/drawn.st b/RoloLudo.package/DeckOfCards.class/instance/drawn.st new file mode 100644 index 0000000..085f89d --- /dev/null +++ b/RoloLudo.package/DeckOfCards.class/instance/drawn.st @@ -0,0 +1,3 @@ +accessing +drawn + ^ drawn ifNil: [drawn := OrderedCollection new] \ No newline at end of file diff --git a/RoloLudo.package/DeckOfCards.class/instance/stock.st b/RoloLudo.package/DeckOfCards.class/instance/stock.st new file mode 100644 index 0000000..af992f2 --- /dev/null +++ b/RoloLudo.package/DeckOfCards.class/instance/stock.st @@ -0,0 +1,3 @@ +accessing +stock + ^ stock := self cards copyWithoutAll: self drawn \ No newline at end of file diff --git a/RoloLudo.package/DeckOfCards.class/properties.json b/RoloLudo.package/DeckOfCards.class/properties.json index c3f19aa..4b8fce1 100644 --- a/RoloLudo.package/DeckOfCards.class/properties.json +++ b/RoloLudo.package/DeckOfCards.class/properties.json @@ -1,12 +1,14 @@ { - "commentStamp" : "", + "commentStamp" : "", "super" : "Object", "category" : "RoloLudo", "classinstvars" : [ ], "pools" : [ ], "classvars" : [ ], "instvars" : [ - "cards" + "cards", + "drawn", + "stock" ], "name" : "DeckOfCards", "type" : "normal"