mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 02:44:50 +00:00
fix: issues
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
package org.toop.app.layer.layers;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import org.toop.app.App;
|
||||
import org.toop.app.GameType;
|
||||
import org.toop.app.Match;
|
||||
import org.toop.app.canvas.TicTacToeCanvas;
|
||||
import org.toop.app.layer.Container;
|
||||
import org.toop.app.layer.Layer;
|
||||
import org.toop.app.layer.containers.VerticalContainer;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class GameLayer extends Layer {
|
||||
Match match;
|
||||
public GameLayer() {
|
||||
super("game.css");
|
||||
//temp
|
||||
match = new Match("name"+LocalDateTime.now().getSecond(),false,"127.0.0.1",7789, GameType.TICTACTOE);
|
||||
reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
App.popAll();
|
||||
|
||||
final Container controlContainer = new VerticalContainer(5);
|
||||
controlContainer.addButton("Back", () -> { App.activate(new MainLayer()); });
|
||||
|
||||
addCanvas(new TicTacToeCanvas(), Pos.CENTER, 0, 0, 100, 100);
|
||||
addContainer(controlContainer, Pos.BOTTOM_LEFT, 2, -2, 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.toop.app.layer.layers.game;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.paint.Color;
|
||||
import org.toop.app.App;
|
||||
import org.toop.app.GameInformation;
|
||||
import org.toop.app.canvas.TicTacToeCanvas;
|
||||
@@ -14,6 +12,9 @@ import org.toop.game.tictactoe.TicTacToe;
|
||||
import org.toop.game.tictactoe.TicTacToeAI;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
@@ -113,7 +114,14 @@ public final class TicTacToeLayer extends Layer {
|
||||
|
||||
if (information.isPlayerHuman()[currentPlayer]) {
|
||||
try {
|
||||
move = playerMoveQueue.take();
|
||||
final Game.Move wants = playerMoveQueue.take();
|
||||
final Game.Move[] legalMoves = ticTacToe.getLegalMoves();
|
||||
|
||||
for (final Game.Move legalMove : legalMoves) {
|
||||
if (legalMove.position() == wants.position() && legalMove.value() == wants.value()) {
|
||||
move = wants;
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException exception) {
|
||||
return;
|
||||
}
|
||||
@@ -121,7 +129,10 @@ public final class TicTacToeLayer extends Layer {
|
||||
move = ticTacToeAI.findBestMove(ticTacToe, compurterDifficultyToDepth(5, information.computerDifficulty()[currentPlayer]));
|
||||
}
|
||||
|
||||
assert move != null;
|
||||
if (move == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final Game.State state = ticTacToe.play(move);
|
||||
|
||||
if (move.value() == 'X') {
|
||||
|
||||
Reference in New Issue
Block a user