diff --git a/repository/IngSoft2-Model/CircularIterator.class.st b/repository/IngSoft2-Model/CircularIterator.class.st index b91528e..41db896 100644 --- a/repository/IngSoft2-Model/CircularIterator.class.st +++ b/repository/IngSoft2-Model/CircularIterator.class.st @@ -68,5 +68,5 @@ CircularIterator >> reset [ { #category : #accessing } CircularIterator >> sort [ - options := options sort + options := options sort: [ :a :b | a>=b ] ] diff --git a/repository/IngSoft2-Model/Game.class.st b/repository/IngSoft2-Model/Game.class.st index 321dfcc..eca70ba 100644 --- a/repository/IngSoft2-Model/Game.class.st +++ b/repository/IngSoft2-Model/Game.class.st @@ -30,7 +30,7 @@ Game class >> with: aDice andPlayers: players [ ^self with: aDice andFields: 12 andPlayers: players ] -{ #category : #'as yet unclassified' } +{ #category : #instanceCreation } Game class >> with: aDie andPlayers: aCollection ofLaps: anInteger [ ^self with: aDie andFields: 16 andPlayers: aCollection andLaps: anInteger ] @@ -45,7 +45,7 @@ Game class >> withPlayers: players [ ^self with: Die d6 andFields: 12 andPlayers: players ] -{ #category : #'as yet unclassified' } +{ #category : #playing } Game >> addLapTo: aPlayer [ aPlayer position >= length ifTrue: [ aPlayer addLap:(aPlayer position%length)]. ^aPlayer laps @@ -59,17 +59,17 @@ Game >> att: aPosition [ ^playerSequence att: aPosition ] +{ #category : #accessing } +Game >> dice [ + ^dice +] + { #category : #StateChanging } Game >> finishAnStartedGame [ state := Finished new. playerSequence sort ] -{ #category : #accessing } -Game >> getDice [ - ^dice -] - { #category : #initialization } Game >> initializeDice: aDice withFields: aNumber andPlayers: players andLaps: ammountLaps [ dice := aDice. @@ -79,17 +79,12 @@ Game >> initializeDice: aDice withFields: aNumber andPlayers: players andLaps: a laps := ammountLaps. ] -{ #category : #'as yet unclassified' } +{ #category : #results } Game >> isFinished [ ^state isFinished. ] -{ #category : #checking } -Game >> isPlayedBy: aPlayer [ - ^ playerSequence includes: aPlayer. -] - -{ #category : #'as yet unclassified' } +{ #category : #accessing } Game >> laps [ ^ laps ] @@ -119,9 +114,7 @@ Game >> playNext [ Game >> playUntilFinished [ "playNext pero juega hasta que termine el juego, no sólo la próxima jugada" - | position | - position := self play. - state finishAndContinue: self at: position +[self isFinished] whileFalse: [ self playNext ] ] { #category : #playing } diff --git a/repository/IngSoft2-Model/Player.class.st b/repository/IngSoft2-Model/Player.class.st index bbf17dd..dedaca5 100644 --- a/repository/IngSoft2-Model/Player.class.st +++ b/repository/IngSoft2-Model/Player.class.st @@ -20,8 +20,8 @@ Player class >> named: aNameSurname [ ] { #category : #comparing } -Player >> <= aPlayer [ - ^position >= (aPlayer position) +Player >> >= aPlayer [ + ^laps >= (aPlayer laps) ] { #category : #'as yet unclassified' } diff --git a/repository/IngSoft2-Model/Started.class.st b/repository/IngSoft2-Model/Started.class.st index 61a3bbf..6efc29b 100644 --- a/repository/IngSoft2-Model/Started.class.st +++ b/repository/IngSoft2-Model/Started.class.st @@ -10,11 +10,9 @@ Started >> finish: aGame at: aPosition [ ifFalse: [ aGame finishAnStartedGame ] ] -{ #category : #StateChanging } -Started >> finishAndContinue: aGame at: aPosition [ - (self isFinished: aGame at: aPosition) - ifFalse: [ aGame finishAnStartedGame ] - ifTrue: [ aGame playUntilFinished ] +{ #category : #'as yet unclassified' } +Started >> isFinished [ + ^false ] { #category : #StateChanging } diff --git a/repository/IngSoft2-Tests/GameTest.class.st b/repository/IngSoft2-Tests/GameTest.class.st index b9561d0..44e9cb5 100644 --- a/repository/IngSoft2-Tests/GameTest.class.st +++ b/repository/IngSoft2-Tests/GameTest.class.st @@ -49,8 +49,8 @@ self assert: (aGame isFinished). GameTest >> test06PlayAGameAndFranWins [ | aGame aPlayer otherPlayer | -aPlayer := Player named: 'Fran'. -otherPlayer := Player named: 'Manu'. +aPlayer := self anotherPlayer. +otherPlayer := self newPlayer . aGame := Game with: (Die of: 6 rolling: #(4 1)) andPlayers: { aPlayer. otherPlayer} . aGame playUntilFinished. self assert: (aGame winner name) equals: 'Fran'.