Skip to content

Feature/start turn1 gui#29

Merged
MartinStenhagen merged 2 commits into
mainfrom
feature/startTurn1Gui
Jan 14, 2026
Merged

Feature/start turn1 gui#29
MartinStenhagen merged 2 commits into
mainfrom
feature/startTurn1Gui

Conversation

@MartinStenhagen

@MartinStenhagen MartinStenhagen commented Jan 14, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

Release Notes

  • Performance
    • Optimized turn tracking and HUD display refresh system to improve responsiveness and reduce latency during active gameplay

✏️ Tip: You can customize this high-level summary in your review settings.

…orPlayers i JourneyService för att det ska fungera bra med flera spelare. Ny metod refreshTurnCache() i Controller som använder detta. Den metoden läggs till i syncHudandMap(). Uppdaterad updateHud() med int lastTurn = lastTurnByTravelerId.getOrDefault(current.getId(), 0);

  currentTurnLabel.setText(String.valueOf(lastTurn + 1));
@MartinStenhagen
MartinStenhagen merged commit 9d98842 into main Jan 14, 2026
1 of 2 checks passed
@coderabbitai

coderabbitai Bot commented Jan 14, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR introduces per-traveler turn caching in TravelGameController by adding a map to store last turn numbers. A new refreshTurnCache method syncs data from JourneyService before HUD rendering, and a corresponding service method fetches max turn numbers for multiple travelers in a single query.

Changes

Cohort / File(s) Summary
Turn Caching Infrastructure
src/main/java/org/example/TravelGameController.java, src/main/java/org/example/service/JourneyService.java
Added lastTurnByTravelerId cache field and refreshTurnCache() method in controller; integrated cache refresh into syncHudAndMap() workflow. New service method getLastTurnNumbersForPlayers() batch-fetches max turn numbers per traveler, returning empty map for null/empty input and defaulting missing travelers to turn 0. HUD label now derives current turn value from cache.

Sequence Diagram

sequenceDiagram
    participant UI as UI/Event
    participant Controller as TravelGameController
    participant Cache as lastTurnByTravelerId
    participant Service as JourneyService
    participant DB as Database

    UI->>Controller: syncHudAndMap()
    Controller->>Controller: refreshTurnCache()
    Controller->>Service: getLastTurnNumbersForPlayers(travelerIds)
    Service->>DB: Query MAX(turnNumber) per traveler
    DB-->>Service: Turn data
    Service-->>Controller: Map<Long, Integer>
    Controller->>Cache: Store results
    Controller->>UI: Update currentTurnLabel from cache
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A cache springs forth with hoppy delight,
Per traveler turns now stored just right,
The HUD syncs smooth, no queries in sight,
Batch-fetching turns keeps the game light,
From database hops to UI so bright! 🎮

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9cea17c and 73bd4ec.

📒 Files selected for processing (2)
  • src/main/java/org/example/TravelGameController.java
  • src/main/java/org/example/service/JourneyService.java

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@MartinStenhagen
MartinStenhagen deleted the feature/startTurn1Gui branch January 14, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant