fix: hide spent rescue to prevent StateError crash; log per-attempt starts

Expose engine.rescueUsed getter and surface it through GameViewState so
the result overlay can omit the watch-ad FilledButton after a rescue has
been consumed, preventing a second tap from calling useContinue /
addExtraMoves and hitting their StateError guard. Give-up is promoted to
FilledButton when rescue is unavailable for clear affordance.

Also emit stageStart / endlessStart analytics in restart() so every
attempt (not just the first) is bracketed by a matching start event.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 13:41:59 +09:00
parent 074a21ea2b
commit 9763968db9
4 changed files with 67 additions and 22 deletions
+15
View File
@@ -193,6 +193,21 @@ void main() {
});
});
group('rescueUsed getter', () {
test('rescueUsed flag is exposed and flips after a rescue', () {
final engine = GameEngine(
_stage(moveLimit: 1),
generator: _smallPool(1),
);
expect(engine.rescueUsed, isFalse);
engine.tryPlace(0, 0, 0);
expect(engine.phase, GamePhase.stuck);
expect(engine.rescueUsed, isFalse);
engine.addExtraMoves();
expect(engine.rescueUsed, isTrue);
});
});
group('dead board and continue', () {
StageConfig deadStage() {
// Checkerboard: only monos fit, and the injected pool has none small