From 014eba59374634f73dd8f24a48c87148151751ee Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Tue, 28 Nov 2023 12:07:32 -0500 Subject: [PATCH] Recovering game reseting from last crash. --- RoloLudo.package/DeckOfCards.class/instance/draw..st | 7 +++++-- RoloLudo.package/DeckOfCards.class/instance/drawAll..st | 3 +++ RoloLudo.package/DeckOfCards.class/instance/drawn..st | 3 +++ RoloLudo.package/DeckOfCards.class/instance/reset.st | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 RoloLudo.package/DeckOfCards.class/instance/drawAll..st create mode 100644 RoloLudo.package/DeckOfCards.class/instance/drawn..st diff --git a/RoloLudo.package/DeckOfCards.class/instance/draw..st b/RoloLudo.package/DeckOfCards.class/instance/draw..st index 22675f3..2b5b933 100644 --- a/RoloLudo.package/DeckOfCards.class/instance/draw..st +++ b/RoloLudo.package/DeckOfCards.class/instance/draw..st @@ -1,3 +1,6 @@ accessing -draw: aCollection - drawn := aCollection \ No newline at end of file +draw: card + self stock + detect: [ :each | each = card ] + ifFound: [self drawn add: card ] + ifNone: [ ^ nil ] \ No newline at end of file diff --git a/RoloLudo.package/DeckOfCards.class/instance/drawAll..st b/RoloLudo.package/DeckOfCards.class/instance/drawAll..st new file mode 100644 index 0000000..029c978 --- /dev/null +++ b/RoloLudo.package/DeckOfCards.class/instance/drawAll..st @@ -0,0 +1,3 @@ +accessing +drawAll: aCollection + self drawn addAll: aCollection \ 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..de0e5ed --- /dev/null +++ b/RoloLudo.package/DeckOfCards.class/instance/drawn..st @@ -0,0 +1,3 @@ +accessing +drawn: aCollection + drawn := aCollection \ No newline at end of file diff --git a/RoloLudo.package/DeckOfCards.class/instance/reset.st b/RoloLudo.package/DeckOfCards.class/instance/reset.st index 083bac2..4b96ab0 100644 --- a/RoloLudo.package/DeckOfCards.class/instance/reset.st +++ b/RoloLudo.package/DeckOfCards.class/instance/reset.st @@ -1,5 +1,5 @@ accessing reset - self draw: OrderedCollection new. + self drawn: OrderedCollection new. self cards: self class initialize cards. ^ self \ No newline at end of file