iaaaaaaaaaaaaaa
This commit is contained in:
@@ -7,6 +7,7 @@ import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
@@ -20,8 +21,9 @@ import chess.controller.Command.CommandResult;
|
||||
import chess.controller.CommandExecutor;
|
||||
import chess.controller.OutputSystem;
|
||||
import chess.controller.commands.CastlingCommand;
|
||||
import chess.controller.commands.GetAllowedMovesCommand;
|
||||
import chess.controller.commands.GetAllowedMovesPieceCommand;
|
||||
import chess.controller.commands.GetPieceAtCommand;
|
||||
import chess.controller.commands.GetPlayerMovesCommand;
|
||||
import chess.controller.commands.MoveCommand;
|
||||
import chess.controller.commands.PromoteCommand;
|
||||
import chess.controller.commands.PromoteCommand.PromoteType;
|
||||
@@ -139,7 +141,7 @@ public class Window extends JFrame implements OutputSystem {
|
||||
}
|
||||
|
||||
private boolean previewMoves(int x, int y) {
|
||||
GetAllowedMovesCommand movesCommand = new GetAllowedMovesCommand(new Coordinate(x, y));
|
||||
GetAllowedMovesPieceCommand movesCommand = new GetAllowedMovesPieceCommand(new Coordinate(x, y));
|
||||
if (sendCommand(movesCommand) == CommandResult.NotAllowed)
|
||||
return false;
|
||||
|
||||
@@ -196,6 +198,15 @@ public class Window extends JFrame implements OutputSystem {
|
||||
@Override
|
||||
public void playerTurn(chess.model.Color color) {
|
||||
this.displayText.setText("Current turn: " + color);
|
||||
|
||||
// dumb IA
|
||||
if (color == chess.model.Color.Black) {
|
||||
GetPlayerMovesCommand cmd = new GetPlayerMovesCommand();
|
||||
sendCommand(cmd);
|
||||
List<Move> moves = cmd.getMoves();
|
||||
int random = new Random().nextInt(moves.size());
|
||||
sendCommand(new MoveCommand(moves.get(random)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user