Skip to content

Implement Sequential Levels and Graduation system - #174

Merged
candour merged 3 commits into
mainfrom
sequential-levels-8315806439057926885
May 31, 2026
Merged

Implement Sequential Levels and Graduation system#174
candour merged 3 commits into
mainfrom
sequential-levels-8315806439057926885

Conversation

@candour

@candour candour commented May 30, 2026

Copy link
Copy Markdown
Owner

I have implemented a sequential level system for Hawker Rush.

Key changes:

  1. Level Progression: Players now progress through 6 levels with increasing board sizes:
    • Level 1: 6x8
    • Level 2: 6x10
    • Level 3: 6x12
    • Level 4: 6x14
    • Level 5: 6x16
    • Level 6+: 8x16 (continues indefinitely at this size)
  2. Graduation Mechanic: Upon completing Wave 50 of any level, a "SHIOK! LEVEL CLEAR!" overlay appears. Clicking "HUAT AH!" graduates the player to the next level.
  3. State Reset: Graduation resets gold, health, Kitchelin Stars, score, and waves to starting values for the new level's fresh board.
  4. Persistence: The current level is saved and restored alongside other game state data.
  5. Game Over Logic: Losing a game resets the progression back to Level 1 (6x8).
  6. UI Enhancements: Added a dedicated graduation overlay in the game's signature style.

PR created automatically by Jules for task 8315806439057926885 started by @candour

Summary by CodeRabbit

  • New Features

    • Level progression with dynamic map sizing and scaling per level.
    • Graduation overlay that appears after completing a level, showing current level and a confirmation button.
    • Persisted level and overlay state so progression is saved between sessions.
  • Behavior Changes

    • Advancing to the next level resets transient gameplay state (waves, enemies, upgrades, score, effects) and hides the overlay.

Review Change Stack

- Added `currentLevel` and `showGraduationOverlay` to `GameState`.
- Defined level configurations for board dimensions (6x8, 6x10, 6x12, 6x14, 6x16, 8x16).
- Implemented level graduation logic in `MainViewModel` triggered after completing Wave 50.
- Added `GraduationOverlay` to `MainActivity` with Singlish flavor text ("Shiok!", "Steady pom pi pi", "Huat ah!").
- Updated `GameStateRepository` to persist the current level.
- Ensured progress (gold, health, stars, wave, score) resets upon graduation or game over.

Co-authored-by: candour <4670475+candour@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f219e9e0-c827-4206-91b9-e893d28a38ee

📥 Commits

Reviewing files that changed from the base of the PR and between 45528b6 and 4a3349d.

📒 Files selected for processing (2)
  • app/src/main/java/com/messark/hawker/MainViewModel.kt
  • app/src/main/java/com/messark/hawker/utils/GameStateRepository.kt
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/src/main/java/com/messark/hawker/utils/GameStateRepository.kt
  • app/src/main/java/com/messark/hawker/MainViewModel.kt

📝 Walkthrough

Walkthrough

The PR adds a level progression system: GameState now tracks currentLevel and showGraduationOverlay. At wave 50 the UI shows a GraduationOverlay; confirming it calls ViewModel.graduateToNextLevel(), which increments level, regenerates the map to per-level dimensions, resets transient state and score, and persists the new state.

Changes

Level Progression with Graduation Overlay

Layer / File(s) Summary
GameState model and persistence
app/src/main/java/com/messark/hawker/model/GameModels.kt, app/src/main/java/com/messark/hawker/utils/GameStateRepository.kt
GameState gains currentLevel: Int = 1 and showGraduationOverlay: Boolean = false; PersistentGameState persisted fields added; saveGameState and loadGameState map these fields.
Per-level dimension configuration
app/src/main/java/com/messark/hawker/MainViewModel.kt
levelConfigs list and getLevelDimensions(level) helper map level numbers to board (width,height) tuples.
Game initialization with level support
app/src/main/java/com/messark/hawker/MainViewModel.kt
initializeGame() and resetGame() use getLevelDimensions(1) instead of hardcoded dimensions; initial state explicitly sets currentLevel = 1.
Graduation overlay state transition
app/src/main/java/com/messark/hawker/MainViewModel.kt
Wave completion detects currentWave == 50, sets isGraduating, and commits showGraduationOverlay = true in the post-wave state update.
Level advancement implementation
app/src/main/java/com/messark/hawker/MainViewModel.kt
graduateToNextLevel() increments currentLevel, regenerates the map via getLevelDimensions(nextLevel), resets waves/enemies/projectiles/puddles/visual effects and selection/tutorial modes, hides the overlay, and resets score and related counters before persisting.
Graduation overlay UI and wiring
app/src/main/java/com/messark/hawker/MainActivity.kt
GraduationOverlay composable renders a full-screen green-bordered modal with level display and confirmation button that triggers haptics then calls graduateToNextLevel(); GameScreen shows it when showGraduationOverlay is true.

Sequence Diagram

