Class ExpertGameStateController
java.lang.Object
it.polimi.ingsw.server.controller.game_state_controller.GameStateController
it.polimi.ingsw.server.controller.game_state_controller.ExpertGameStateController
- All Implemented Interfaces:
GameStateControllerCommonInterface
-
Field Summary
Fields inherited from class it.polimi.ingsw.server.controller.game_state_controller.GameStateController
gameState -
Constructor Summary
ConstructorsConstructorDescriptionExpertGameStateController(int playersNumber) ExpertGameStateController(UUID gameUUID) -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyEffect(int characterIndex) This method applies the effect of the character corresponding to the inputted character index.booleanapplyEffect(int characterIndex, int archipelagoIslandCode) This method applies the effect of the character corresponding to the inputted character index.voidapplyEffect(int characterIndex, Color color) This method applies the effect of the character corresponding to the inputted character index.voidapplyEffect(int characterIndex, Color color, int archipelagoIslandCode) This method applies the effect of the character corresponding to the inputted character index.voidapplyEffect(int characterIndex, List<Color> getStudents, List<Color> giveStudents) This method applies the effect of the character corresponding to the inputted character index.private voidapplyEffectGenericChecks(int characterIndex) This method performs the generic checks on the input before applying the effectprotected ExpertGameStateinitializeGameState(int playersNumber) This method initializes the correct gameState with its attributesbooleanmoveMotherNature(int nSteps) This method performs all the checks required by the rules and then, if all of them are met, modifies the gameState moving motherNature.protected voidThis method advances the turn during the action phase, after a player ended its turn.voidrollback()Methods inherited from class it.polimi.ingsw.server.controller.game_state_controller.GameStateController
cardPlayed, endActionTurn, getCurrentPlayerSchoolBoardId, getGameStateForTesting, getGameUUID, getLightGameState, getSchoolBoardIDFromTowerColor, getSchoolBoardIds, getSchoolBoardTowerColorFromID, grabStudentsFromCloud, moveStudentFromEntranceToArchipelago, moveStudentFromEntranceToDiningRoom, playCard, setCurrentPhaseForTesting
-
Constructor Details
-
ExpertGameStateController
-
ExpertGameStateController
-
-
Method Details
-
initializeGameState
protected ExpertGameState initializeGameState(int playersNumber) throws GameStateInitializationFailureException This method initializes the correct gameState with its attributes- Overrides:
initializeGameStatein classGameStateController- Parameters:
playersNumber- is the number of players- Returns:
- the newly created GameState
- Throws:
GameStateInitializationFailureException- if there was a failure in the initialization procedure
-
applyEffectGenericChecks
private void applyEffectGenericChecks(int characterIndex) throws WrongPhaseException, MoveAlreadyPlayedException, InvalidCharacterIndexException This method performs the generic checks on the input before applying the effect- Parameters:
characterIndex- is the index of the character that the player inputted- Throws:
WrongPhaseException- if the effect is activated during the wrong phaseMoveAlreadyPlayedException- if another character was activated during this turnInvalidCharacterIndexException- if the character index is outside the bounds of the availableCharacters list
-
applyEffect
public void applyEffect(int characterIndex) throws WrongPhaseException, MoveAlreadyPlayedException, InvalidCharacterIndexException, MoveNotAvailableException, WrongArgumentsException, NotEnoughCoinsException This method applies the effect of the character corresponding to the inputted character index.- Parameters:
characterIndex- is the index of the character to be activated- Throws:
WrongPhaseException- if the effect is activated during the wrong phaseMoveAlreadyPlayedException- if another character was activated during this turnInvalidCharacterIndexException- if the character index is outside the bounds of the availableCharacters listMoveNotAvailableException- if the move is not present in availableCharactersWrongArgumentsException- if the character linked to the inputted index and the list of arguments are incompatibleNotEnoughCoinsException- if the player doesn't have enough coins to activate the character
-
applyEffect
public boolean applyEffect(int characterIndex, int archipelagoIslandCode) throws InvalidCharacterIndexException, ArchipelagoAlreadyLockedException, InvalidArchipelagoIdException, WrongPhaseException, MoveAlreadyPlayedException, MoveNotAvailableException, NoAvailableLockException, WrongArgumentsException, NotEnoughCoinsException, GameOverException This method applies the effect of the character corresponding to the inputted character index.- Parameters:
characterIndex- is the index of the character to be activatedarchipelagoIslandCode- is a code that identifies a single archipelago- Returns:
- true if a merge was performed, false otherwise
- Throws:
InvalidCharacterIndexException- if the character index is outside the bounds of the availableCharacters listArchipelagoAlreadyLockedException- if the archipelago to be locked is already lockedInvalidArchipelagoIdException- if the inputted archipelago code is invalidWrongPhaseException- if the effect is activated during the wrong phaseMoveAlreadyPlayedException- if another character was activated during this turnMoveNotAvailableException- if the move is not present in availableCharactersNoAvailableLockException- if no locks are available on the characterWrongArgumentsException- if the character linked to the inputted index and the list of arguments are incompatibleNotEnoughCoinsException- if the player doesn't have enough coins to activate the characterGameOverException- if one of the gameOver conditions is met with the activation of the effect
-
applyEffect
public void applyEffect(int characterIndex, Color color) throws InvalidCharacterIndexException, MoveAlreadyPlayedException, WrongPhaseException, MoveNotAvailableException, StudentNotOnCharacterException, FullDiningRoomLaneException, WrongArgumentsException, NotEnoughCoinsException, StudentsNotInTheDiningRoomException This method applies the effect of the character corresponding to the inputted character index.- Parameters:
characterIndex- is the index of the character to be activatedcolor- is the color involved in the effect of the character- Throws:
InvalidCharacterIndexException- if the character index is outside the bounds of the availableCharacters listMoveAlreadyPlayedException- if another character was activated during this turnWrongPhaseException- if the effect is activated during the wrong phaseMoveNotAvailableException- if the move is not present in availableCharactersStudentNotOnCharacterException- if the inputted student is not present on the characterFullDiningRoomLaneException- if the diningRoom table corresponding to the inputted student is already fullWrongArgumentsException- if the character linked to the inputted index and the list of arguments are incompatibleNotEnoughCoinsException- if the player doesn't have enough coins to activate the characterStudentsNotInTheDiningRoomException- if the inputted student is not present in the diningRoom
-
applyEffect
public void applyEffect(int characterIndex, Color color, int archipelagoIslandCode) throws InvalidCharacterIndexException, MoveAlreadyPlayedException, WrongPhaseException, MoveNotAvailableException, InvalidArchipelagoIdException, StudentNotOnCharacterException, WrongArgumentsException, NotEnoughCoinsException This method applies the effect of the character corresponding to the inputted character index.- Parameters:
characterIndex- is the index of the character to be activatedcolor- is the color involved in the effect of the characterarchipelagoIslandCode- is a code that identifies a single archipelago- Throws:
InvalidCharacterIndexException- if the character index is outside the bounds of the availableCharacters listMoveAlreadyPlayedException- if another character was activated during this turnWrongPhaseException- if the effect is activated during the wrong phaseMoveNotAvailableException- if the move is not present in availableCharactersInvalidArchipelagoIdException- if the inputted archipelago code is invalidStudentNotOnCharacterException- if the inputted student is not present on the characterWrongArgumentsException- if the character linked to the inputted index and the list of arguments are incompatibleNotEnoughCoinsException- if the player doesn't have enough coins to activate the character
-
applyEffect
public void applyEffect(int characterIndex, List<Color> getStudents, List<Color> giveStudents) throws InvalidCharacterIndexException, MoveAlreadyPlayedException, WrongPhaseException, WrongArgumentsException, InvalidStudentListsLengthException, StudentNotInTheEntranceException, StudentNotOnCharacterException, MoveNotAvailableException, StudentsNotInTheDiningRoomException, FullDiningRoomLaneException, NotEnoughCoinsException This method applies the effect of the character corresponding to the inputted character index.- Parameters:
characterIndex- is the index of the character to be activatedgetStudents- is the list of students to getgiveStudents- is the list of students to give- Throws:
InvalidCharacterIndexException- if the character index is outside the bounds of the availableCharacters listMoveAlreadyPlayedException- if another character was activated during this turnWrongPhaseException- if the effect is activated during the wrong phaseWrongArgumentsException- if the character linked to the inputted index and the list of arguments are incompatibleInvalidStudentListsLengthException- if the length of the getStudents and giveStudents is not equalStudentNotInTheEntranceException- if one of the elements of getStudents is not actually present in the entranceStudentNotOnCharacterException- if the inputted student is not present on the characterMoveNotAvailableException- if the move is not present in availableCharactersStudentsNotInTheDiningRoomException- if the inputted student is not present in the diningRoomFullDiningRoomLaneException- if the diningRoom table corresponding to the inputted student is already fullNotEnoughCoinsException- if the player doesn't have enough coins to activate the character
-
moveMotherNature
public boolean moveMotherNature(int nSteps) throws InvalidNumberOfStepsException, WrongPhaseException, MoreStudentsToBeMovedException, MoveAlreadyPlayedException, GameOverException This method performs all the checks required by the rules and then, if all of them are met, modifies the gameState moving motherNature.- Overrides:
moveMotherNaturein classGameStateController- Parameters:
nSteps- indicates the number of steps for which the player intends to move motherNature- Throws:
InvalidNumberOfStepsException- if the player provides a number of steps that isn't between 0 and the maximum number of steps that the player chose during the planning phase.WrongPhaseException- if the method is executed in the wrong phase.MoreStudentsToBeMovedExceptionMoveAlreadyPlayedExceptionGameOverException
-
nextActionTurn
This method advances the turn during the action phase, after a player ended its turn.- Overrides:
nextActionTurnin classGameStateController- Throws:
GameOverException- if a gameOver condition has occurred
-
rollback
public void rollback()- Overrides:
rollbackin classGameStateController
-