Removed: PickOptionalTribeCard and PickOptionalBuildingCard in Game and GameController

This commit is contained in:
rubenpirreram
2026-05-17 16:32:42 +02:00
parent d9ef7983f8
commit 4b4614d17e
8 changed files with 90 additions and 205 deletions
@@ -411,11 +411,12 @@ public class Game implements Serializable {
* @param player the player performing the draw.
* @param cardIndex the index of the upper tribe card to draw.
* @return {@code true} if the draw succeeds, {@code false} otherwise.
* TODO
*/
public boolean DrawUpperTribeCardByIndex(Player player,int cardIndex) {
if( cardIndex<0 || cardIndex >=board.upperListTribe.size())
return false;
if(currentState.getGameStage()!= GameStages.RES_ACTIONS)
if(currentState.getGameStage()!= GameStages.RES_ACTIONS && currentState.getGameStage()!=GameStages.OPT_CARD_E)
{
return false;
}
@@ -423,7 +424,7 @@ public class Game implements Serializable {
{
return false;
}
if(currentState.getNUpper() <1)
if(currentState.getNUpper() <1 && currentState.getGameStage()==GameStages.RES_ACTIONS)
return false;
TribeCard tribeCard = board.upperListTribe.get(cardIndex);
if(tribeCard.IsEventCard())
@@ -432,9 +433,17 @@ public class Game implements Serializable {
Character tempCard = (Character) tribeCard;
tempCard.insert(player);
board.removeUpperTribeCard(tempCard);
currentState.UpperDrawn();
if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty())))
if(currentState.getGameStage()==GameStages.RES_ACTIONS)
{
currentState.UpperDrawn();
if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty())))
nextPlayerSetup();
}
else
{
nextPlayerSetup();
}
return true;
}
@@ -447,8 +456,8 @@ public class Game implements Serializable {
* @param player the player skipping the turn .
* @return {@code true} if the skip succeeds, {@code false} otherwise.
*/
public boolean SkipNoDrawable(Player player) {
if(currentState.getGameStage()!= GameStages.RES_ACTIONS)
public boolean SkipTurn(Player player) {
if(currentState.getGameStage()!= GameStages.RES_ACTIONS && !currentState.getGameStage().equals(GameStages.OPT_CARD_E))
{
return false;
}
@@ -456,15 +465,21 @@ public class Game implements Serializable {
{
return false;
}
if(hasDrawableDown() && currentState.getNLower()>0 )
return false;
if(hasDrawableUp() && currentState.getNUpper()>0)
return false;
while(currentState.getNLower()>0)
currentState.LowerDrawn();
while(currentState.getNUpper()>0)
currentState.UpperDrawn();
nextPlayerSetup();
if(currentState.getGameStage()==GameStages.RES_ACTIONS)
{
if(hasDrawableDown() && currentState.getNLower()>0 )
return false;
if(hasDrawableUp() && currentState.getNUpper()>0)
return false;
while(currentState.getNLower()>0)
currentState.LowerDrawn();
while(currentState.getNUpper()>0)
currentState.UpperDrawn();
nextPlayerSetup();
}
else {
nextPlayerSetup();
}
return true;
}
@@ -525,7 +540,7 @@ public class Game implements Serializable {
public boolean DrawUpperBuildingCardByIndex(Player player,int cardIndex) {
if( cardIndex<0 || cardIndex >=board.upperListBuilding.size())
return false;
if(currentState.getGameStage()!= GameStages.RES_ACTIONS)
if(currentState.getGameStage()!= GameStages.RES_ACTIONS && currentState.getGameStage()!=GameStages.OPT_CARD_E)
{
return false;
}
@@ -534,18 +549,23 @@ public class Game implements Serializable {
return false;
}
BuildingCard buildingCard = board.upperListBuilding.get(cardIndex);
if(currentState.getNUpper() <1)
if(currentState.getNUpper() <1 && currentState.getGameStage()==GameStages.RES_ACTIONS)
return false;
if(buildingCard.buy(player))
if(!buildingCard.buy(player))
{
return false;
}
board.removeUpperBuildingCard(buildingCard);
if(currentState.getGameStage().equals(GameStages.RES_ACTIONS))
{
currentState.UpperDrawn();
board.removeUpperBuildingCard(buildingCard);
if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty())))
nextPlayerSetup();
}
else
return false;
if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty())))
{
nextPlayerSetup();
}
return true;
}
@@ -594,98 +614,6 @@ public class Game implements Serializable {
//region Optional Card Methods
/**
* Attempts to pick the upper optional tribe card at the specified index for the specified player.
* The operation succeeds only if the current game stage is {@code OPTIONAL_CARD_EFFECT},
* the specified player is the current player, the index is valid,
* and the selected tribe card is not an event card.
* If successful, the card is inserted into the player's collection,
* removed from the board, the player is removed from the optional card queue,
* and the next player setup is triggered.
*
* @param player the player performing the optional tribe card pick.
* @param cardIndex the index of the upper optional tribe card to pick.
* @return {@code true} if the operation succeeds, {@code false} otherwise.
*/
public boolean PickOptionalTribeCardByIndex(Player player,int cardIndex) {
if(currentState.getGameStage() != GameStages.OPT_CARD_E){
return false;
}
if(!player.equals(currentState.getCurrentPlayer())){
return false;
}
if( cardIndex<0 || cardIndex >=board.upperListTribe.size())
return false;
TribeCard tribeCard = board.upperListTribe.get(cardIndex);
if(tribeCard.IsEventCard())
return false;
Character tempCard = (Character) tribeCard;
tempCard.insert(player);
board.removeUpperTribeCard(tempCard);
OptionalCardQueue.removeIf(x->x.equals(player));
nextPlayerSetup();
return true;
}
/**
* Attempts to pick the upper optional building card at the specified index for the specified player.
* The operation succeeds only if the current game stage is {@code OPTIONAL_CARD_EFFECT},
* the specified player is the current player, the index is valid,
* and the selected building card can be bought by the player.
* If successful, the card is removed from the board, the next player setup is triggered,
* and the player is removed from the optional card queue.
*
* @param player the player performing the optional building card pick.
* @param cardIndex the index of the upper optional building card to pick.
* @return {@code true} if the operation succeeds, {@code false} otherwise.
*/
public boolean PickOptionalBuildingCard(Player player, int cardIndex) {
if(currentState.getGameStage() != GameStages.OPT_CARD_E){
return false;
}
if(!player.equals(currentState.getCurrentPlayer())){
return false;
}
if( cardIndex<0 || cardIndex >=board.upperListBuilding.size())
return false;
BuildingCard buildingCard = board.upperListBuilding.get(cardIndex);
if(buildingCard.buy(player)) {
board.removeUpperBuildingCard(buildingCard);
}
else {
return false;
}
OptionalCardQueue.removeIf(x->x.equals(player));
nextPlayerSetup();
return true;
}
/**
* Skips the optional card choice for the specified player.
* The operation succeeds only if the current game stage is {@code OPTIONAL_CARD_EFFECT}
* and the specified player is the current player.
* If successful, the player is removed from the optional card queue
* and the next player setup is triggered.
*
* @param player the player skipping the optional card choice.
* @return {@code true} if the operation succeeds, {@code false} otherwise.
*/
public boolean NoOptionalCard(Player player) {
if(currentState.getGameStage() != GameStages.OPT_CARD_E){
return false;
}
if(!player.equals(currentState.getCurrentPlayer())){
return false;
}
OptionalCardQueue.removeIf(x->x.equals(player));
nextPlayerSetup();
return true;
}
//endregion
//endregion