Remove modelfactory from UltimateTicTacToePanelViewModel

This commit is contained in:
Marcel Schwarz 2021-11-03 23:21:19 +01:00
parent 016d6db839
commit 8de7f2ac50
2 changed files with 4 additions and 4 deletions

View File

@ -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<String> gameResultCallback;
private Consumer<String> 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() {

View File

@ -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) {