Removed property changes
This commit is contained in:
@@ -6,15 +6,12 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
|
||||
import it.polimi.ingsw.gc14.Model.GamePackage.Board;
|
||||
import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
public class MiniModel implements Serializable {
|
||||
|
||||
private final PropertyChangeSupport support = new PropertyChangeSupport(this);
|
||||
|
||||
public Board board;
|
||||
public Map<Slot, Player> slotPlayerMap;
|
||||
public OrderLogicCard orderLogicCard;
|
||||
@@ -22,7 +19,7 @@ public class MiniModel implements Serializable {
|
||||
public Map<String, Player> players;
|
||||
public List<Totems> availableTotems;
|
||||
|
||||
// --- Costruttori invariati ---
|
||||
// --- Costruttori ---
|
||||
|
||||
public MiniModel() {
|
||||
|
||||
@@ -43,63 +40,39 @@ public class MiniModel implements Serializable {
|
||||
setPlayers(players);
|
||||
}
|
||||
|
||||
// --- Gestione listener ---
|
||||
|
||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||
support.addPropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
public void removePropertyChangeListener(PropertyChangeListener listener) {
|
||||
support.removePropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
// --- Setter con notifica ---
|
||||
// --- Setter ---
|
||||
|
||||
public void setBoard(Board board) {
|
||||
Board old = this.board;
|
||||
this.board = board;
|
||||
support.firePropertyChange("board", old, board);
|
||||
}
|
||||
|
||||
public void setAvailableTotems(List<Totems> availableTotems) {
|
||||
List<Totems> old = this.availableTotems;
|
||||
this.availableTotems = availableTotems;
|
||||
support.firePropertyChange("availableTotems", old, availableTotems);
|
||||
}
|
||||
|
||||
public void setSlotPlayerMap(Map<Slot, Player> slotPlayerMap) {
|
||||
Map<Slot, Player> old = this.slotPlayerMap;
|
||||
this.slotPlayerMap = slotPlayerMap;
|
||||
support.firePropertyChange("slotPlayerMap", old, slotPlayerMap);
|
||||
}
|
||||
|
||||
public void setOrderLogicCard(OrderLogicCard orderLogicCard) {
|
||||
OrderLogicCard old = this.orderLogicCard;
|
||||
this.orderLogicCard = orderLogicCard;
|
||||
support.firePropertyChange("orderLogicCard", old, orderLogicCard);
|
||||
}
|
||||
|
||||
public void setCurrentState(CurrentState currentState) {
|
||||
CurrentState old = this.currentState;
|
||||
this.currentState = currentState;
|
||||
support.firePropertyChange("currentState", old, currentState);
|
||||
}
|
||||
|
||||
public void setPlayers(List<Player> players) {
|
||||
Map<String, Player> old = new HashMap<>(this.players != null ? this.players : new HashMap<>());
|
||||
for (Player player : players) {
|
||||
this.players.put(player.getUserName(), player);
|
||||
}
|
||||
support.firePropertyChange("players", old, this.players);
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
Map<String, Player> old = new HashMap<>(this.players);
|
||||
players.put(player.getUserName(), player);
|
||||
support.firePropertyChange("players", old, this.players);
|
||||
}
|
||||
|
||||
// --- Metodi invariati ---
|
||||
|
||||
public int getPositionByUsername(String username) {
|
||||
int i = 0;
|
||||
|
||||
Reference in New Issue
Block a user