refactor dddview
All checks were successful
Linux arm64 / Build (push) Successful in 46s

This commit is contained in:
2025-05-18 11:45:23 +02:00
parent 1b31643f0b
commit fd9aabb6a1

View File

@@ -7,6 +7,8 @@ import java.util.function.Consumer;
import chess.controller.commands.*;
import imgui.ImGui;
import imgui.ImVec2;
import imgui.flag.ImGuiCond;
import imgui.flag.ImGuiWindowFlags;
import org.joml.Vector2f;
import org.joml.Vector3f;
@@ -147,7 +149,7 @@ public class DDDView extends GameAdapter implements CommandSender {
private void onCellExit(Coordinate coordinate) {
if (this.click == null) {
this.boardEntity.resetCellColor(coordinate);
Piece p = pieceAt(coordinate);
Piece p = getPieceAt(coordinate);
if (p == null)
return;
@@ -167,7 +169,7 @@ public class DDDView extends GameAdapter implements CommandSender {
private void cancelPreview(Coordinate coordinate) {
this.boardEntity.resetCellColor(coordinate);
Piece p = pieceAt(coordinate);
Piece p = getPieceAt(coordinate);
if (p == null)
return;
this.world.getPiece(coordinate).setColor(p.getColor() == Color.White ? WHITE : BLACK);
@@ -179,12 +181,6 @@ public class DDDView extends GameAdapter implements CommandSender {
}
}
private Piece pieceAt(Coordinate pos) {
GetPieceAtCommand cmd = new GetPieceAtCommand(pos);
this.commandExecutor.executeCommand(cmd);
return cmd.getPiece();
}
@Override
public void onGameStart() {
this.window.scheduleTask(() -> {
@@ -250,7 +246,7 @@ public class DDDView extends GameAdapter implements CommandSender {
for (int i = 0; i < Coordinate.VALUE_MAX; i++) {
for (int j = 0; j < Coordinate.VALUE_MAX; j++) {
Coordinate pos = new Coordinate(i, j);
Piece piece = pieceAt(pos);
Piece piece = getPieceAt(pos);
if (piece == null)
continue;
@@ -436,6 +432,11 @@ public class DDDView extends GameAdapter implements CommandSender {
this.window.stop();
}
@Override
public void onWin(Color color) {
openPopup(color == Color.White ? "Black victory" : "White victory");
}
@Override
public void onPatSituation() {
openPopup("Pat");
@@ -444,7 +445,6 @@ public class DDDView extends GameAdapter implements CommandSender {
@Override
public void onSurrender(Color color) {
openPopup(color == Color.White ? "White surrender" : "Black surrender");
openPopup(color == Color.White ? "Black victory" : "White victory");
}
@Override