Skip to content

Commit

Permalink
remove checkmate check bug, remove typos
Browse files Browse the repository at this point in the history
  • Loading branch information
MZober1993 authored and MZober1993 committed Nov 6, 2016
1 parent d4b3ee6 commit 3b89143
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/main/java/chess/tools/move/Direction.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ public class Direction {
public static final List<Direction> TOWER = Stream.of(new Direction(1, 0), new Direction(-1, 0),
new Direction(0, 1), new Direction(0, -1))
.collect(Collectors.toList());
public static final List<Direction> BISCHOP = Stream.of(new Direction(1, 1), new Direction(-1, 1)
public static final List<Direction> BISHOP = Stream.of(new Direction(1, 1), new Direction(-1, 1)
, new Direction(-1, -1), new Direction(1, -1))
.collect(Collectors.toList());
public static final List<Direction> QUEEN = Stream.of(TOWER, BISCHOP).flatMap(Collection::stream)
public static final List<Direction> QUEEN = Stream.of(TOWER, BISHOP).flatMap(Collection::stream)
.collect(Collectors.toList());
public static final List<Direction> SPRINGER = Stream.of(new Direction(1, 2), new Direction(2, 1), new Direction(1, -2), new Direction(2, -1),
new Direction(-1, 2), new Direction(-2, 1), new Direction(-1, -2), new Direction(-2, -1))
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/chess/tools/move/strategy/DefaultMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public List<Position> possibleFields(Figure current, Figure[][] board) {
int endOffset = repeating ? 8 : 2;
for (Direction dir : directions) {
for (int i = 1; i < endOffset; i++) {
if (begin.getC() + i * dir.getC() < 0 || begin.getR() + i * dir.getR() < 0) {
continue;
}
final Position newPos = new Position(begin.getC() + i * dir.getC(), begin.getR() + i * dir.getR());
if (newPos.isValid() && !possibleFields.contains(newPos)) {
final Figure newFigure = Figure.figureForPos(board, newPos);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/chess/tools/move/strategy/MoveStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public enum MoveStrategy {
S(new DefaultMode(false, Direction.SPRINGER)),
D(new DefaultMode(true, Direction.QUEEN)),
T(new DefaultMode(true, Direction.TOWER)),
L(new DefaultMode(true, Direction.BISCHOP)),
L(new DefaultMode(true, Direction.BISHOP)),
EMPTY(new DefaultMode(true, Collections.emptyList()));

private VerifyMode verifyMode;
Expand Down
10 changes: 2 additions & 8 deletions src/test/java/chess/tools/game/ChessTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ public void turnSucceeds() {
}

@Test
public void notValidBug() {
public void noCheckMateBug() {
Chess chess = new Chess(Arrays.asList("e2 e3", "c7 c6", "f1 c4"));
Assert.assertEquals(Arrays.asList(true, true, false), chess.getTurnValids());
//TODO: should be: Assert.assertEquals(Arrays.asList(true, true, true), chess.getTurnValids());
Assert.assertEquals(Arrays.asList(true, true, true), chess.getTurnValids());
}

@Test
Expand All @@ -78,9 +77,4 @@ public void chessMateSucceeds() {
, chess.getEatTuples());
Assert.assertTrue(chess.isCheckMate());
}

@Test
public void stalementSucceeds() {
//TODO: add test
}
}

0 comments on commit 3b89143

Please sign in to comment.