From b3247323f7c0d891aae7b9e89e2cb80acf79e944 Mon Sep 17 00:00:00 2001 From: PawelSapula Date: Sun, 24 May 2026 12:08:05 +0200 Subject: [PATCH] fix(Start-MVC): Notification when player not found. --- .../idi/idatt/view/entry/StartController.java | 6 ++++++ .../edu/ntnu/idi/idatt/view/entry/StartModel.java | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/main/java/edu/ntnu/idi/idatt/view/entry/StartController.java b/src/main/java/edu/ntnu/idi/idatt/view/entry/StartController.java index 595a1c2..8fdb8d4 100644 --- a/src/main/java/edu/ntnu/idi/idatt/view/entry/StartController.java +++ b/src/main/java/edu/ntnu/idi/idatt/view/entry/StartController.java @@ -52,6 +52,12 @@ public void initializeGame() { model.isNewGame().set(true); } + if (model.isFirstNewGame()) { + model.getError().set("No player with this name found. Create new player."); + model.setFirstNewGame(false); + return; + } + if (model.getBalance().get() == null) { model.getError().set("Balance field can't be empty"); return; diff --git a/src/main/java/edu/ntnu/idi/idatt/view/entry/StartModel.java b/src/main/java/edu/ntnu/idi/idatt/view/entry/StartModel.java index 089262c..36710de 100644 --- a/src/main/java/edu/ntnu/idi/idatt/view/entry/StartModel.java +++ b/src/main/java/edu/ntnu/idi/idatt/view/entry/StartModel.java @@ -14,8 +14,15 @@ public class StartModel implements Model { private final StringProperty fileName = new SimpleStringProperty(); private final BooleanProperty newGame = new SimpleBooleanProperty(); + private boolean firstNewGame = false; private final BooleanProperty predefinedCSV = new SimpleBooleanProperty(true); + public StartModel() { + newGame.addListener((obs) -> { + firstNewGame = true; + }); + } + public StringProperty getName() { return name; } @@ -36,6 +43,14 @@ public BooleanProperty isNewGame() { return newGame; } + public boolean isFirstNewGame() { + return firstNewGame; + } + + public void setFirstNewGame(boolean val) { + firstNewGame = val; + } + public BooleanProperty isPredefinedCSV() { return predefinedCSV; }