Removed: Board in ApplyNextRound, MiniModel constructor

Added: upperListTribe,lowerListTribe,upperListBuilding,lowerListBuilding in MiniModel constructor
This commit is contained in:
rubenpirreram
2026-05-19 18:28:05 +02:00
parent d37c111c3c
commit 6da5670dff
10 changed files with 58 additions and 44 deletions
@@ -1,6 +1,8 @@
package it.polimi.ingsw.gc14.Network.NetworkEvents;
import it.polimi.ingsw.gc14.Controller.GameController;
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState;
import it.polimi.ingsw.gc14.Model.MiniModel;
import it.polimi.ingsw.gc14.Model.OrderLogicCard;
@@ -11,6 +13,7 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent;
import it.polimi.ingsw.gc14.View.IView;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -20,6 +23,11 @@ import java.util.Map;
public class ApplyNextRound extends NetworkEvent implements Serializable{
List<Player> players;
ArrayList<TribeCard> upperListTribeCards;
ArrayList<TribeCard> lowerListTribeCards;
ArrayList<BuildingCard> upperListBuildingCards;
ArrayList<BuildingCard> lowerListBuildingCards;
/**
* Constructs an event that updates the game state for the next round.
@@ -29,8 +37,12 @@ public class ApplyNextRound extends NetworkEvent implements Serializable{
* @param currentState the current state of the game.
* @param players the list of players in the game.
*/
public ApplyNextRound(Map<Slot, Player> slotPlayerMap, OrderLogicCard orderLogicCard, CurrentState currentState, List<Player> players){
public ApplyNextRound(Map<Slot, Player> slotPlayerMap, OrderLogicCard orderLogicCard, CurrentState currentState, List<Player> players, ArrayList<TribeCard> upperListTribeCards, ArrayList<TribeCard>lowerListTribeCards, ArrayList<BuildingCard> upperListBuildingCards, ArrayList<BuildingCard>lowerListBuildingCards) {
super("SERVER",EventType.NEXT_ROUND,false);
this.upperListBuildingCards = upperListBuildingCards;
this.lowerListBuildingCards = lowerListBuildingCards;
this.upperListTribeCards = upperListTribeCards;
this.lowerListTribeCards = lowerListTribeCards;
this.slotPlayerMap = slotPlayerMap;
this.orderLogicCard = orderLogicCard;
this.currentState = currentState;
@@ -51,7 +63,10 @@ public class ApplyNextRound extends NetworkEvent implements Serializable{
miniModel.setOrderLogicCard(orderLogicCard);
miniModel.setCurrentState(currentState);
miniModel.setPlayers(players);
miniModel.board.nextRound();
miniModel.upperListTribeCards=upperListTribeCards;
miniModel.lowerListTribeCards=lowerListTribeCards;
miniModel.upperListBuildingCards=upperListBuildingCards;
miniModel.lowerListBuildingCards=lowerListBuildingCards;
return true;
}
@@ -111,7 +111,7 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
System.out.println("Reconnected player: " + username);
startWatchdog(username);
Game game = controller.getModel();
callback.onGameInit(new MiniModel(game.getBoard(),game.getSlotMap(), game.orderLogicCard,game.getCurrentState(),game.getPlayers(),game.getAvailableTotems()));
callback.onGameInit(new MiniModel(game.getSlotMap(), game.orderLogicCard,game.getCurrentState(),game.getPlayers(),game.getAvailableTotems(),game.getUpperListTribeCards(),game.getLowerListTribeCards(),game.getUpperListBuilding(),game.getLowerListBuilding()));
System.out.println("Model sent: " + username);
actionQueue.add(new ReconnectPlayer(username));
return true;
@@ -137,7 +137,7 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
System.out.println("Reconnected player: " + username);
startWatchdog(username);
Game game = controller.getModel();
callback.onGameInit(new MiniModel(game.getBoard(),game.getSlotMap(), game.orderLogicCard,game.getCurrentState(),game.getPlayers(),game.getAvailableTotems()));
callback.onGameInit(new MiniModel(game.getSlotMap(), game.orderLogicCard,game.getCurrentState(),game.getPlayers(),game.getAvailableTotems(),game.getUpperListTribeCards(),game.getLowerListTribeCards(),game.getUpperListBuilding(),game.getLowerListBuilding()));
System.out.println("Model sent: " + username);
actionQueue.add(new ReconnectPlayer(username));
return true;
@@ -228,12 +228,12 @@ public class TCPServer {
Game game = controller.getModel();
handler.notifyMiniModel(new MiniModel(
game.getBoard(),
game.getSlotMap(),
game.orderLogicCard,
game.getCurrentState(),
game.getPlayers(),
game.getAvailableTotems()
game.getAvailableTotems(),
game.getUpperListTribeCards(),game.getLowerListTribeCards(),game.getUpperListBuilding(),game.getLowerListBuilding()
));
Thread thread = new Thread(handler);
@@ -300,12 +300,13 @@ public class TCPServer {
Game game = controller.getModel();
handler.notifyMiniModel(new MiniModel(
game.getBoard(),
game.getSlotMap(),
game.orderLogicCard,
game.getCurrentState(),
game.getPlayers(),
game.getAvailableTotems()
game.getAvailableTotems(),
game.getUpperListTribeCards(),game.getLowerListTribeCards(),game.getUpperListBuilding(),game.getLowerListBuilding()
));
Thread thread = new Thread(handler);