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 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:
      moveForward in class LorenzoTrack
      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

      public void notifyVaticanChange​(VaticanReport msg)
      Description copied from interface: VaticanUpdateObservable
      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 documentation
      Specified by:
      notifyVaticanChange in interface VaticanUpdateObservable
      Parameters:
      msg - the update object representing a vatican report update
    • update

      public void update​(int active)
      Description copied from interface: VaticanReportObserver
      When the observable class changes it's state notify the observer calling this method
      Specified by:
      update in interface VaticanReportObserver
      Parameters:
      active - represent the active zone in which the vatican report is held
    • addToVaticanReportObserverList

      public void addToVaticanReportObserverList​(VaticanReportObserver observerToAdd)
      Description copied from interface: VaticanReportObservable
      Add an observer to a list of observers
      Specified by:
      addToVaticanReportObserverList in interface VaticanReportObservable
      Specified by:
      addToVaticanReportObserverList in interface VaticanReportObserver
      Overrides:
      addToVaticanReportObserverList in class LorenzoTrack
      Parameters:
      observerToAdd - the observer to add
    • notifyTrackUpdate

      public void notifyTrackUpdate​(TrackUpdate msg)
      Description copied from interface: TrackObservable
      Notify 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:
      notifyTrackUpdate in interface TrackObservable
      Overrides:
      notifyTrackUpdate in class LorenzoTrack
      Parameters:
      msg - the update object representing a track update