summaryrefslogtreecommitdiff
path: root/src/main/java/design/model/Round.java
diff options
context:
space:
mode:
authorMichael Lizzio <142752852+Michael-Lizzio@users.noreply.github.com>2025-10-05 05:30:55 -0400
committerGitHub <noreply@github.com>2025-10-05 05:30:55 -0400
commitc5cbe4ffd56b7c96d85dc1676387993c6c15af7b (patch)
tree2ba839f3fc8fea03612e7f7051176b8d0a059a48 /src/main/java/design/model/Round.java
parent42fcc633ddc0e328561f984a6aa0b8593765dcf2 (diff)
parent40470b1788c28f1c95bba7339dd9819b0e9b95cc (diff)
downloaddesignproject-design-6-c5cbe4ffd56b7c96d85dc1676387993c6c15af7b.tar.gz
designproject-design-6-c5cbe4ffd56b7c96d85dc1676387993c6c15af7b.tar.bz2
designproject-design-6-c5cbe4ffd56b7c96d85dc1676387993c6c15af7b.zip
Merge pull request #2 from RIT-SWEN-262/lizzio-holePlaySubsystem
Lizzio hole play subsystem
Diffstat (limited to 'src/main/java/design/model/Round.java')
-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();
+ }
}