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
    void addToEndGameObserverList​(EndGameObserver observerToAdd)
    add an observer to a list of observers
    void addToVaticanReportObserverList​(VaticanReportObserver observerToAdd)
    Add an observer to a list of observers
    Square[] getTrack()
    getter of the track
    int getTrackPosition()  
    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
    void notifyForEndGame​(boolean onySinglePlayer)
    notify the endgame observers that the game is in the endgame state
    void notifyForVaticanReport​(int active)
    Notify the vaticanReport observers that a vatican report is started
    void notifyTrackUpdate​(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 documentation
    void removeFromEndGameObserverList​(EndGameObserver observerToRemove)
    remove an observer from a list of observers
    void removeFromVaticanReportObserverList​(VaticanReportObserver observerToRemove)
    Remove an observer from a list of observers
    void setController​(ModelObserver controller)  
    void setUsername​(java.lang.String username)  
    void update()
    When the observable class changes it's state notify the observer calling this method

    Methods 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

      public Square[] 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

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

      public void removeFromVaticanReportObserverList​(VaticanReportObserver observerToRemove)
      Description copied from interface: VaticanReportObservable
      Remove an observer from a list of observers
      Specified by:
      removeFromVaticanReportObserverList in interface VaticanReportObservable
      Parameters:
      observerToRemove - the observer to remove
    • notifyForVaticanReport

      public void notifyForVaticanReport​(int active)
      Description copied from interface: VaticanReportObservable
      Notify the vaticanReport observers that a vatican report is started
      Specified by:
      notifyForVaticanReport in interface VaticanReportObservable
    • addToEndGameObserverList

      public void addToEndGameObserverList​(EndGameObserver observerToAdd)
      Description copied from interface: EndGameObservable
      add an observer to a list of observers
      Specified by:
      addToEndGameObserverList in interface EndGameObservable
      Parameters:
      observerToAdd - the observer to add
    • removeFromEndGameObserverList

      public void removeFromEndGameObserverList​(EndGameObserver observerToRemove)
      Description copied from interface: EndGameObservable
      remove an observer from a list of observers
      Specified by:
      removeFromEndGameObserverList in interface EndGameObservable
      Parameters:
      observerToRemove - the observer to remove
    • notifyForEndGame

      public void notifyForEndGame​(boolean onySinglePlayer)
      Description copied from interface: EndGameObservable
      notify the endgame observers that the game is in the endgame state
      Specified by:
      notifyForEndGame in interface EndGameObservable
      Parameters:
      onySinglePlayer - true the game must end only if it is in single player
    • update

      public void update()
      Description copied from interface: MoveForwardObserver
      When the observable class changes it's state notify the observer calling this method
      Specified by:
      update in interface MoveForwardObserver
    • getTrackPosition

      public int getTrackPosition()
      Specified by:
      getTrackPosition in interface MoveForwardObserver
    • 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
      Parameters:
      msg - the update object representing a track update
    • setUsername

      public void setUsername​(java.lang.String username)
    • setController

      public void setController​(ModelObserver controller)