Class ControllerImpl

java.lang.Object
ca.uqam.info.controller.ControllerImpl
All Implemented Interfaces:
ca.uqam.info.mgl7010.max.skyjo.controller.Controller

public class ControllerImpl extends Object implements ca.uqam.info.mgl7010.max.skyjo.controller.Controller
Version:
2.1
Author:
Mohamed Latif Diallo, Hamza Afif, Ussel Sabbat
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addModelObserver(ca.uqam.info.mgl7010.max.skyjo.controller.ModelObserver modelObserver)
    Adds a new observer to the list and immediately notifies the added observer with the current model state.
    void
    doCommand(int commandIndex)
    Modifies model state according to the action index of a given player's actions.
    ca.uqam.info.mgl7010.max.skyjo.controller.Command[]
    Generator for all valid actions of the current player.
    ca.uqam.info.mgl7010.max.skyjo.model.SkyjoModelReadOnly
    SkyjoModelReadOnly getModel() Read only access to current version of model.
    void
    initializeModel(ca.uqam.info.mgl7010.max.skyjo.controller.ModelPreset modelPreset, String[] players)
    Created a new model.
    boolean
    Tells whether the most recent action can be undone.
    void
    reverts the last command.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ControllerImpl

      public ControllerImpl()
  • Method Details

    • getModel

      public ca.uqam.info.mgl7010.max.skyjo.model.SkyjoModelReadOnly getModel()
      SkyjoModelReadOnly getModel() Read only access to current version of model. Can be used e.g. by UI, to visualize state. Cannot be used to directly modify state. All state modification must pass through other controller methods. Returns: the immutable model.
      Specified by:
      getModel in interface ca.uqam.info.mgl7010.max.skyjo.controller.Controller
    • initializeModel

      public void initializeModel(ca.uqam.info.mgl7010.max.skyjo.controller.ModelPreset modelPreset, String[] players)
      Created a new model. Must internally use the model factory to encapsulate complexity. Parameters:
      Specified by:
      initializeModel in interface ca.uqam.info.mgl7010.max.skyjo.controller.Controller
      Parameters:
      modelPreset - as string matching exactly one player object associated with model.
      players - as horizontal card position, first column is 0.
    • getCurrentPlayerCommands

      public ca.uqam.info.mgl7010.max.skyjo.controller.Command[] getCurrentPlayerCommands()
      Generator for all valid actions of the current player. Each action object represents an atomic move, that is, further actions by the same player may be possible. The provided array must be sorted, i.e. respecting the Move order. Taking from remainin card deck comes before taking from discard pile. For replacing card replacements, y is compared before x. Returns: array of move objects, each representing an atomic skyjo move.
      Specified by:
      getCurrentPlayerCommands in interface ca.uqam.info.mgl7010.max.skyjo.controller.Controller
    • doCommand

      public void doCommand(int commandIndex)
      Modifies model state according to the action index of a given player's actions. Parameters:
      Specified by:
      doCommand in interface ca.uqam.info.mgl7010.max.skyjo.controller.Controller
      Parameters:
      commandIndex - as int specifying which position in the currently available moves list is desired.
    • isUndoAvailable

      public boolean isUndoAvailable()
      Tells whether the most recent action can be undone. If information has been revealed, an undo is not possible. Returns: boolean telling whether an undo is available.
      Specified by:
      isUndoAvailable in interface ca.uqam.info.mgl7010.max.skyjo.controller.Controller
    • undoLastCommand

      public void undoLastCommand()
      reverts the last command.
      Specified by:
      undoLastCommand in interface ca.uqam.info.mgl7010.max.skyjo.controller.Controller
    • addModelObserver

      public void addModelObserver(ca.uqam.info.mgl7010.max.skyjo.controller.ModelObserver modelObserver)
      Adds a new observer to the list and immediately notifies the added observer with the current model state. Parameters:
      Specified by:
      addModelObserver in interface ca.uqam.info.mgl7010.max.skyjo.controller.Controller
      Parameters:
      modelObserver - Adds a new observer to the list and immediately notifies the added observer with the current model state.