Fixed: now at every action is sent all playersList
This commit is contained in:
@@ -8,6 +8,7 @@ import it.polimi.ingsw.gc14.Model.Player;
|
|||||||
import it.polimi.ingsw.gc14.Model.Slot;
|
import it.polimi.ingsw.gc14.Model.Slot;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,9 +56,9 @@ public abstract class NetworkEvent implements Serializable {
|
|||||||
protected CurrentState currentState;
|
protected CurrentState currentState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player directly involved in the event, when required.
|
* List of all players.
|
||||||
*/
|
*/
|
||||||
protected Player player;
|
protected List<Player> playerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the game data associated with this network event.
|
* Sets the game data associated with this network event.
|
||||||
@@ -65,16 +66,16 @@ public abstract class NetworkEvent implements Serializable {
|
|||||||
* @param slotPlayerMap the map associating each slot with the player occupying it.
|
* @param slotPlayerMap the map associating each slot with the player occupying it.
|
||||||
* @param orderLogicCard the order logic card used to manage turn order.
|
* @param orderLogicCard the order logic card used to manage turn order.
|
||||||
* @param currentState the current state of the game.
|
* @param currentState the current state of the game.
|
||||||
* @param player the player directly associated with the event.
|
* @param playerList the list of the actual state of the players
|
||||||
*/
|
*/
|
||||||
public void setData(Map<Slot, Player> slotPlayerMap,
|
public void setData(Map<Slot, Player> slotPlayerMap,
|
||||||
OrderLogicCard orderLogicCard,
|
OrderLogicCard orderLogicCard,
|
||||||
CurrentState currentState,
|
CurrentState currentState,
|
||||||
Player player) {
|
List<Player> playerList) {
|
||||||
this.slotPlayerMap = slotPlayerMap;
|
this.slotPlayerMap = slotPlayerMap;
|
||||||
this.orderLogicCard = orderLogicCard;
|
this.orderLogicCard = orderLogicCard;
|
||||||
this.currentState = currentState;
|
this.currentState = currentState;
|
||||||
this.player = player;
|
this.playerList = playerList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class AddPlayer extends NetworkEvent implements Serializable {
|
|||||||
public boolean apply(MiniModel miniModel){
|
public boolean apply(MiniModel miniModel){
|
||||||
if(isError)
|
if(isError)
|
||||||
return false;
|
return false;
|
||||||
miniModel.setPlayer(player);
|
miniModel.setPlayers(playerList);
|
||||||
miniModel.setOrderLogicCard(orderLogicCard);
|
miniModel.setOrderLogicCard(orderLogicCard);
|
||||||
miniModel.setCurrentState(currentState);
|
miniModel.setCurrentState(currentState);
|
||||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class DisconnectedPlayer extends NetworkEvent implements Serializable{
|
|||||||
return false;
|
return false;
|
||||||
if(miniModel!=null)
|
if(miniModel!=null)
|
||||||
{
|
{
|
||||||
miniModel.setPlayer(player);
|
miniModel.setPlayers(playerList);
|
||||||
miniModel.setOrderLogicCard(orderLogicCard);
|
miniModel.setOrderLogicCard(orderLogicCard);
|
||||||
miniModel.setCurrentState(currentState);
|
miniModel.setCurrentState(currentState);
|
||||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class DrawLowerBuildingCard extends NetworkEvent implements Serializable
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
miniModel.lowerListBuildingCards.remove(pos);
|
miniModel.lowerListBuildingCards.remove(pos);
|
||||||
miniModel.setPlayer(player);
|
miniModel.setPlayers(playerList);
|
||||||
miniModel.setOrderLogicCard(orderLogicCard);
|
miniModel.setOrderLogicCard(orderLogicCard);
|
||||||
miniModel.setCurrentState(currentState);
|
miniModel.setCurrentState(currentState);
|
||||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class DrawLowerTribeCard extends NetworkEvent implements Serializable{
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
miniModel.lowerListTribeCards.remove(pos);
|
miniModel.lowerListTribeCards.remove(pos);
|
||||||
miniModel.setPlayer(player);
|
miniModel.setPlayers(playerList);
|
||||||
miniModel.setOrderLogicCard(orderLogicCard);
|
miniModel.setOrderLogicCard(orderLogicCard);
|
||||||
miniModel.setCurrentState(currentState);
|
miniModel.setCurrentState(currentState);
|
||||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class DrawUpperBuildingCard extends NetworkEvent implements Serializable
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
miniModel.upperListBuildingCards.remove(pos);
|
miniModel.upperListBuildingCards.remove(pos);
|
||||||
miniModel.setPlayer(player);
|
miniModel.setPlayers(playerList);
|
||||||
miniModel.setOrderLogicCard(orderLogicCard);
|
miniModel.setOrderLogicCard(orderLogicCard);
|
||||||
miniModel.setCurrentState(currentState);
|
miniModel.setCurrentState(currentState);
|
||||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class DrawUpperTribeCard extends NetworkEvent implements Serializable{
|
|||||||
if(isError)
|
if(isError)
|
||||||
return false;
|
return false;
|
||||||
miniModel.upperListTribeCards.remove(pos);
|
miniModel.upperListTribeCards.remove(pos);
|
||||||
miniModel.setPlayer(player);
|
miniModel.setPlayers(playerList);
|
||||||
miniModel.setOrderLogicCard(orderLogicCard);
|
miniModel.setOrderLogicCard(orderLogicCard);
|
||||||
miniModel.setCurrentState(currentState);
|
miniModel.setCurrentState(currentState);
|
||||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class ReconnectPlayer extends NetworkEvent implements Serializable {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (miniModel != null) {
|
if (miniModel != null) {
|
||||||
miniModel.setPlayer(player);
|
miniModel.setPlayers(playerList);
|
||||||
miniModel.setOrderLogicCard(orderLogicCard);
|
miniModel.setOrderLogicCard(orderLogicCard);
|
||||||
miniModel.setCurrentState(currentState);
|
miniModel.setCurrentState(currentState);
|
||||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class SkipTurn extends NetworkEvent implements Serializable{
|
|||||||
public boolean apply(MiniModel miniModel){
|
public boolean apply(MiniModel miniModel){
|
||||||
if(isError)
|
if(isError)
|
||||||
return false;
|
return false;
|
||||||
miniModel.setPlayer(player);
|
miniModel.setPlayers(playerList);
|
||||||
miniModel.setOrderLogicCard(orderLogicCard);
|
miniModel.setOrderLogicCard(orderLogicCard);
|
||||||
miniModel.setCurrentState(currentState);
|
miniModel.setCurrentState(currentState);
|
||||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class SlotChoice extends NetworkEvent implements Serializable {
|
|||||||
public boolean apply(MiniModel miniModel){
|
public boolean apply(MiniModel miniModel){
|
||||||
if(isError)
|
if(isError)
|
||||||
return false;
|
return false;
|
||||||
miniModel.setPlayer(player);
|
miniModel.setPlayers(playerList);
|
||||||
miniModel.setOrderLogicCard(orderLogicCard);
|
miniModel.setOrderLogicCard(orderLogicCard);
|
||||||
miniModel.setCurrentState(currentState);
|
miniModel.setCurrentState(currentState);
|
||||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class TotemChoice extends NetworkEvent implements Serializable {
|
|||||||
if (isError)
|
if (isError)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
miniModel.setPlayer(player);
|
miniModel.setPlayers(playerList);
|
||||||
miniModel.setOrderLogicCard(orderLogicCard);
|
miniModel.setOrderLogicCard(orderLogicCard);
|
||||||
miniModel.setCurrentState(currentState);
|
miniModel.setCurrentState(currentState);
|
||||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public class ServerLauncher {
|
|||||||
{
|
{
|
||||||
playerList.remove(event.getUsername());
|
playerList.remove(event.getUsername());
|
||||||
}else {
|
}else {
|
||||||
event.setData(game.getSlotMap(), game.orderLogicCard, game.getCurrentState(), game.getPlayerByUsername(event.getUsername()));
|
event.setData(game.getSlotMap(), game.orderLogicCard, game.getCurrentState(), game.getPlayers());
|
||||||
if (event.getEventType().equals(EventType.TOTEM_CHOICE)) {
|
if (event.getEventType().equals(EventType.TOTEM_CHOICE)) {
|
||||||
((TotemChoice) event).setAvailableTotems(gameController.getModel().getAvailableTotems());
|
((TotemChoice) event).setAvailableTotems(gameController.getModel().getAvailableTotems());
|
||||||
} else if (event.getEventType().equals(EventType.DISCONNECTED_PLAYER) && game.getCurrentState().equals(GameStages.WAITING)) {
|
} else if (event.getEventType().equals(EventType.DISCONNECTED_PLAYER) && game.getCurrentState().equals(GameStages.WAITING)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user