fix(boosters): address final-review findings
- daily claim: record the claim before granting boosters, so a crash mid-claim forfeits at most one reward instead of allowing a re-claim (booster farming) on next launch. - game screen: disarm the booster target synchronously before awaiting, so a rapid second board tap can't double-fire a use or stack a dialog. - new players: seed one of each booster once (idempotent persisted flag), fulfilling the spec's starting inventory. Wired in main(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -34,4 +34,21 @@ void main() {
|
||||
expect(repo.boosterCount(BoosterType.shuffle), 0);
|
||||
expect(await repo.consumeBooster(BoosterType.shuffle), isFalse);
|
||||
});
|
||||
|
||||
test('seedInitialBoosters grants 1 of each once, then is idempotent',
|
||||
() async {
|
||||
final repo = await fresh();
|
||||
await repo.seedInitialBoostersIfNeeded();
|
||||
for (final t in BoosterType.values) {
|
||||
expect(repo.boosterCount(t), 1, reason: t.name);
|
||||
}
|
||||
|
||||
// A second call (and a reload) must not grant again — the flag persists.
|
||||
await repo.seedInitialBoostersIfNeeded();
|
||||
final reloaded = SaveRepository(await SharedPreferences.getInstance());
|
||||
await reloaded.seedInitialBoostersIfNeeded();
|
||||
for (final t in BoosterType.values) {
|
||||
expect(reloaded.boosterCount(t), 1, reason: '${t.name} after reload');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user