Skip to content

Commit

Permalink
Implemented hierarchy of Instant and Permanent Cards
Browse files Browse the repository at this point in the history
  • Loading branch information
Caipe97 committed Jul 8, 2020
1 parent 09dfb79 commit 73463f2
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 67 deletions.
12 changes: 1 addition & 11 deletions repository/IngSoft2-Model/Acceleration.class.st
Original file line number Diff line number Diff line change
@@ -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
]
12 changes: 1 addition & 11 deletions repository/IngSoft2-Model/Cancellation.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #Cancellation,
#superclass : #Card,
#superclass : #InstantCard,
#category : #'IngSoft2-Model-Card'
}

Expand All @@ -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'].
Expand Down
14 changes: 14 additions & 0 deletions repository/IngSoft2-Model/InstantCard.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Class {
#name : #InstantCard,
#superclass : #Card,
#category : #'IngSoft2-Model-Card'
}

{ #category : #comparing }
InstantCard >> isPermanent [
^false
]

{ #category : #playing }
InstantCard >> triggerEffectFor: aGame [
]
13 changes: 1 addition & 12 deletions repository/IngSoft2-Model/Overload.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #Overload,
#superclass : #Card,
#superclass : #PermanentCard,
#category : #'IngSoft2-Model-Card'
}

Expand All @@ -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
]
15 changes: 15 additions & 0 deletions repository/IngSoft2-Model/PermanentCard.class.st
Original file line number Diff line number Diff line change
@@ -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
]
12 changes: 1 addition & 11 deletions repository/IngSoft2-Model/Redo.class.st
Original file line number Diff line number Diff line change
@@ -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 |
Expand Down
11 changes: 1 addition & 10 deletions repository/IngSoft2-Model/Repeat.class.st
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
13 changes: 1 addition & 12 deletions repository/IngSoft2-Model/Speed.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #Speed,
#superclass : #Card,
#superclass : #PermanentCard,
#category : #'IngSoft2-Model-Card'
}

Expand All @@ -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
]

0 comments on commit 73463f2

Please sign in to comment.