sequenceDiagram
  participant GameScreen
  participant GraduationOverlay
  participant MainViewModel
  participant GameStateRepository

  GameScreen->>GraduationOverlay: render when showGraduationOverlay == true (level)
  GraduationOverlay->>MainViewModel: onTriggerHaptic() then onGraduate()
  MainViewModel->>MainViewModel: graduateToNextLevel() (increment currentLevel, regen map, reset transient state, hide overlay)
  MainViewModel->>GameStateRepository: saveGameState(updated GameState)
  GameStateRepository-->>MainViewModel: persist confirmation
  MainViewModel-->>GameScreen: new GameState emitted (updated map, score=0, showGraduationOverlay=false)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • candour/towerpower#100: Modifies MainViewModel wave-completion logic at the same checkpoint (wave-end transitions and overlays).
  • candour/towerpower#98: Related to kitchelinStars handling and interactions with level reset/persistence logic.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Implement Sequential Levels and Graduation system' directly matches the main objective of the PR: introducing a progressive level system with wave-based graduation mechanics.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sequential-levels-8315806439057926885

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.

@github-actions

Copy link
Copy Markdown

Build Successful! 🚀

Download APK

Note: This link will be removed when the PR is closed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
app/src/main/java/com/messark/hawker/MainViewModel.kt (1)

1020-1040: ⚡ Quick win

Simplify the chained .copy() calls.

The code sets score = state.score at line 1036, then immediately chains another .copy(score = 0) at line 1040, which overwrites the first assignment. This is inefficient and confusing.

♻️ Simplify to a single copy
             state.copy(
                 currentLevel = nextLevel,
                 currentWave = 0,
                 gold = 500,
                 health = 10,
                 kitchelinStars = 0,
                 hexes = hexes,
                 startPosition = startPos,
                 endPosition = endPos,
                 enemies = emptyList(),
                 projectiles = emptyList(),
                 puddles = emptyList(),
                 visualEffects = emptyList(),
                 showGraduationOverlay = false,
                 waveActive = false,
                 goldEarnedThisWave = 0,
-                score = state.score // Keep total score? Or reset? User said "Fresh everything", usually includes score?
-                // But usually in levels you want to see your total score.
-                // "Reset too" for difficulty scaling.
-                // Let's reset score too if it's "Fresh everything".
-            ).copy(score = 0)
+                score = 0
+            )

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2907965d-646c-4d0f-9b9c-bbcf621155f5

📥 Commits

Reviewing files that changed from the base of the PR and between 5fd06fa and 45528b6.

📒 Files selected for processing (4)
  • app/src/main/java/com/messark/hawker/MainActivity.kt
  • app/src/main/java/com/messark/hawker/MainViewModel.kt
  • app/src/main/java/com/messark/hawker/model/GameModels.kt
  • app/src/main/java/com/messark/hawker/utils/GameStateRepository.kt

Comment thread app/src/main/java/com/messark/hawker/MainActivity.kt
Comment thread app/src/main/java/com/messark/hawker/MainActivity.kt
Comment thread app/src/main/java/com/messark/hawker/MainViewModel.kt
- Added `currentLevel` and `showGraduationOverlay` to `GameState` and persistence.
- Defined level configurations for board dimensions (6x8, 6x10, 6x12, 6x14, 6x16, 8x16).
- Implemented level graduation logic in `MainViewModel` triggered after completing Wave 50.
- Added `GraduationOverlay` to `MainActivity` with Singlish flavor text.
- Refined `graduateToNextLevel` and `resetGame` for comprehensive state resets.
- Ensured level graduation state and dimensions are correctly saved and restored.

Co-authored-by: candour <4670475+candour@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Build Successful! 🚀

Download APK

Note: This link will be removed when the PR is closed.

@candour

candour commented May 31, 2026

Copy link
Copy Markdown
Owner Author

The code sets score = state.score at line 1036, then immediately chains another .copy(score = 0) at line 1040, which overwrites the first assignment. This is inefficient and confusing.

…gement

- Added `currentLevel` and `showGraduationOverlay` to `GameState` and persistence.
- Defined level configurations for board dimensions (6x8, 6x10, 6x12, 6x14, 6x16, 8x16).
- Implemented level graduation logic in `MainViewModel` triggered after completing Wave 50.
- Added `GraduationOverlay` to `MainActivity` with Singlish flavor text.
- Refined `graduateToNextLevel` to perform a comprehensive reset of all session and transient state (gold, health, stars, wave, score, stalls, UI overlays, etc.) and save the state immediately.
- Updated `resetGame` to ensure a full revert to starting values (Health 10, Wave 0, Level 1).
- Ensured level graduation state and dimensions are correctly saved and restored across app restarts.

Co-authored-by: candour <4670475+candour@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Build Successful! 🚀

Download APK

Note: This link will be removed when the PR is closed.

@candour
candour merged commit 2519e7d into main May 31, 2026
3 checks passed
@candour
candour deleted the sequential-levels-8315806439057926885 branch May 31, 2026 15:49
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