From 8de7f2ac5080c2bdc2e049e3ec62aba3c744c561 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 3 Nov 2021 23:21:19 +0100 Subject: [PATCH] Remove modelfactory from UltimateTicTacToePanelViewModel --- .../viewmodel/UltimateTicTacToePanelViewModel.java | 5 ++--- .../ultimatetictactoe/viewmodel/ViewModelFactory.java | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/icaotix/ultimatetictactoe/viewmodel/UltimateTicTacToePanelViewModel.java b/src/main/java/de/icaotix/ultimatetictactoe/viewmodel/UltimateTicTacToePanelViewModel.java index a45ce78..e754fa8 100644 --- a/src/main/java/de/icaotix/ultimatetictactoe/viewmodel/UltimateTicTacToePanelViewModel.java +++ b/src/main/java/de/icaotix/ultimatetictactoe/viewmodel/UltimateTicTacToePanelViewModel.java @@ -2,7 +2,6 @@ package de.icaotix.ultimatetictactoe.viewmodel; import de.icaotix.ultimatetictactoe.model.IUltimateTicTacToe; -import de.icaotix.ultimatetictactoe.model.ModelFactory; import de.icaotix.ultimatetictactoe.model.definitions.GameState; import java.util.function.Consumer; @@ -14,12 +13,12 @@ public class UltimateTicTacToePanelViewModel { private Consumer gameResultCallback; private Consumer currentPlayerCallback; - public UltimateTicTacToePanelViewModel(ModelFactory modelFactory, ViewModelFactory viewModelFactory) { + public UltimateTicTacToePanelViewModel(IUltimateTicTacToe ultimateTicTacToe, ViewModelFactory viewModelFactory) { this.subGameViewModels = new TicTacToePanelViewModel[9]; for (int i = 0; i < this.subGameViewModels.length; i++) { this.subGameViewModels[i] = viewModelFactory.getTicTacToePanelViewModel(this); } - this.ultimateTicTacToe = modelFactory.getUltimateTicTacToe(); + this.ultimateTicTacToe = ultimateTicTacToe; } public void prepareNextMove() { diff --git a/src/main/java/de/icaotix/ultimatetictactoe/viewmodel/ViewModelFactory.java b/src/main/java/de/icaotix/ultimatetictactoe/viewmodel/ViewModelFactory.java index b8f3f72..280a355 100644 --- a/src/main/java/de/icaotix/ultimatetictactoe/viewmodel/ViewModelFactory.java +++ b/src/main/java/de/icaotix/ultimatetictactoe/viewmodel/ViewModelFactory.java @@ -11,7 +11,8 @@ public class ViewModelFactory { } public UltimateTicTacToePanelViewModel getUltimateTicTacToePanelViewModel() { - return new UltimateTicTacToePanelViewModel(this.modelFactory, this); + var ultimateTicTacToeGame = this.modelFactory.getUltimateTicTacToe(); + return new UltimateTicTacToePanelViewModel(ultimateTicTacToeGame, this); } public TicTacToePanelViewModel getTicTacToePanelViewModel(UltimateTicTacToePanelViewModel ultimateTicTacToePanelViewModel) {