Removed property changes

This commit is contained in:
2026-05-14 16:42:19 +02:00
parent 9fa51e9fe7
commit 711d57e4cd
3 changed files with 8 additions and 54 deletions
@@ -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;
@@ -25,7 +25,7 @@ public abstract class OrderLogicCard implements Serializable {
/**
* The list of {@link Player Players} associated with this order logic card.
*/
protected List<OrderPlayer> playerList;
public List<OrderPlayer> playerList;
/**
@@ -6,6 +6,7 @@ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
import it.polimi.ingsw.gc14.Model.GamePackage.Board;
import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState;
import it.polimi.ingsw.gc14.Model.Orders.OrderPlayer;
import javafx.animation.ScaleTransition;
import javafx.application.Platform;
import javafx.event.Event;
@@ -70,25 +71,9 @@ public class MainFXMLController {
// Initialize popup
initPopup();
controller.miniModel.addPropertyChangeListener(evt -> {
switch (evt.getPropertyName()) {
case "board" -> ciao("board");
case "currentState" -> ciao("currentState");
case "players" -> Platform.runLater(() -> renderSidePanel());
case "slotPlayerMap" -> Platform.runLater(() -> renderBoard());
case "orderLogicCard"-> Platform.runLater(() -> renderBoard());
case "availableTotems"-> ciao("availableTotems");
}
});
}
public void ciao(String s) {
System.out.println(s);
}
public void render() {
renderBackground();
@@ -309,15 +294,11 @@ public class MainFXMLController {
StackPane.setAlignment(overlay, Pos.TOP_LEFT);
StackPane.setMargin(overlay, new Insets(9, 0, 0, 57));
List<Player> ordered = controller.miniModel.players.values().stream()
.filter(p -> !controller.miniModel.orderLogicCard.players.contains(p))
.collect(Collectors.toList());
ordered.addAll(controller.miniModel.orderLogicCard.players);
for (Player player : ordered) {
ImageView totem = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Totems/totem_" + player.totem.toString().toLowerCase(Locale.ROOT) + ".png")));
for (OrderPlayer player : controller.miniModel.orderLogicCard.playerList) {
ImageView totem = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Totems/totem_" + player.player.totem.toString().toLowerCase(Locale.ROOT) + ".png")));
totem.setFitHeight(70);
totem.setPreserveRatio(true);
if (!controller.miniModel.orderLogicCard.players.contains(player)) {
if(controller.miniModel.slotPlayerMap.containsValue(player.player)) {
totem.setOpacity(0.5);
}
overlay.getChildren().add(totem);