summaryrefslogtreecommitdiff
path: root/src/main/java/design/model/Round.java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/design/model/Round.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main/java/design/model/Round.java b/src/main/java/design/model/Round.java
index 048a21a..bc4914e 100644
--- a/src/main/java/design/model/Round.java
+++ b/src/main/java/design/model/Round.java
@@ -11,6 +11,7 @@ public class Round {
private final LocalDateTime dateTime;
private final Hole startingHole;
private final List<Play> plays;
+ private int currentHoleIndex;
@JsonCreator
private Round(Course course, LocalDateTime dateTime, Hole startingHole, List<Play> plays) {
@@ -18,6 +19,9 @@ public class Round {
this.dateTime = dateTime;
this.startingHole = startingHole;
this.plays = plays;
+ // Allows the golfer to start anywhere on the course. Helps HolePalyContext be
+ // simpler.
+ this.currentHoleIndex = Math.max(0, startingHole.getNumber() - 1);
}
public Round(Course course, LocalDateTime dateTime, Hole startingHole) {
@@ -25,6 +29,9 @@ public class Round {
this.dateTime = dateTime;
this.startingHole = startingHole;
plays = new ArrayList<>();
+ // Allows the golfer to start anywhere on the course. Helps HolePalyContext be
+ // simpler.
+ this.currentHoleIndex = Math.max(0, startingHole.getNumber() - 1);
}
public int getTotalSwings() {
@@ -52,4 +59,14 @@ public class Round {
public void addPlay(Play play) {
plays.add(play);
}
+
+ // Current hole
+ public Hole getCurrentHole() {
+ return course.getHoles().get(currentHoleIndex);
+ }
+
+ // Handles wraparound too
+ public void nextHole() {
+ currentHoleIndex = (currentHoleIndex + 1) % course.getHoleCount();
+ }
}