Skip to content

Commit

Permalink
Merge branch 'bugfix/#52-javadoc-coverage' into feature/#51-make-geom…
Browse files Browse the repository at this point in the history
…etryitems-clickable
  • Loading branch information
DorianRec committed Dec 20, 2019
2 parents 44735fd + e0c4aba commit 16a0a4d
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/main/java/com/treasure/hunt/game/GameEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@
*/
@Requires(hider = Hider.class, searcher = Searcher.class)
public class GameEngine {
/**
* The height of the playing area.
*/
public static final int HEIGHT = 200;
/**
* The width of the playing area.
*/
public static final int WIDTH = 200;

protected final Searcher searcher;
Expand All @@ -47,6 +53,8 @@ public class GameEngine {
protected boolean firstMove = true;

/**
* The constructor.
*
* @param searcher playing the game
* @param hider playing the game
*/
Expand Down Expand Up @@ -88,12 +96,16 @@ protected static boolean located(List<GeometryItem<Point>> geometryItemsList, Po
return false;
}

/**
* Initialize searcher on initial position {@code (0,0)} and treasure positions.
*
* @return a {@link Move}, since the initialization must be displayed.
*/
public Move init() {
return init(JTSUtils.createPoint(0, 0));
}

/**
* initialize searcher and hider.
* initialize searcher and treasure positions.
*
* @param p initial searcher position
Expand Down Expand Up @@ -124,8 +136,6 @@ public Move init(Point p) {
* The searcher begins since we want not force him,
* to take a initial hint, he eventually do not need,
* f.e. if he works randomized!
* <p>
* Updates the searchers position.
*
* @return the {@link Move}, happened in this step.
*/
Expand All @@ -143,7 +153,7 @@ public Move move() {
}

/**
* Lets the {@link GameEngine#hider} make its move.
* Let the {@link GameEngine#hider} give its {@link Hint}.
*/
protected void hiderMove() {
lastHint = hider.move(lastMovement);
Expand All @@ -152,7 +162,7 @@ protected void hiderMove() {
}

/**
* Lets the {@link GameEngine#searcher} make its move.
* Let the {@link GameEngine#searcher} make {@link Movement}.
*/
protected void searcherMove() {
if (finished.get()) {
Expand All @@ -174,6 +184,8 @@ protected void searcherMove() {
}

/**
* Verifies whether the performed {@link Movement} {@code movement} by the {@link Searcher} followed the rules.
*
* @param movement which gets verified
* @param initialSearcherPosition initial searcher position
* @throws IllegalArgumentException when the {@link Movement} is not valid.
Expand Down Expand Up @@ -201,9 +213,9 @@ protected void verifyMovement(Movement movement, Point initialSearcherPosition)
* AngleHints must be correct
* AngleHints must be of angle [0, 180] !?
* CircleHints must contain each other !?
* Verifies whether the performed {@link Movement}' by the searcher and {@link Hint}'s from the hider followed the rules.
* Verifies whether the {@link Hint} {@code hint} given by the {@link Hider} followed the rules.
*
* @param hint hint to be verified
* @param hint {@link Hint} to be verified
* @param treasurePosition treasure position
*/
protected void verifyHint(Hint hint, Point treasurePosition) {
Expand All @@ -222,12 +234,15 @@ protected void verifyHint(Hint hint, Point treasurePosition) {
}

/**
* Sets {@link GameEngine#finished} to true.
* Setter for {@link GameEngine#finished}.
*/
protected void finish() {
finished.set(true);
}

/**
* @return {@code true}, if {@link GameEngine#finished} is true. {@code false}, otherwise.
*/
protected boolean isFinished() {
return finished.get();
}
Expand Down

0 comments on commit 16a0a4d

Please sign in to comment.