Package it.polimi.ingsw.model.track
Class LorenzoTrack
java.lang.Object
it.polimi.ingsw.model.track.LorenzoTrack
- All Implemented Interfaces:
EndGameObservable,TrackObservable,MoveForwardObserver,VaticanReportObservable
- Direct Known Subclasses:
Track
public class LorenzoTrack extends java.lang.Object implements VaticanReportObservable, EndGameObservable, TrackObservable, MoveForwardObserver
Represents the Lorenzo's track and his position in a single player game
-
Constructor Summary
Constructors Constructor Description LorenzoTrack()constructor of the class instances of this class are made with a json file -
Method Summary
Modifier and Type Method Description voidaddToEndGameObserverList(EndGameObserver observerToAdd)add an observer to a list of observersvoidaddToVaticanReportObserverList(VaticanReportObserver observerToAdd)Add an observer to a list of observersSquare[]getTrack()getter of the trackintgetTrackPosition()voidmoveForward(int faith)Let Lorenzo move his faith marker along the track Every time Lorenzo steps on a red Square the track's observers are notified When Lorenzo reaches the end (Square 24) the observer that manage the end game is notifiedvoidnotifyForEndGame(boolean onySinglePlayer)notify the endgame observers that the game is in the endgame statevoidnotifyForVaticanReport(int active)Notify the vaticanReport observers that a vatican report is startedvoidnotifyTrackUpdate(TrackUpdate msg)Notify the model observers that Lorenzo moved on the track Along with the notification sends the proper update Object as further explained in project documentationvoidremoveFromEndGameObserverList(EndGameObserver observerToRemove)remove an observer from a list of observersvoidremoveFromVaticanReportObserverList(VaticanReportObserver observerToRemove)Remove an observer from a list of observersvoidsetController(ModelObserver controller)voidsetUsername(java.lang.String username)voidupdate()When the observable class changes it's state notify the observer calling this methodMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
LorenzoTrack
public LorenzoTrack()constructor of the class instances of this class are made with a json file
-
-
Method Details
-
getTrack
getter of the track- Returns:
- a track's clone
-
moveForward
public void moveForward(int faith)Let Lorenzo move his faith marker along the track Every time Lorenzo steps on a red Square the track's observers are notified When Lorenzo reaches the end (Square 24) the observer that manage the end game is notified- Parameters:
faith- number of steps to do on the track from the current position
-
addToVaticanReportObserverList
Description copied from interface:VaticanReportObservableAdd an observer to a list of observers- Specified by:
addToVaticanReportObserverListin interfaceVaticanReportObservable- Parameters:
observerToAdd- the observer to add
-
removeFromVaticanReportObserverList
Description copied from interface:VaticanReportObservableRemove an observer from a list of observers- Specified by:
removeFromVaticanReportObserverListin interfaceVaticanReportObservable- Parameters:
observerToRemove- the observer to remove
-
notifyForVaticanReport
public void notifyForVaticanReport(int active)Description copied from interface:VaticanReportObservableNotify the vaticanReport observers that a vatican report is started- Specified by:
notifyForVaticanReportin interfaceVaticanReportObservable
-
addToEndGameObserverList
Description copied from interface:EndGameObservableadd an observer to a list of observers- Specified by:
addToEndGameObserverListin interfaceEndGameObservable- Parameters:
observerToAdd- the observer to add
-
removeFromEndGameObserverList
Description copied from interface:EndGameObservableremove an observer from a list of observers- Specified by:
removeFromEndGameObserverListin interfaceEndGameObservable- Parameters:
observerToRemove- the observer to remove
-
notifyForEndGame
public void notifyForEndGame(boolean onySinglePlayer)Description copied from interface:EndGameObservablenotify the endgame observers that the game is in the endgame state- Specified by:
notifyForEndGamein interfaceEndGameObservable- Parameters:
onySinglePlayer- true the game must end only if it is in single player
-
update
public void update()Description copied from interface:MoveForwardObserverWhen the observable class changes it's state notify the observer calling this method- Specified by:
updatein interfaceMoveForwardObserver
-
getTrackPosition
public int getTrackPosition()- Specified by:
getTrackPositionin interfaceMoveForwardObserver
-
notifyTrackUpdate
Description copied from interface:TrackObservableNotify the model observers that Lorenzo moved on the track Along with the notification sends the proper update Object as further explained in project documentation- Specified by:
notifyTrackUpdatein interfaceTrackObservable- Parameters:
msg- the update object representing a track update
-
setUsername
public void setUsername(java.lang.String username) -
setController
-