Add: Javadoc for CurrentState class
This commit is contained in:
@@ -4,39 +4,108 @@ import it.polimi.ingsw.gc14.Model.Player;
|
|||||||
import it.polimi.ingsw.gc14.Model.Slot;
|
import it.polimi.ingsw.gc14.Model.Slot;
|
||||||
import it.polimi.ingsw.gc14.Model.GamePackage.GameStages;
|
import it.polimi.ingsw.gc14.Model.GamePackage.GameStages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the current state of the game.
|
||||||
|
* A CurrentState object stores the current player, slot, era, round,
|
||||||
|
* remaining upper and lower cards, and the current game stage.
|
||||||
|
*/
|
||||||
public class CurrentState {
|
public class CurrentState {
|
||||||
// region Getters
|
// region Getters
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current player associated with the game state.
|
||||||
|
*/
|
||||||
private Player player;
|
private Player player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current player.
|
||||||
|
*
|
||||||
|
* @return the current player.
|
||||||
|
*/
|
||||||
public Player getCurrentPlayer(){
|
public Player getCurrentPlayer(){
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current slot associated with the game state.
|
||||||
|
*/
|
||||||
private Slot slot;
|
private Slot slot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current slot.
|
||||||
|
*
|
||||||
|
* @return the current slot.
|
||||||
|
*/
|
||||||
public Slot getSlot(){
|
public Slot getSlot(){
|
||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current era of the game.
|
||||||
|
*/
|
||||||
private int Era;
|
private int Era;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current era of the game.
|
||||||
|
*
|
||||||
|
* @return the current era of the game.
|
||||||
|
*/
|
||||||
public int getEra(){
|
public int getEra(){
|
||||||
return Era;
|
return Era;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current round of the game.
|
||||||
|
*/
|
||||||
private int round;
|
private int round;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current round of the game.
|
||||||
|
*
|
||||||
|
* @return the current round of the game.
|
||||||
|
*/
|
||||||
public int getRound(){
|
public int getRound(){
|
||||||
return round;
|
return round;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of upper cards currently available.
|
||||||
|
*/
|
||||||
private int NUpper;
|
private int NUpper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of upper cards currently available.
|
||||||
|
*
|
||||||
|
* @return the number of upper cards currently available.
|
||||||
|
*/
|
||||||
public int getNUpper(){
|
public int getNUpper(){
|
||||||
return NUpper;
|
return NUpper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of lower cards currently available.
|
||||||
|
*/
|
||||||
private int NLower;
|
private int NLower;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of lower cards currently available.
|
||||||
|
*
|
||||||
|
* @return the number of lower cards currently available.
|
||||||
|
*/
|
||||||
public int getNLower(){
|
public int getNLower(){
|
||||||
return NLower;
|
return NLower;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current stage of the game.
|
||||||
|
*/
|
||||||
private GameStages GameStage;
|
private GameStages GameStage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current stage of the game.
|
||||||
|
*
|
||||||
|
* @return the current stage of the game.
|
||||||
|
*/
|
||||||
public GameStages getGameStage(){
|
public GameStages getGameStage(){
|
||||||
return GameStage;
|
return GameStage;
|
||||||
}
|
}
|
||||||
@@ -44,28 +113,52 @@ public class CurrentState {
|
|||||||
// endregion getters
|
// endregion getters
|
||||||
|
|
||||||
// region Setters
|
// region Setters
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increments the current era by 1.
|
||||||
|
*/
|
||||||
public void EraUpdate(){
|
public void EraUpdate(){
|
||||||
Era++;
|
Era++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increments the current round by 1.
|
||||||
|
*/
|
||||||
public void RoundUpdate(){
|
public void RoundUpdate(){
|
||||||
round++;
|
round++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrements the number of upper cards by 1.
|
||||||
|
*/
|
||||||
public void UpperDrawn(){
|
public void UpperDrawn(){
|
||||||
NUpper--;
|
NUpper--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrements the number of lower cards by 1.
|
||||||
|
*/
|
||||||
public void LowerDrawn(){
|
public void LowerDrawn(){
|
||||||
NLower--;
|
NLower--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the current game stage.
|
||||||
|
*
|
||||||
|
* @param GameStage the new game stage.
|
||||||
|
*/
|
||||||
public void GameStageUpdate(GameStages GameStage){
|
public void GameStageUpdate(GameStages GameStage){
|
||||||
this.GameStage = GameStage;
|
this.GameStage = GameStage;
|
||||||
}
|
}
|
||||||
// endregion setters
|
// endregion setters
|
||||||
|
|
||||||
// region Constructors
|
// region Constructors
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new CurrentState object with default initial values.
|
||||||
|
* The initial player and slot are {@code null}, the era and round are set to 1,
|
||||||
|
* the number of upper and lower cards is set to 0, and the game stage is set to {@code WAITING}.
|
||||||
|
*/
|
||||||
public CurrentState(){
|
public CurrentState(){
|
||||||
this.player = null;
|
this.player = null;
|
||||||
this.slot = null;
|
this.slot = null;
|
||||||
@@ -78,6 +171,15 @@ public class CurrentState {
|
|||||||
// endregion constructors
|
// endregion constructors
|
||||||
|
|
||||||
// region Functions
|
// region Functions
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the current player and slot.
|
||||||
|
* If the specified slot is {@code null}, the numbers of upper and lower cards are both set to 0.
|
||||||
|
* Otherwise, the numbers of upper and lower cards are updated using the values of the specified slot.
|
||||||
|
*
|
||||||
|
* @param player the new current player.
|
||||||
|
* @param slot the new current slot.
|
||||||
|
*/
|
||||||
public void PlayerUpdate(Player player, Slot slot){
|
public void PlayerUpdate(Player player, Slot slot){
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
|
|||||||
Reference in New Issue
Block a user