refactor misc
This commit is contained in:
@@ -31,7 +31,7 @@ public class DumbAI extends AI {
|
||||
int randomMove = this.random.nextInt(moves.size() + 2);
|
||||
if (randomMove < moves.size() - 2)
|
||||
break;
|
||||
this.commandExecutor.executeCommand(new CastlingCommand(randomMove == moves.size()));
|
||||
sendCommand(new CastlingCommand(randomMove == moves.size()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class DumbAI extends AI {
|
||||
int randomMove = this.random.nextInt(moves.size() + 1);
|
||||
if (randomMove != moves.size())
|
||||
break;
|
||||
this.commandExecutor.executeCommand(new CastlingCommand(castlings == CastlingResult.Big));
|
||||
sendCommand(new CastlingCommand(castlings == CastlingResult.Big));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ public class DumbAI extends AI {
|
||||
}
|
||||
|
||||
int randomMove = this.random.nextInt(moves.size());
|
||||
this.commandExecutor.executeCommand(new MoveCommand(moves.get(randomMove)));
|
||||
sendCommand(new MoveCommand(moves.get(randomMove)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void promote(Coordinate pawnCoords) {
|
||||
int promote = this.random.nextInt(PromoteType.values().length);
|
||||
this.commandExecutor.executeCommand(new PromoteCommand(PromoteType.values()[promote]));
|
||||
sendCommand(new PromoteCommand(PromoteType.values()[promote]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class PromoteCommand extends PlayerCommand {
|
||||
|
||||
public PromoteCommand(PromoteType promoteType) {
|
||||
this.promoteType = promoteType;
|
||||
assert this.promoteType != null;
|
||||
this.pieceCoords = null;
|
||||
this.oldPawn = null;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import chess.model.Color;
|
||||
import chess.model.Game;
|
||||
|
||||
class AppTest {
|
||||
@Test void functionalRollback(){
|
||||
private void functionalRollback(){
|
||||
Game game = new Game();
|
||||
CommandExecutor commandExecutor = new CommandExecutor(game);
|
||||
|
||||
@@ -37,6 +37,9 @@ class AppTest {
|
||||
Game initialGame = new Game();
|
||||
CommandExecutor initialCommandExecutor = new CommandExecutor(initialGame);
|
||||
initialCommandExecutor.executeCommand(new NewGameCommand());
|
||||
|
||||
initialCommandExecutor.close();
|
||||
commandExecutor.close();
|
||||
|
||||
assert(game.getBoard().equals(initialGame.getBoard()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user