Package it.polimi.ingsw.client
Interface View
- All Known Implementing Classes:
Cli,GuiManager
public interface View
Interface that defines the methods of the interfaces (CLI and GUI)
that need to be implemented to guarantee a correct game flow.
-
Method Summary
Modifier and Type Method Description java.lang.StringaskBuildAgainDemeter()Asks to the player that holds Demeter as a God if he wants to build again.java.lang.StringaskBuildAgainHephaestus()Asks to the player that holds Hephaestus as a God if he wants to build again.java.lang.StringaskBuildAgainHestia()Asks to the player that holds Hestia as a God if he wants to build again.java.lang.StringaskBuildingDirection()This method asks the user to insert the position where he wants to build.java.lang.String[]askBuildingDirectionAtlas()This method asks to Atlas' owner to insert the position where he wants to build and what type of building.java.lang.StringaskBuildPrometheus()Asks to the player that holds Prometheus as a God if he wants to build before moving.java.lang.StringaskChosenWorker()Asks to the player which one of his worker wants to play with during the current turn.int[]askInitialWorkerPosition(java.lang.String workerSex)This method asks the player to set his worker initial position.java.lang.StringaskMoveAgain()Allows to get the input of the player to move again.java.lang.StringaskMovementDirection()This method asks the user to insert the direction of his next movement.intaskNumberOfPlayers()Asks to the creator of a game how many players will the game hold.java.lang.StringaskPlayerColor(java.util.ArrayList<java.lang.String> availableColors)Asks to the player the color for the game.java.lang.StringaskPlayerGod()Asks to the player which God among the available ones wants to play with during the current game.java.lang.StringaskPlayerNickname()Asks to the player the nickname for the game.java.lang.StringaskWantToMoveEnemy()Allows to get the input of the player to move an enemy's worker.java.lang.StringaskWorkerToMove(java.util.ArrayList<WorkerClient> enemyWorkers, WorkerClient myWorker)Allows to move one worker's enemy.java.lang.StringchallengerChooseStartPlayer()Asks to the challenger which player will be the starting one.voidconnectionOutcome(boolean connected)Shows if the connection to the server was successful or notvoidcreateGame()Lets the player know he is the creator of a new game.java.lang.StringgetGodFromChallenger(int numOfPlayers, int alreadyChosenGods)Lets the challenger know how many gods he still has to choose.java.lang.StringgetServerAddress()Asks the IP of the server where the client wants to connect to.voidinvalidInitialWorkerPosition()Lets the player know the position he wrote for the initial worker position was wrong.voidjoinGame(int numberOfPlayers)Lets the player know the number of players for the game he's been assigned.booleanlosingView(java.lang.String winner)Lets player know that he has lost, and who is the winner.voidnicknameFormatError()Lets the client know that the nickname entered is too long or empty.voidnotAvailableColor()Lets the player know that the chosen color was not available, maybe because another player had already chosen it before or maybe because that was not a color defined by the game.voidnotAvailableNickname()Tells the player that the inserted nickname was not available.voidnotifyOtherPlayerDisconnection(java.lang.String disconnectedPlayer)Displays that a player has been disconnected and reason.voidnotifyPlayersOfLoss(java.lang.String loserNickname)In a 3 players game, this method notifies the other players that a player has lost the game.voidnotifyValidColor()Notifies the player that his color choice was accepted by the server.voidnotifyValidNick()Notifies the player that his nickname was accepted by the server.voidotherPlayerChoseGod(java.lang.String otherPlayer, java.lang.String chosenGod)Lets player know the god chosen by another playervoidotherPlayerSettingInitialWorkerPosition(java.lang.String player)Lets player know that another player is choosing the initial position for his workersvoidotherPlayerTurn(java.lang.String currentPlayer)Lets player know that it's another player's turnvoidplayerChoseInvalidGod()Lets the player know that his God's choice was rejected by the server.voidprintBuildBlockErrorScreen()Points out a player is not allowed to build a block in a certain position.java.lang.StringprintBuildDecisionError()Asks the player if he still wants to build during this turn.voidprintBuildGeneralErrorScreen()Points out a player is not allowed to build.voidprintBuildInSamePositionScreen()Points out that a player is not allowed to build again in a certain position.voidprintCannotBuildDomeUnderneath()Warns user of invalid build action: he cannot build a dome underneath himself.voidprintChosenGods(java.util.ArrayList<java.lang.String> chosenGods)Prints all the Gods chosen by the challenger for the current game.voidprintMap()This method prints an updated version of the Board, depending on the Class' parameter "mymap".java.lang.StringprintMoveDecisionError()Asks the player if he still wants to move during this turn.voidprintMoveErrorScreen()Points out the player cannot move in a certain position.voidprintStartPlayer(java.lang.String startPlayer)Lets player know who is the start playervoidselectedWorkerCannotMove(java.lang.String sex)Lets the player know the selected worker cannot move.voidsetOtherPlayersInfo(java.lang.String nickname, java.lang.String color)Allows to set and to store in the local cli memory the general settings info of other players.booleanunableToBuildLose()Lets the player know he has lost the game because both of his workers cannot build.booleanunableToMoveLose()Lets the player know he has lost the game because both of his workers cannot move.voidupdate(CellClient toUpdateCell)Updates the cell of the board that has changed its contents.voidwaitChallengerChooseGods(java.lang.String challenger)Lets player know that the challenger is choosing the gods for the game.voidwaitChallengerStartPlayer()Lets player know that the challenger is choosing the start playervoidwaitOtherPlayerChooseGod(java.lang.String otherPlayer)Lets player know that another player is choosing his godbooleanwinningView()Prints to screen that the player has won the game.
-
Method Details
-
getServerAddress
java.lang.String getServerAddress()Asks the IP of the server where the client wants to connect to.- Returns:
- The IP of the server to connect to.
-
joinGame
void joinGame(int numberOfPlayers)Lets the player know the number of players for the game he's been assigned. The player in this specific case did not choose the number of players for the game, but someone else did (the so called "creator").- Parameters:
numberOfPlayers- The number of players of the game the player has been assigned to.
-
createGame
void createGame()Lets the player know he is the creator of a new game. -
connectionOutcome
void connectionOutcome(boolean connected)Shows if the connection to the server was successful or not- Parameters:
connected- True if the connection was established, false otherwise.
-
nicknameFormatError
void nicknameFormatError()Lets the client know that the nickname entered is too long or empty. -
notifyValidNick
void notifyValidNick()Notifies the player that his nickname was accepted by the server. -
notifyValidColor
void notifyValidColor()Notifies the player that his color choice was accepted by the server. Sets also the local info about the player (his nickname and color). -
notifyOtherPlayerDisconnection
void notifyOtherPlayerDisconnection(java.lang.String disconnectedPlayer)Displays that a player has been disconnected and reason.- Parameters:
disconnectedPlayer- The name of the disconnected player.
-
askNumberOfPlayers
int askNumberOfPlayers()Asks to the creator of a game how many players will the game hold.- Returns:
- The number of players decided by the creator player.
-
askInitialWorkerPosition
int[] askInitialWorkerPosition(java.lang.String workerSex) throws java.util.InputMismatchExceptionThis method asks the player to set his worker initial position. It will be invoked both for the male worker and the female worker of every player.- Parameters:
workerSex- This is the sex of the worker to be placed on the board.- Returns:
- Array with x,y coordinates of the chosen position.
- Throws:
java.util.InputMismatchException
-
setOtherPlayersInfo
void setOtherPlayersInfo(java.lang.String nickname, java.lang.String color)Allows to set and to store in the local cli memory the general settings info of other players. Allows also to store into specific colored class attributes the info of the players, so that a better representation when printing the game's board can be done.- Parameters:
nickname- Nickname of the player to register.color- Color chosen by that specific player for the current game.
-
invalidInitialWorkerPosition
void invalidInitialWorkerPosition()Lets the player know the position he wrote for the initial worker position was wrong. -
askPlayerNickname
java.lang.String askPlayerNickname()Asks to the player the nickname for the game.- Returns:
- The nickname chosen by the player.
-
askPlayerColor
java.lang.String askPlayerColor(java.util.ArrayList<java.lang.String> availableColors)Asks to the player the color for the game. Only three colors are available: blue, white and beige.- Parameters:
availableColors- available colors for the game.- Returns:
- The color chosen by the player.
-
askPlayerGod
java.lang.String askPlayerGod()Asks to the player which God among the available ones wants to play with during the current game.- Returns:
- The name of the chosen God.
-
playerChoseInvalidGod
void playerChoseInvalidGod()Lets the player know that his God's choice was rejected by the server. -
getGodFromChallenger
java.lang.String getGodFromChallenger(int numOfPlayers, int alreadyChosenGods)Lets the challenger know how many gods he still has to choose. Then the challenger, if other gods need to be selected, chooses another god for the game.- Parameters:
numOfPlayers- The number of players of the current game.alreadyChosenGods- The number of gods that the challenger has already chosen for the game.- Returns:
- Another name of the God the challenger chooses for the current game.
-
challengerChooseStartPlayer
java.lang.String challengerChooseStartPlayer()Asks to the challenger which player will be the starting one.- Returns:
- The nickname of the starting player.
-
notAvailableColor
void notAvailableColor()Lets the player know that the chosen color was not available, maybe because another player had already chosen it before or maybe because that was not a color defined by the game. -
notAvailableNickname
void notAvailableNickname()Tells the player that the inserted nickname was not available. This error can occur when the length of the nickname is too long or when the same nick was already chosen by another player. -
askChosenWorker
java.lang.String askChosenWorker()Asks to the player which one of his worker wants to play with during the current turn.- Returns:
- The sex of the worker the player wants to play with.
-
winningView
boolean winningView()Prints to screen that the player has won the game.- Returns:
- Generic return to ensure server waits for confirmation from client before disconnecting it.
-
unableToMoveLose
boolean unableToMoveLose()Lets the player know he has lost the game because both of his workers cannot move.- Returns:
- Generic return to ensure server waits for confirmation from client before disconnecting it.
-
unableToBuildLose
boolean unableToBuildLose()Lets the player know he has lost the game because both of his workers cannot build.- Returns:
- Generic return to ensure server waits for confirmation from client before disconnecting it.
-
notifyPlayersOfLoss
void notifyPlayersOfLoss(java.lang.String loserNickname)In a 3 players game, this method notifies the other players that a player has lost the game.- Parameters:
loserNickname- The nickname of the player that has lost the game.
-
printMap
void printMap()This method prints an updated version of the Board, depending on the Class' parameter "mymap". -
update
Updates the cell of the board that has changed its contents.- Parameters:
toUpdateCell- The cell that needs to be updated.
-
printChosenGods
void printChosenGods(java.util.ArrayList<java.lang.String> chosenGods)Prints all the Gods chosen by the challenger for the current game.- Parameters:
chosenGods- The list of the chosen gods.
-
selectedWorkerCannotMove
void selectedWorkerCannotMove(java.lang.String sex)Lets the player know the selected worker cannot move.- Parameters:
sex- The sex of the selected worker
-
askBuildingDirection
java.lang.String askBuildingDirection()This method asks the user to insert the position where he wants to build.- Returns:
- The compass direction of the place where to build.
-
askBuildingDirectionAtlas
java.lang.String[] askBuildingDirectionAtlas()This method asks to Atlas' owner to insert the position where he wants to build and what type of building.- Returns:
- The compass direction of the place where to build.
-
askMovementDirection
java.lang.String askMovementDirection()This method asks the user to insert the direction of his next movement.- Returns:
- The compass direction of the movement.
-
askMoveAgain
java.lang.String askMoveAgain()Allows to get the input of the player to move again.- Returns:
- The will of the player on keeping going moving his worker on the board.
-
askWantToMoveEnemy
java.lang.String askWantToMoveEnemy()Allows to get the input of the player to move an enemy's worker.- Returns:
- The will of the player to move an enemy's worker
-
askWorkerToMove
java.lang.String askWorkerToMove(java.util.ArrayList<WorkerClient> enemyWorkers, WorkerClient myWorker)Allows to move one worker's enemy.- Parameters:
enemyWorkers- It's the list of the neighbour movable enemy workers.myWorker- It's the chosen worker of the current player.- Returns:
- The Worker to move selected by the player.
-
askBuildAgainHephaestus
java.lang.String askBuildAgainHephaestus()Asks to the player that holds Hephaestus as a God if he wants to build again.- Returns:
- The will of the player to build again.
-
askBuildAgainDemeter
java.lang.String askBuildAgainDemeter()Asks to the player that holds Demeter as a God if he wants to build again.- Returns:
- The will of the player to build again.
-
askBuildAgainHestia
java.lang.String askBuildAgainHestia()Asks to the player that holds Hestia as a God if he wants to build again.- Returns:
- The will of the player to build again.
-
askBuildPrometheus
java.lang.String askBuildPrometheus()Asks to the player that holds Prometheus as a God if he wants to build before moving.- Returns:
- The will of the player to build before moving.
-
printMoveErrorScreen
void printMoveErrorScreen()Points out the player cannot move in a certain position. -
printCannotBuildDomeUnderneath
void printCannotBuildDomeUnderneath()Warns user of invalid build action: he cannot build a dome underneath himself. This error can only occur if player uses Zeus' power. -
printMoveDecisionError
java.lang.String printMoveDecisionError()Asks the player if he still wants to move during this turn.- Returns:
- Y for a positive answer, N for a negative one.
-
printBuildDecisionError
java.lang.String printBuildDecisionError()Asks the player if he still wants to build during this turn.- Returns:
- Y for a positive answer, N for a negative one.
-
printBuildGeneralErrorScreen
void printBuildGeneralErrorScreen()Points out a player is not allowed to build. -
printBuildBlockErrorScreen
void printBuildBlockErrorScreen()Points out a player is not allowed to build a block in a certain position. -
printBuildInSamePositionScreen
void printBuildInSamePositionScreen()Points out that a player is not allowed to build again in a certain position. -
waitChallengerChooseGods
void waitChallengerChooseGods(java.lang.String challenger)Lets player know that the challenger is choosing the gods for the game.- Parameters:
challenger- nickname of the challenger
-
waitOtherPlayerChooseGod
void waitOtherPlayerChooseGod(java.lang.String otherPlayer)Lets player know that another player is choosing his god- Parameters:
otherPlayer- the player that is choosing his god
-
otherPlayerChoseGod
void otherPlayerChoseGod(java.lang.String otherPlayer, java.lang.String chosenGod)Lets player know the god chosen by another player- Parameters:
otherPlayer- player who chose the godchosenGod- god chosen by the otherPlayer
-
waitChallengerStartPlayer
void waitChallengerStartPlayer()Lets player know that the challenger is choosing the start player -
printStartPlayer
void printStartPlayer(java.lang.String startPlayer)Lets player know who is the start player- Parameters:
startPlayer- start player nickname
-
otherPlayerSettingInitialWorkerPosition
void otherPlayerSettingInitialWorkerPosition(java.lang.String player)Lets player know that another player is choosing the initial position for his workers- Parameters:
player- player who is performing the action
-
otherPlayerTurn
void otherPlayerTurn(java.lang.String currentPlayer)Lets player know that it's another player's turn- Parameters:
currentPlayer- nickname of the player that is playing his turn
-
losingView
boolean losingView(java.lang.String winner)Lets player know that he has lost, and who is the winner.- Parameters:
winner- nickname of the winner- Returns:
- Generic return to ensure server waits for confirmation from client before disconnecting it.
-