diff --git a/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java b/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java index 9190895..ade8efb 100644 --- a/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java +++ b/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java @@ -118,9 +118,9 @@ public class Matchfield { return false; if (direction == 0) { - next = new Coordinate(next.getX() + i, next.getY()); + next = new Coordinate(next.getX() + 1, next.getY()); } else if (direction == 1) { - next = new Coordinate(next.getX(), next.getY() + i); + next = new Coordinate(next.getX(), next.getY() + 1); } } diff --git a/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldShipTest.java b/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldShipTest.java index 72a94c8..b3f1205 100644 --- a/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldShipTest.java +++ b/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldShipTest.java @@ -148,6 +148,8 @@ class MatchfieldShipTest { Arguments.of("one ship is within the coordinates", new Coordinate(0, 0), 1, 2, new Coordinate[] { new Coordinate(0, 0) }, false), Arguments.of("no ship is within the coordinates", new Coordinate(1, 1), 0, 5, new Coordinate[] {}, - true)); + true), + Arguments.of("one of the coordinates is hit, others on free fields", new Coordinate(5, 5), 1, 3, + new Coordinate[] { new Coordinate(5, 7), new Coordinate(5, 8), new Coordinate(5, 9) }, false)); } }