generated from uca-argentina/project-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made extract methods. Implemented CardHistory.
- Loading branch information
1 parent
bd5173d
commit f2cf9ca
Showing
15 changed files
with
138 additions
and
68 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
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
Class { | ||
#name : #CardHistory, | ||
#superclass : #Object, | ||
#instVars : [ | ||
'thrownCards' | ||
], | ||
#category : #'IngSoft2-Model-Card' | ||
} | ||
|
||
{ #category : #acccessing } | ||
CardHistory >> add: aCard [ | ||
thrownCards add: aCard | ||
] | ||
|
||
{ #category : #initialization } | ||
CardHistory >> initialize [ | ||
thrownCards := OrderedCollection new | ||
] | ||
|
||
{ #category : #acccessing } | ||
CardHistory >> last [ | ||
^ thrownCards last copy | ||
] | ||
|
||
{ #category : #acccessing } | ||
CardHistory >> remove: aCard [ | ||
| cardsIdenticalToCard cardsNotIdenticalToCard | | ||
cardsIdenticalToCard := self selectIdenticalTo: aCard. | ||
self removeFirstFrom: cardsIdenticalToCard. | ||
cardsNotIdenticalToCard := self selectNotIdenticalTo: aCard. | ||
cardsNotIdenticalToCard addAll: cardsIdenticalToCard. | ||
thrownCards := cardsNotIdenticalToCard | ||
] | ||
|
||
{ #category : #private } | ||
CardHistory >> removeFirstFrom: cardsIdenticalToCard [ | ||
cardsIdenticalToCard isEmpty | ||
ifFalse: [ cardsIdenticalToCard removeFirst ] | ||
] | ||
|
||
{ #category : #private } | ||
CardHistory >> selectIdenticalTo: aCard [ | ||
^ thrownCards select: [ :card | card isIdenticalTo: aCard ] | ||
] | ||
|
||
{ #category : #private } | ||
CardHistory >> selectNotIdenticalTo: aCard [ | ||
^ thrownCards select: [ :card | (card isIdenticalTo: aCard) not ] | ||
] | ||
|
||
{ #category : #playing } | ||
CardHistory >> triggerEffectsFor: aGame [ | ||
thrownCards do: [ :aCard | aCard triggerEffectFor: aGame ] | ||
] |
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
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 |
---|---|---|
|
@@ -6,5 +6,4 @@ Class { | |
|
||
{ #category : #checking } | ||
TargetCard >> isValid [ | ||
^true | ||
] |
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 |
---|---|---|
|
@@ -12,5 +12,4 @@ TargetPlayer >> initializePointingTo: aPlayerName [ | |
|
||
{ #category : #checking } | ||
TargetPlayer >> isValid [ | ||
^true | ||
] |
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
Oops, something went wrong.