Package it.polimi.ingsw.model.track
Class Track
java.lang.Object
it.polimi.ingsw.model.track.LorenzoTrack
it.polimi.ingsw.model.track.Track
- All Implemented Interfaces:
EndGameObservable,TrackObservable,VaticanUpdateObservable,MoveForwardObserver,VaticanReportObservable,VaticanReportObserver
public class Track extends LorenzoTrack implements VaticanReportObserver, VaticanUpdateObservable
Represents a player's track with their position and their pope cards
-
Constructor Summary
Constructors Constructor Description Track()constructor of the class instances of this class are made with a json file -
Method Summary
Modifier and Type Method Description voidaddToVaticanReportObserverList(VaticanReportObserver observerToAdd)Add an observer to a list of observersintcalculateTrackScore()Calculate track's pointsvoidcheckIfCurrentPositionIsActive(int active)Method called by phaseUpdate() of VaticanReportObserver interface once it's called it check if the player is into the active zone that it receives from the phaseUpdate Set the correct value in popeCards array, depending on active and position of the playerjava.lang.IntegergetCurrentPosition()voidmoveForward(int faith)Let the player move his faith marker along the track Every time a player steps on a red Square the track's observers are notified When a player reaches the end (Square 24) the observer that manage the end game is notifiedvoidnotifyTrackUpdate(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 documentationvoidnotifyVaticanChange(VaticanReport msg)Notify the model observers that a pope card has been flipped Along with the notification sends the proper update Object as further explained in project documentationvoidupdate(int active)When the observable class changes it's state notify the observer calling this methodMethods inherited from class it.polimi.ingsw.model.track.LorenzoTrack
addToEndGameObserverList, getTrack, getTrackPosition, notifyForEndGame, notifyForVaticanReport, removeFromEndGameObserverList, removeFromVaticanReportObserverList, setController, setUsername, updateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
Track
public Track()constructor of the class instances of this class are made with a json file
-
-
Method Details
-
calculateTrackScore
public int calculateTrackScore()Calculate track's points- Returns:
- total score of the track
-
moveForward
public void moveForward(int faith)Let the player move his faith marker along the track Every time a player steps on a red Square the track's observers are notified When a player reaches the end (Square 24) the observer that manage the end game is notified- Overrides:
moveForwardin classLorenzoTrack- Parameters:
faith- number of steps to do on the track from the current position
-
checkIfCurrentPositionIsActive
public void checkIfCurrentPositionIsActive(int active)Method called by phaseUpdate() of VaticanReportObserver interface once it's called it check if the player is into the active zone that it receives from the phaseUpdate Set the correct value in popeCards array, depending on active and position of the player- Parameters:
active- indicate which is the activeZone i should be in to flip the popeCard related to that zone
-
getCurrentPosition
public java.lang.Integer getCurrentPosition() -
notifyVaticanChange
Description copied from interface:VaticanUpdateObservableNotify the model observers that a pope card has been flipped Along with the notification sends the proper update Object as further explained in project documentation- Specified by:
notifyVaticanChangein interfaceVaticanUpdateObservable- Parameters:
msg- the update object representing a vatican report update
-
update
public void update(int active)Description copied from interface:VaticanReportObserverWhen the observable class changes it's state notify the observer calling this method- Specified by:
updatein interfaceVaticanReportObserver- Parameters:
active- represent the active zone in which the vatican report is held
-
addToVaticanReportObserverList
Description copied from interface:VaticanReportObservableAdd an observer to a list of observers- Specified by:
addToVaticanReportObserverListin interfaceVaticanReportObservable- Specified by:
addToVaticanReportObserverListin interfaceVaticanReportObserver- Overrides:
addToVaticanReportObserverListin classLorenzoTrack- Parameters:
observerToAdd- the observer to add
-
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- Overrides:
notifyTrackUpdatein classLorenzoTrack- Parameters:
msg- the update object representing a track update
-