From 73463f2a008b2bee9aba21d467e21a9c3f3af56e Mon Sep 17 00:00:00 2001 From: caipe97 Date: Wed, 8 Jul 2020 18:09:19 -0300 Subject: [PATCH] Implemented hierarchy of Instant and Permanent Cards --- repository/IngSoft2-Model/Acceleration.class.st | 12 +----------- repository/IngSoft2-Model/Cancellation.class.st | 12 +----------- repository/IngSoft2-Model/InstantCard.class.st | 14 ++++++++++++++ repository/IngSoft2-Model/Overload.class.st | 13 +------------ repository/IngSoft2-Model/PermanentCard.class.st | 15 +++++++++++++++ repository/IngSoft2-Model/Redo.class.st | 12 +----------- repository/IngSoft2-Model/Repeat.class.st | 11 +---------- repository/IngSoft2-Model/Speed.class.st | 13 +------------ 8 files changed, 35 insertions(+), 67 deletions(-) create mode 100644 repository/IngSoft2-Model/InstantCard.class.st create mode 100644 repository/IngSoft2-Model/PermanentCard.class.st diff --git a/repository/IngSoft2-Model/Acceleration.class.st b/repository/IngSoft2-Model/Acceleration.class.st index 6dd066b..c65e524 100644 --- a/repository/IngSoft2-Model/Acceleration.class.st +++ b/repository/IngSoft2-Model/Acceleration.class.st @@ -1,20 +1,10 @@ Class { #name : #Acceleration, - #superclass : #Card, + #superclass : #PermanentCard, #category : #'IngSoft2-Model-Card' } -{ #category : #'as yet unclassified' } -Acceleration >> isPermanent [ - ^true. -] - { #category : #playing } Acceleration >> triggerEffectFor: aGame [ aGame moveActualPlayerForward: 1 ] - -{ #category : #playing } -Acceleration >> useEffectFor: aGame by: aPlayer [ - aGame addPermanent: self by: aPlayer -] diff --git a/repository/IngSoft2-Model/Cancellation.class.st b/repository/IngSoft2-Model/Cancellation.class.st index 7315a34..07b2aab 100644 --- a/repository/IngSoft2-Model/Cancellation.class.st +++ b/repository/IngSoft2-Model/Cancellation.class.st @@ -1,6 +1,6 @@ Class { #name : #Cancellation, - #superclass : #Card, + #superclass : #InstantCard, #category : #'IngSoft2-Model-Card' } @@ -11,16 +11,6 @@ Cancellation class >> to: aTarget [ ^ self new initializeWithTarget: aTarget ] -{ #category : #comparing } -Cancellation >> isPermanent [ - ^false. -] - -{ #category : #playing } -Cancellation >> triggerEffectFor: aGame [ - -] - { #category : #playing } Cancellation >> useEffectFor: aGame by: aPlayer [ ((target isValid) and: (aGame hasActivatedPermanents)) ifFalse: [InvalidAction signal: 'Invalid Card Usage']. diff --git a/repository/IngSoft2-Model/InstantCard.class.st b/repository/IngSoft2-Model/InstantCard.class.st new file mode 100644 index 0000000..3dc3ef7 --- /dev/null +++ b/repository/IngSoft2-Model/InstantCard.class.st @@ -0,0 +1,14 @@ +Class { + #name : #InstantCard, + #superclass : #Card, + #category : #'IngSoft2-Model-Card' +} + +{ #category : #comparing } +InstantCard >> isPermanent [ + ^false +] + +{ #category : #playing } +InstantCard >> triggerEffectFor: aGame [ +] diff --git a/repository/IngSoft2-Model/Overload.class.st b/repository/IngSoft2-Model/Overload.class.st index 31e1493..7bbf1e6 100644 --- a/repository/IngSoft2-Model/Overload.class.st +++ b/repository/IngSoft2-Model/Overload.class.st @@ -1,6 +1,6 @@ Class { #name : #Overload, - #superclass : #Card, + #superclass : #PermanentCard, #category : #'IngSoft2-Model-Card' } @@ -11,19 +11,8 @@ Overload class >> to: aTarget [ ^ self new initializeWithTarget: aTarget ] -{ #category : #comparing } -Overload >> isPermanent [ - ^true. -] - { #category : #playing } Overload >> triggerEffectFor: aGame [ target objective = aGame actualPlayer ifTrue: [ aGame moveActualPlayerBackwards: 2 ]. ] - -{ #category : #playing } -Overload >> useEffectFor: aGame by: aPlayer [ - target isValid. - aGame addPermanent: self by: aPlayer -] diff --git a/repository/IngSoft2-Model/PermanentCard.class.st b/repository/IngSoft2-Model/PermanentCard.class.st new file mode 100644 index 0000000..359c6d5 --- /dev/null +++ b/repository/IngSoft2-Model/PermanentCard.class.st @@ -0,0 +1,15 @@ +Class { + #name : #PermanentCard, + #superclass : #Card, + #category : #'IngSoft2-Model-Card' +} + +{ #category : #comparing } +PermanentCard >> isPermanent [ + ^true +] + +{ #category : #'as yet unclassified' } +PermanentCard >> useEffectFor: aGame by: aPlayer [ + aGame addPermanent: self by: aPlayer +] diff --git a/repository/IngSoft2-Model/Redo.class.st b/repository/IngSoft2-Model/Redo.class.st index b9a33b0..66cbb5f 100644 --- a/repository/IngSoft2-Model/Redo.class.st +++ b/repository/IngSoft2-Model/Redo.class.st @@ -1,19 +1,9 @@ Class { #name : #Redo, - #superclass : #Card, + #superclass : #InstantCard, #category : #'IngSoft2-Model-Card' } -{ #category : #comparing } -Redo >> isPermanent [ - ^false. -] - -{ #category : #playing } -Redo >> triggerEffectFor: aGame [ - -] - { #category : #playing } Redo >> useEffectFor: aGame by: aPlayer [ | aCard | diff --git a/repository/IngSoft2-Model/Repeat.class.st b/repository/IngSoft2-Model/Repeat.class.st index b6081ca..9b31f3d 100644 --- a/repository/IngSoft2-Model/Repeat.class.st +++ b/repository/IngSoft2-Model/Repeat.class.st @@ -1,18 +1,9 @@ Class { #name : #Repeat, - #superclass : #Card, + #superclass : #InstantCard, #category : #'IngSoft2-Model-Card' } -{ #category : #comparing } -Repeat >> isPermanent [ - ^false. -] - -{ #category : #playing } -Repeat >> triggerEffectFor: aGame [ -] - { #category : #playing } Repeat >> useEffectFor: aGame by: aPlayer [ aGame repeatLastEffect. diff --git a/repository/IngSoft2-Model/Speed.class.st b/repository/IngSoft2-Model/Speed.class.st index 1e6a261..38b5e50 100644 --- a/repository/IngSoft2-Model/Speed.class.st +++ b/repository/IngSoft2-Model/Speed.class.st @@ -1,6 +1,6 @@ Class { #name : #Speed, - #superclass : #Card, + #superclass : #PermanentCard, #category : #'IngSoft2-Model-Card' } @@ -11,19 +11,8 @@ Speed class >> to: aTarget [ ^ self new initializeWithTarget: aTarget ] -{ #category : #comparing } -Speed >> isPermanent [ - ^true. -] - { #category : #playing } Speed >> triggerEffectFor: aGame [ target objective = aGame actualPlayer ifTrue: [ aGame moveActualPlayerForward: 1 ] ] - -{ #category : #playing } -Speed >> useEffectFor: aGame by: aPlayer [ - target isValid. - aGame addPermanent: self by: aPlayer -]