Add: DrawCard implementations, fix: CurrentState nUpper&nLower management

This commit is contained in:
MatteoPellegrino05
2026-03-24 15:09:20 +01:00
parent fd621e90c7
commit 948f44c1dd
2 changed files with 49 additions and 20 deletions
@@ -2,6 +2,7 @@ package it.polimi.ingsw.gc14.Model;
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCard; import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.ShamanicRitual; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.ShamanicRitual;
@@ -96,11 +97,24 @@ public class Game {
{ {
return false; return false;
} }
if(player.equals(currentState.getCurrentPlayer())) if(!player.equals(currentState.getCurrentPlayer()))
{ {
}
return false; return false;
}
if(!board.containsUpperTribeCard(tribeCard))
return false;
if(currentState.getNUpper() <1)
return false;
if(!tribeCard.IsEventCard())
return false;
Character tempCard = (Character) tribeCard;
tempCard.insert(player);
board.removeUpperTribeCard(tempCard);
currentState.UpperDrawn();
if(currentState.getNUpper() ==0 && currentState.getNLower() ==0)
nextPlayerSetup();
return true;
} }
public boolean DrawLowerTribeCard(Player player,TribeCard tribeCard) { public boolean DrawLowerTribeCard(Player player,TribeCard tribeCard) {
@@ -108,11 +122,24 @@ public class Game {
{ {
return false; return false;
} }
if(player.equals(currentState.getCurrentPlayer())) if(!player.equals(currentState.getCurrentPlayer()))
{ {
}
return false; return false;
}
if(!board.containsLowerTribeCard(tribeCard))
return false;
if(currentState.getNLower() <1)
return false;
if(!tribeCard.IsEventCard())
return false;
Character tempCard = (Character) tribeCard;
tempCard.insert(player);
board.removeLowerTribeCard(tempCard);
currentState.LowerDrawn();
if(currentState.getNLower() ==0 && currentState.getNUpper() ==0)
nextPlayerSetup();
return true;
} }
@@ -129,6 +156,8 @@ public class Game {
{ {
return false; return false;
} }
if(currentState.getNUpper() <1)
return false;
if(buildingCard.buy(player)) if(buildingCard.buy(player))
{ {
currentState.UpperDrawn(); currentState.UpperDrawn();
@@ -136,11 +165,10 @@ public class Game {
} }
else else
return false; return false;
if(currentState.getNUpper()==currentState.getSlot().getNUpper()&& currentState.getNLower()==currentState.getSlot().getNLower()) if(currentState.getNLower() ==0 && currentState.getNUpper() ==0)
{ nextPlayerSetup();
} return true;
return false;
} }
public boolean DrawLowerBuildingCard(Player player,BuildingCard buildingCard) { public boolean DrawLowerBuildingCard(Player player,BuildingCard buildingCard) {
if(currentState.getGameStage()!= GameStages.RESOLVING_ACTIONS) if(currentState.getGameStage()!= GameStages.RESOLVING_ACTIONS)
@@ -155,23 +183,24 @@ public class Game {
{ {
return false; return false;
} }
if(currentState.getNLower() <1)
return false;
if(buildingCard.buy(player)) if(buildingCard.buy(player))
{ {
currentState.UpperDrawn(); currentState.LowerDrawn();
board.removeLowerBuildingCard(buildingCard); board.removeLowerBuildingCard(buildingCard);
} }
else else
return false; return false;
if(currentState.getNUpper()==currentState.getSlot().getNUpper()&& currentState.getNLower()==currentState.getSlot().getNLower()) if(currentState.getNLower() ==0 && currentState.getNUpper() ==0)
{ nextPlayerSetup();
return true;
}
return false;
} }
//endregion //endregion
private void EraUpdate(){}
private void nextPlayerSetup() { private void nextPlayerSetup() {
if(GameStages.RESOLVING_ACTIONS==currentState.getGameStage()) { if(GameStages.RESOLVING_ACTIONS==currentState.getGameStage()) {
orderLogicCard.push(currentState.getCurrentPlayer()); orderLogicCard.push(currentState.getCurrentPlayer());
@@ -53,11 +53,11 @@ public class CurrentState {
} }
public void UpperDrawn(){ public void UpperDrawn(){
NUpper++; NUpper--;
} }
public void LowerDrawn(){ public void LowerDrawn(){
NLower++; NLower--;
} }
public void GameStageUpdate(GameStages GameStage){ public void GameStageUpdate(GameStages GameStage){
@@ -80,8 +80,8 @@ public class CurrentState {
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;
this.NUpper = 0; this.NUpper = slot.getNUpper();
this.NLower = 0; this.NLower = slot.getNLower();
} }
// End functions // End functions
} }