Add: Minimodel FindPosByUsername-> for GUI

This commit is contained in:
rubenpirreram
2026-05-12 23:39:04 +02:00
parent 779b72275c
commit 9343c07004
2 changed files with 15 additions and 2 deletions
@@ -45,4 +45,17 @@ public class MiniModel implements Serializable {
{
players.put(player.getUserName(),player);
}
public int getPositionByUsername(String username)
{
int i=0;
for (Player player : players.values())
{
if(player.getUserName().equals(username))
{
return i;
}
i++;
}
return -1;
}
}
@@ -117,8 +117,8 @@ public class MainFXMLController {
StackPane wrapper = new StackPane(img);
Player player = model.slotPlayerMap.get(slot);
if (player != null) {
int index = new ArrayList<>(model.players.values()).indexOf(player);
if (player != null && model.getPositionByUsername(player.getUserName())!=-1) {
int index = model.getPositionByUsername(player.getUserName());
ImageView totem = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Totems/totem_" + index + ".png")));
totem.setFitHeight(70);
totem.setPreserveRatio(true);