Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying reverse card on hyper jump #43

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
```smalltalk
Metacello new
baseline: 'IngSoft2';
githubUser: 'uca-argentina' project: '2023-pura-magia' commitish: 'master' path: 'repository';
githubUser: 'Delfinalasheras' project: '2023-pura-magia' commitish: 'master' path: 'repository';
load: 'development'.
```
5 changes: 5 additions & 0 deletions repository/IngSoft2-Model/Acceleration.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ Acceleration >> initializeWith: aShipsGame [
shipsGame := aShipsGame .
]

{ #category : #testing }
Acceleration >> isOnlyForPlayers [
^true.
]

{ #category : #validation }
Acceleration >> permanent [
^true.
Expand Down
38 changes: 25 additions & 13 deletions repository/IngSoft2-Model/Cancellation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,23 @@ Cancellation class >> with: aShipsGame [

{ #category : #action }
Cancellation >> apply: aGameBoard [
self applyForAccelerationTo: aGameBoard .
self applyForOtherCardsTo: aGameBoard .
(cardToRemove isOnlyForPlayers)ifTrue:[
self applyForcardForAllPlayersTo: aGameBoard .
self applyForOtherCardsTo: aGameBoard .]ifFalse:[
self applyForCardsThatAffectCell: aGameBoard.].

^(self)

]

{ #category : #action }
Cancellation >> applyForAccelerationTo: aGameBoard [
(aGameBoard accelerations includes: cardToRemove) ifTrue: [
self removeAcceleration: aGameBoard.
].
Cancellation >> applyForCardsThatAffectCell [

]

{ #category : #action }
Cancellation >> applyForCardsThatAffectCell: aGameBoard [
cardToRemove apply: aGameBoard
]

{ #category : #action }
Expand All @@ -39,6 +44,13 @@ Cancellation >> applyForOtherCardsTo: aGameBoard [
self removeFrom: collectionCards ]
]

{ #category : #action }
Cancellation >> applyForcardForAllPlayersTo: aGameBoard [
(aGameBoard cardForAllPlayers includes: cardToRemove) ifTrue: [
self removecardForAllPlayers: aGameBoard.
].
]

{ #category : #initialization }
Cancellation >> canceled: aCardToRemove [
cardToRemove:= aCardToRemove.
Expand Down Expand Up @@ -73,13 +85,6 @@ Cancellation >> permanent: aShipsGame verify: aNumberOfShip [
aShipsGame cardDirectedTo: aNumberOfShip
]

{ #category : #action }
Cancellation >> removeAcceleration: aGameBoard [
|collectionOfAccelerations|
collectionOfAccelerations := aGameBoard accelerations.
collectionOfAccelerations remove: cardToRemove .
]

{ #category : #action }
Cancellation >> removeFrom: collectionCards [

Expand All @@ -88,6 +93,13 @@ Cancellation >> removeFrom: collectionCards [

]

{ #category : #action }
Cancellation >> removecardForAllPlayers: aGameBoard [
|collectionOfAccelerations|
collectionOfAccelerations := aGameBoard cardForAllPlayers.
collectionOfAccelerations remove: cardToRemove .
]

{ #category : #instance }
Cancellation >> selected: aShipPosition [
chosenShip := aShipPosition.
Expand Down
5 changes: 5 additions & 0 deletions repository/IngSoft2-Model/Cell.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Cell class >> with: aSpecialEffect and: aNumberOfCell [
^(self new)initializeWith: aSpecialEffect and: aNumberOfCell.
]

{ #category : #action }
Cell >> changeEffect: specialEffectNewState [
effect := specialEffectNewState.
]

{ #category : #initialization }
Cell >> initializeWith: aSpeedUp and: aNumberOfCell [
effect := aSpeedUp.
Expand Down
25 changes: 17 additions & 8 deletions repository/IngSoft2-Model/GameBoard.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ GameBoard class >> with: numberOfCells and: numberOfLaps [

]

{ #category : #action }
GameBoard >> accelerations [
^aCollectionOfAccelerations .
]

{ #category : #adding }
GameBoard >> add: aEffect at: aNumberOfCell [
aCollectionOfSpecialCells add: (Cell with: aEffect and: aNumberOfCell).
Expand Down Expand Up @@ -109,6 +104,11 @@ GameBoard >> amountOfPlayers [
^ collectionOfShipPositions size.
]

{ #category : #action }
GameBoard >> cardForAllPlayers [
^aCollectionOfAccelerations .
]

{ #category : #initialization }
GameBoard >> cellsWith: anAmountOfParsecs and: aCollectionOfDice [
parsecsByCell := anAmountOfParsecs .
Expand Down Expand Up @@ -167,9 +167,10 @@ GameBoard >> change: aShipPosition withNegative: aResult [
GameBoard >> change: aShipPosition withNegativeParsecs: aResult [
|newShipPosition result position newLap parsecs |
result := aResult .
position := aShipPosition isAtPosition.
[ result < 0 ] whileTrue: [

position:=aShipPosition isAtPosition -1.
position:= position -1.
newShipPosition := self verifyCellsOf: aShipPosition at: position.
position := newShipPosition isAtPosition .
newLap := newShipPosition isAtLap .
Expand Down Expand Up @@ -357,6 +358,13 @@ GameBoard >> resultOf: aShip [
^dieResult .
]

{ #category : #action }
GameBoard >> specialCell: aNumberOfCell [
| targetCell |
targetCell:= aCollectionOfSpecialCells detect: [ :each | each numberOfSpecialCell = aNumberOfCell].
^targetCell.
]

{ #category : #validation }
GameBoard >> specialEffectAtCell: aNumberOfCell [

Expand Down Expand Up @@ -398,8 +406,9 @@ GameBoard >> turn [
{ #category : #action }
GameBoard >> turnOf: numberOfShip [
turn := numberOfShip .
self
move: (collectionOfShipPositions at: numberOfShip)
self winner = 0
ifTrue: [ self move: (collectionOfShipPositions at: numberOfShip) ]
ifFalse: [ Error signal: 'The game is finished, we already have a winner' ]
]

{ #category : #update }
Expand Down
28 changes: 27 additions & 1 deletion repository/IngSoft2-Model/HyperJump.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Class {
#superclass : #Object,
#instVars : [
'anAmountOfParsecsToMove',
'round'
'round',
'stateReverse'
],
#category : #'IngSoft2-Model'
}
Expand Down Expand Up @@ -43,8 +44,33 @@ HyperJump >> applyTo: aGameBoard for: aChosenShip [
(aChosenShip) changePosition: newPosition.
]

{ #category : #action }
HyperJump >> changeState: stateToChange [
stateReverse := stateToChange.

]

{ #category : #initialization }
HyperJump >> initializeWith: amountOfParsecsToMove [
anAmountOfParsecsToMove:=amountOfParsecsToMove .
round:= 0.
stateReverse := false.
]

{ #category : #highlighting }
HyperJump >> reverse [
(stateReverse not )ifTrue:[
self changeState: true .
]
ifFalse:[
self changeState: false.
].
self reverseCollectionOfParcecsToMove.

]

{ #category : #action }
HyperJump >> reverseCollectionOfParcecsToMove [
anAmountOfParsecsToMove do: [:each | each negateNominalValue]

]
5 changes: 5 additions & 0 deletions repository/IngSoft2-Model/LightYears.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ LightYears >> initializeWith: aNominalValue [
nominalValue := aNominalValue .
]

{ #category : #action }
LightYears >> negateNominalValue [
nominalValue := nominalValue negated.
]

{ #category : #calculating }
LightYears >> parsecs [
^( Parsecs with: (nominalValue // 3))
Expand Down
15 changes: 15 additions & 0 deletions repository/IngSoft2-Model/ManifestIngSoft2Model.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"
Please describe the package using the class comment of the included manifest class. The manifest class also includes other additional metadata for the package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
"
Class {
#name : #ManifestIngSoft2Model,
#superclass : #PackageManifest,
#category : #'IngSoft2-Model-Manifest'
}

{ #category : #'code-critics' }
ManifestIngSoft2Model class >> ruleTempsReadBeforeWrittenRuleV1FalsePositive [

<ignoreForCoverage>
^ #(#(#(#RGMethodDefinition #(#GameBoard #change:withNegativeParsecs: #false)) #'2024-07-19T13:36:49.784346-03:00') )
]
5 changes: 5 additions & 0 deletions repository/IngSoft2-Model/Overload.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ Overload >> initializeWith: aShipsGame [
shipsGame := aShipsGame .
]

{ #category : #testing }
Overload >> isOnlyForPlayers [
^true.
]

{ #category : #validation }
Overload >> permanent [
^true.
Expand Down
5 changes: 5 additions & 0 deletions repository/IngSoft2-Model/Parsecs.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Parsecs >> initializeWith: aNominalValue [
nominalValue := aNominalValue.
]

{ #category : #action }
Parsecs >> negateNominalValue [
nominalValue := nominalValue negated.
]

{ #category : #value }
Parsecs >> nominalValue [
^ nominalValue
Expand Down
53 changes: 53 additions & 0 deletions repository/IngSoft2-Model/Reverse.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Class {
#name : #Reverse,
#superclass : #Object,
#instVars : [
'shipsGame',
'atargetCell'
],
#category : #'IngSoft2-Model'
}

{ #category : #'instance creation' }
Reverse class >> with: aShipsGame [
^(self new) initializeWith: aShipsGame .
]

{ #category : #action }
Reverse >> apply: aGameBoard [
|aTargetSpecialEffect|
aTargetSpecialEffect := atargetCell typeOfSpecialEffect.
aTargetSpecialEffect reverse.
atargetCell changeEffect: aTargetSpecialEffect.
]

{ #category : #'instance creation' }
Reverse >> from: aNumberOfShip to: anEffectCell [
shipsGame chosen: self from: aNumberOfShip.
shipsGame cardDirectedToCell: anEffectCell.
shipsGame applyChosenCard.
]

{ #category : #initialization }
Reverse >> initializeWith: aShipsGame [
shipsGame := aShipsGame .
]

{ #category : #testing }
Reverse >> isOnlyForPlayers [
^false.
]

{ #category : #validation }
Reverse >> permanent: aShipsGame verify: aNumberOfShip [
(aShipsGame playerTurn: aNumberOfShip) ifTrue:[
(aShipsGame verify: self IsInHand: aNumberOfShip) ifTrue: [
aShipsGame chosenCard: self ]. ] .
]

{ #category : #accessing }
Reverse >> selected: targetCell [
atargetCell := targetCell.


]
5 changes: 5 additions & 0 deletions repository/IngSoft2-Model/ShipsGame.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ ShipsGame >> cardDirectedTo: aNumberOfShip [
chosenCard selected: (gameboard player: aNumberOfShip)
]

{ #category : #action }
ShipsGame >> cardDirectedToCell: aNumberOfCell [
chosenCard selected:(gameboard specialCell: aNumberOfCell)
]

{ #category : #validation }
ShipsGame >> chosen: aCard from: aNumberOfShip [

Expand Down
5 changes: 5 additions & 0 deletions repository/IngSoft2-Model/Speed.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ Speed >> initializeWith: aShipsGame [
shipsGame := aShipsGame .
]

{ #category : #testing }
Speed >> isOnlyForPlayers [
^true.
]

{ #category : #validation }
Speed >> permanent [
^true
Expand Down
Loading
Loading