forked from pharo-graphics/Tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
70 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Is sent by ==MgdCardModel== after the card is removed from the ==MgdGameModel== |
2 changes: 1 addition & 1 deletion
2
src/Bloc-MemoryGame-Demo.package/MgdCardDisappearAnnouncement.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
I am a visual card modelled by ==MgdCardModel== | ||
|
||
A model should be attached by sending #card: to the card element. | ||
Card element reacts on model events such as MgdCardFlippedAnnouncement and MgdCardDisappearAnnouncement after card is flipped or disappeared. | ||
|
||
By default I do not have a visual representations of the face and back |
4 changes: 2 additions & 2 deletions
4
src/Bloc-MemoryGame-Demo.package/MgdCardElement.class/instance/card..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
accessing | ||
card: aMgCard | ||
card := aMgCard. | ||
card announcer when: MgCardFlippedAnnouncement send: #onFlipped to: self. | ||
card announcer when: MgCardDisappearAnnouncement send: #onDisappear to: self | ||
card announcer when: MgdCardFlippedAnnouncement send: #onFlipped to: self. | ||
card announcer when: MgdCardDisappearAnnouncement send: #onDisappear to: self |
3 changes: 3 additions & 0 deletions
3
src/Bloc-MemoryGame-Demo.package/MgdCardElement.class/instance/cornerRadius.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
visual properties | ||
cornerRadius | ||
"Return a number representing a corner radius" | ||
<return: #Number> | ||
|
||
^ 12 |
2 changes: 1 addition & 1 deletion
2
src/Bloc-MemoryGame-Demo.package/MgdCardElement.class/instance/onFlipped.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
announcement - handling | ||
onFlipped | ||
self card flipped | ||
self card isFlipped | ||
ifTrue: [ self onFlippedFace ] | ||
ifFalse: [ self onFlippedBack ] |
2 changes: 1 addition & 1 deletion
2
src/Bloc-MemoryGame-Demo.package/MgdCardElement.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Is sent by ==MgdCardModel== after the card is flipped |
2 changes: 1 addition & 1 deletion
2
src/Bloc-MemoryGame-Demo.package/MgdCardFlippedAnnouncement.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 10 additions & 1 deletion
11
src/Bloc-MemoryGame-Demo.package/MgdCardModel.class/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
I am a card model that can be flipped or not. | ||
When card is flipped player should see a symbol that is used to compare two cards. | ||
When card is flipped player should see a symbol that is used to compare two cards. | ||
|
||
!! Examples: | ||
|
||
[[[ | ||
| cardModel | | ||
cardModel := MgdCardModel new symbol: $a. | ||
cardModel flip. | ||
cardModel disappear | ||
]]] |
2 changes: 2 additions & 0 deletions
2
src/Bloc-MemoryGame-Demo.package/MgdCardModel.class/instance/isFlipped.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
testing | ||
isFlipped | ||
"Return true if card is flipped and its face (symbol) is visible, false otherwise" | ||
<return: #Number> | ||
|
||
^ flipped |
2 changes: 1 addition & 1 deletion
2
src/Bloc-MemoryGame-Demo.package/MgdCardModel.class/instance/notifyDisappear.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
notifying | ||
notifyDisappear | ||
"Notify all observers that I disappeared from the game" | ||
self announcer announce: MgCardDisappearAnnouncement new | ||
self announcer announce: MgdCardDisappearAnnouncement new |
2 changes: 1 addition & 1 deletion
2
src/Bloc-MemoryGame-Demo.package/MgdCardModel.class/instance/notifyFlipped.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
notifying | ||
notifyFlipped | ||
"Notify all observers that my flipped state was changed (from flipped to not or the other way around)" | ||
self announcer announce: MgCardFlippedAnnouncement new | ||
self announcer announce: MgdCardFlippedAnnouncement new |
4 changes: 4 additions & 0 deletions
4
src/Bloc-MemoryGame-Demo.package/MgdCardModel.class/instance/symbol..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
accessing | ||
symbol: aCharacter | ||
"Initialize the card with a given symbol as a character" | ||
self | ||
assert: [ aCharacter isNotNil ] | ||
description: [ 'Character must not be nil' ]. | ||
|
||
symbol := aCharacter |
2 changes: 2 additions & 0 deletions
2
src/Bloc-MemoryGame-Demo.package/MgdCardModel.class/instance/symbol.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
accessing | ||
symbol | ||
"Return a symbol that should be displayed when card is flipped and face is visible" | ||
<return: #Character> | ||
|
||
^ symbol |
2 changes: 1 addition & 1 deletion
2
src/Bloc-MemoryGame-Demo.package/MgdCardModel.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/Bloc-MemoryGame-Demo.package/monticello.meta/categories.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
SystemOrganization addCategory: #'Bloc-MemoryGame-Demo'! | ||
SystemOrganization addCategory: 'Bloc-MemoryGame-Demo-Elements'! | ||
SystemOrganization addCategory: 'Bloc-MemoryGame-Demo-Events'! | ||
SystemOrganization addCategory: 'Bloc-MemoryGame-Demo-Model'! | ||
SystemOrganization addCategory: #'Bloc-MemoryGame-Demo-Elements'! | ||
SystemOrganization addCategory: #'Bloc-MemoryGame-Demo-Events'! | ||
SystemOrganization addCategory: #'Bloc-MemoryGame-Demo-Model'! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
I am a card model that can be flipped or not. | ||
When card is flipped player should see a symbol that is used to compare two cards. | ||
When card is flipped player should see a symbol that is used to compare two cards. | ||
|
||
!! Examples: | ||
|
||
[[[ | ||
| cardModel | | ||
cardModel := MgCardModel new symbol: $a. | ||
cardModel flip. | ||
cardModel disappear | ||
]]] |
2 changes: 2 additions & 0 deletions
2
src/Bloc-MemoryGame.package/MgCardModel.class/instance/isFlipped.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
testing | ||
isFlipped | ||
"Return true if card is flipped and its face (symbol) is visible, false otherwise" | ||
<return: #Number> | ||
|
||
^ flipped |
4 changes: 4 additions & 0 deletions
4
src/Bloc-MemoryGame.package/MgCardModel.class/instance/symbol..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
accessing | ||
symbol: aCharacter | ||
"Initialize the card with a given symbol as a character" | ||
self | ||
assert: [ aCharacter isNotNil ] | ||
description: [ 'Character must not be nil' ]. | ||
|
||
symbol := aCharacter |
2 changes: 2 additions & 0 deletions
2
src/Bloc-MemoryGame.package/MgCardModel.class/instance/symbol.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
accessing | ||
symbol | ||
"Return a symbol that should be displayed when card is flipped and face is visible" | ||
<return: #Character> | ||
|
||
^ symbol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
SystemOrganization addCategory: #'Bloc-MemoryGame'! | ||
SystemOrganization addCategory: 'Bloc-MemoryGame-Elements'! | ||
SystemOrganization addCategory: 'Bloc-MemoryGame-Events'! | ||
SystemOrganization addCategory: 'Bloc-MemoryGame-Examples'! | ||
SystemOrganization addCategory: 'Bloc-MemoryGame-Model'! | ||
SystemOrganization addCategory: #'Bloc-MemoryGame-Elements'! | ||
SystemOrganization addCategory: #'Bloc-MemoryGame-Events'! | ||
SystemOrganization addCategory: #'Bloc-MemoryGame-Examples'! | ||
SystemOrganization addCategory: #'Bloc-MemoryGame-Model'! |