Class RevealCardCommand
java.lang.Object
ca.uqam.info.controller.RevealCardCommand
- All Implemented Interfaces:
ca.uqam.info.mgl7010.max.skyjo.controller.Command
public class RevealCardCommand
extends Object
implements ca.uqam.info.mgl7010.max.skyjo.controller.Command
Command implementation for revealing a hidden card in the current player's grid in Skyjo game.
This command represents the player's decision to flip over one of their face-down cards
without drawing a new card from the deck or discard pile.
The command automatically finds and reveals the first available hidden card in the player's grid.
If this action causes the player to reveal their last hidden card, they become the game ender.
- Version:
- 2.1
- Author:
- Mohamed Latif Diallo, Hamza Afif, Ussel Sabbat
-
Constructor Summary
ConstructorsConstructorDescriptionRevealCardCommand(ca.uqam.info.mgl7010.max.skyjo.model.SkyjoModel model, int col, int row) Constructs a new RevealCardCommand with the specified game model. -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()Executes the reveal card command by: 1.ca.uqam.info.mgl7010.max.skyjo.controller.Command[]Returns any follow-up commands that should be available after this command executes.booleanIndicates whether this command supports undo operations.toString()Returns the name of the commandvoidundo()Undo operation for this command.
-
Constructor Details
-
RevealCardCommand
public RevealCardCommand(ca.uqam.info.mgl7010.max.skyjo.model.SkyjoModel model, int col, int row) Constructs a new RevealCardCommand with the specified game model.- Parameters:
model- the Skyjo game model instance, must not be null
-
-
Method Details
-
execute
public void execute()Executes the reveal card command by: 1. Searching for the first hidden card in the current player's grid 2. Revealing that card (flipping it face-up) 3. Checking if this action triggers game end (all player cards revealed) 4. Advancing to the next player's turn The search follows row-major order (left to right, top to bottom) to find the first available hidden card position.- Specified by:
executein interfaceca.uqam.info.mgl7010.max.skyjo.controller.Command
-
undo
public void undo()Undo operation for this command. Not implemented for TP2 requirements. This method is part of the Command interface but remains unused in this version.- Specified by:
undoin interfaceca.uqam.info.mgl7010.max.skyjo.controller.Command
-
isUndoable
public boolean isUndoable()Indicates whether this command supports undo operations.- Specified by:
isUndoablein interfaceca.uqam.info.mgl7010.max.skyjo.controller.Command- Returns:
- false as undo functionality is not implemented for TP2
-
getFollowUpCommands
public ca.uqam.info.mgl7010.max.skyjo.controller.Command[] getFollowUpCommands()Returns any follow-up commands that should be available after this command executes. For RevealCardCommand, no follow-up commands are provided as the turn ends.- Specified by:
getFollowUpCommandsin interfaceca.uqam.info.mgl7010.max.skyjo.controller.Command- Returns:
- empty array as the player's turn ends after revealing a card
-
toString
-