mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
Code cleanup
This commit is contained in:
@@ -22,6 +22,7 @@ import org.toop.framework.eventbus.EventFlow;
|
||||
import org.toop.framework.eventbus.GlobalEventBus;
|
||||
import org.toop.framework.game.BitboardGame;
|
||||
import org.toop.framework.game.games.reversi.BitboardReversi;
|
||||
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
||||
import org.toop.framework.networking.connection.NetworkingClientEventListener;
|
||||
import org.toop.framework.networking.connection.NetworkingClientManager;
|
||||
import org.toop.framework.networking.server.GameDefinition;
|
||||
@@ -141,9 +142,9 @@ public final class App extends Application {
|
||||
|
||||
stage.show();
|
||||
|
||||
var games = new ConcurrentHashMap<String, GameDefinition<BitboardGame<?>>>();
|
||||
games.put("tictactoe", new GameDefinition<>("tictactoe", BitboardReversi.class));
|
||||
games.put("reversi", new GameDefinition<>("reversi", BitboardReversi.class));
|
||||
var games = new ConcurrentHashMap<String, Class<? extends TurnBasedGame>>();
|
||||
games.put("tictactoe", BitboardReversi.class);
|
||||
games.put("reversi", BitboardReversi.class);
|
||||
var s = new MasterServer(6666, games);
|
||||
try {
|
||||
s.start();
|
||||
@@ -156,7 +157,7 @@ public final class App extends Application {
|
||||
private void setKeybinds(StackPane root) {
|
||||
root.addEventHandler(KeyEvent.KEY_PRESSED,event -> {
|
||||
if (event.getCode() == KeyCode.ESCAPE) {
|
||||
escapePopup();
|
||||
escapePopup();
|
||||
}
|
||||
});
|
||||
stage.setFullScreenExitKeyCombination(
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.toop.framework.gameFramework.view.GUIEvents;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public abstract class BitGameCanvas<T extends TurnBasedGame> implements GameCanvas {
|
||||
public abstract class BitGameCanvas implements GameCanvas {
|
||||
protected record Cell(float x, float y, float width, float height) {
|
||||
public boolean isInside(double x, double y) {
|
||||
return x >= this.x && x <= this.x + width &&
|
||||
|
||||
@@ -3,10 +3,6 @@ package org.toop.app.canvas;
|
||||
import javafx.scene.paint.Color;
|
||||
import org.toop.app.App;
|
||||
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
||||
import org.toop.game.games.reversi.BitboardReversi;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ReversiBitCanvas extends BitGameCanvas {
|
||||
public ReversiBitCanvas() {
|
||||
@@ -37,7 +33,7 @@ public class ReversiBitCanvas extends BitGameCanvas {
|
||||
public void redraw(TurnBasedGame gameCopy) {
|
||||
clearAll();
|
||||
long[] board = gameCopy.getBoard();
|
||||
loopOverBoard(board[0], (i) -> drawDot(Color.WHITE, (int)i));
|
||||
loopOverBoard(board[1], (i) -> drawDot(Color.BLACK, (int)i));
|
||||
loopOverBoard(board[0], (i) -> drawDot(Color.WHITE, i));
|
||||
loopOverBoard(board[1], (i) -> drawDot(Color.BLACK, i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,6 @@ package org.toop.app.canvas;
|
||||
import javafx.scene.paint.Color;
|
||||
import org.toop.app.App;
|
||||
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
||||
import org.toop.game.games.tictactoe.BitboardTicTacToe;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class TicTacToeBitCanvas extends BitGameCanvas{
|
||||
public TicTacToeBitCanvas() {
|
||||
@@ -29,8 +25,8 @@ public class TicTacToeBitCanvas extends BitGameCanvas{
|
||||
}
|
||||
|
||||
private void drawMoves(long[] gameBoard){
|
||||
loopOverBoard(gameBoard[0], (i) -> drawX(Color.RED, (int)i));
|
||||
loopOverBoard(gameBoard[1], (i) -> drawO(Color.BLUE, (Integer) i));
|
||||
loopOverBoard(gameBoard[0], (i) -> drawX(Color.RED, i));
|
||||
loopOverBoard(gameBoard[1], (i) -> drawO(Color.BLUE, i));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user