Modern Apps git

← Modern-Apps.git

games-wordmaker: hint available immediately instead of after a phantom cooldown

Commit
76405345f2811688a2b2ecfe21966e79adfcb111
Author
Vayun Mathur <[email protected]>
When
2026-11-08 02:45 UTC (28 days ago)
Parents
920e7d2
_hintCooldownEnd was initialized to now + 30s, so every cold start
showed the hint button disabled with a draining progress ring even
though the player had never used a hint. The UiState contract already
uses 0 for 'available now' (WordMakerUiContract defaults
hintCooldownEnd to 0L, and the wheel enables the button when the
remaining cooldown is <= 0); only an actual revealHint call should arm
the 30s cooldown. Initialize the flow to 0L. Verified with
:games:wordmaker:testDevUnitTest, including a new regression test
asserting a fresh ViewModel reports hintCooldownEnd == 0.

Diff

games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/platform/WordMakerViewModel.kt
diff --git a/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/platform/WordMakerViewModel.kt b/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/platform/WordMakerViewModel.ktindex acb80c0d13..006d536c12 100644--- a/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/platform/WordMakerViewModel.kt+++ b/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/platform/WordMakerViewModel.kt@@ -66,7 +66,7 @@ class WordMakerViewModel(application: Application) : AndroidViewModel(applicatio     val reminderMinutesOfDay: StateFlow<Long> = reminderSettings.minutesOfDay         .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), DailyPuzzleReminder.DEFAULT_MINUTES_OF_DAY) -    private val _hintCooldownEnd = MutableStateFlow(System.currentTimeMillis() + HINT_COOLDOWN_MILLIS)+    private val _hintCooldownEnd = MutableStateFlow(0L)     val hintCooldownEnd: StateFlow<Long> = _hintCooldownEnd.asStateFlow()      // ---- Competitive mode state ----
games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/platform/WordMakerViewModelTest.kt
diff --git a/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/platform/WordMakerViewModelTest.kt b/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/platform/WordMakerViewModelTest.ktindex 8282d4bdf4..3f55adaf0d 100644--- a/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/platform/WordMakerViewModelTest.kt+++ b/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/platform/WordMakerViewModelTest.kt@@ -181,6 +181,12 @@ class WordMakerViewModelTest {         pollUntil { vm.gameMode.value == GameMode.CASUAL }         assertFalse(vm.bonusWords.value.contains("ZQXCOMPWORD"))     }+    @Test fun hintAvailableImmediatelyOnLaunch() {+        // No hint has been used yet, so there is no cooldown to serve: the+        // UiState contract uses 0 for "available now" and the wheel enables+        // the hint button when the remaining cooldown is <= 0.+        assertEquals(0L, vm().hintCooldownEnd.value)+    }     @Test fun revealHintRevealsACellAndStartsCooldown() {         val vm = vm()         pollUntil { vm.crosswordData.value != null }