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