From 40470b1788c28f1c95bba7339dd9819b0e9b95cc Mon Sep 17 00:00:00 2001 From: Michael Lizzio Date: Sun, 5 Oct 2025 05:29:38 -0400 Subject: Updated logic and completed holeplay subsystem --- src/main/java/design/model/Round.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/main/java/design/model/Round.java') 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 plays; + private int currentHoleIndex; @JsonCreator private Round(Course course, LocalDateTime dateTime, Hole startingHole, List 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(); + } } -- cgit v1.2.3