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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddModelObserver(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.voiddoCommand(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.SkyjoModelReadOnlygetModel()SkyjoModelReadOnly getModel() Read only access to current version of model.voidinitializeModel(ca.uqam.info.mgl7010.max.skyjo.controller.ModelPreset modelPreset, String[] players) Created a new model.booleanTells whether the most recent action can be undone.voidreverts the last command.
-
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:
getModelin interfaceca.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:
initializeModelin interfaceca.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:
getCurrentPlayerCommandsin interfaceca.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:
doCommandin interfaceca.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:
isUndoAvailablein interfaceca.uqam.info.mgl7010.max.skyjo.controller.Controller
-
undoLastCommand
public void undoLastCommand()reverts the last command.- Specified by:
undoLastCommandin interfaceca.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:
addModelObserverin interfaceca.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.
-