Add hint text after certain number of guesses (10 for now)

This commit is contained in:
Hank Grabowski 2024-08-30 17:50:33 -04:00
parent b752ac2bd0
commit 3ce0dd43aa
3 changed files with 33 additions and 2 deletions

View file

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:indent/indent.dart';
import 'package:intl/intl.dart';
import '../controls/focus_mode_status_headline.dart';
@ -15,6 +16,17 @@ import '../utils/snackbar_builder.dart';
import '../utils/string_utils.dart';
const _magicUnlockNumber = 1563948536;
final _hintText = '''
Try using a "bisection method" to guess.
For example, if the interval is 0 to 100 a first guess would be 50.
If it says it is too low try 75.
If it says it is too high try 25.
Continue until you get the right answer.
If you are stuck and the interval is very long, or forever,
reach out to the help options on the website for unlocking assistance.
'''
.unindent()
.replaceAll('\n', ' ');
class GameState {
final int maxNumber;
@ -69,6 +81,7 @@ class _DisableFocusModeScreenState
final guessController = TextEditingController();
var game = GameState.newGame(1);
var maxNumber = 1;
var tryCount = 0;
var message = '';
@override
@ -76,6 +89,7 @@ class _DisableFocusModeScreenState
super.initState();
maxNumber = ref.read(focusModeProvider).maxNumber;
game = GameState.newGame(maxNumber);
tryCount = 0;
message =
"If you guess the number I've picked from 0 to ${decimalWithCommasFormat.format(maxNumber)} you may disable focus mode...";
}
@ -98,7 +112,12 @@ class _DisableFocusModeScreenState
child: Column(
children: [
FocusModeStatusHeadline(disableTime: focusMode.disableTime),
Text(message),
Text(
message,
softWrap: true,
maxLines: 10,
textAlign: TextAlign.center,
),
const VerticalPadding(),
TextFormField(
controller: guessController,
@ -147,7 +166,10 @@ class _DisableFocusModeScreenState
context.go(ScreenPaths.timelines);
} else {
setState(() {
message = game.hint;
tryCount++;
message = tryCount <= 10
? game.hint
: '${game.hint}.\n\n$_hintText';
});
}
},

View file

@ -744,6 +744,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.1+1"
indent:
dependency: "direct main"
description:
name: indent
sha256: "819319a5c185f7fe412750c798953378b37a0d0d32564ce33e7c5acfd1372d2a"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
intl:
dependency: "direct main"
description:

View file

@ -60,6 +60,7 @@ dependencies:
video_player: ^2.9.1
wheel_chooser: ^1.1.2
intl: ^0.19.0
indent: ^2.0.0
dev_dependencies:
flutter_test: