valid choice
This commit is contained in:
parent
03987378c0
commit
dbd492969a
|
|
@ -51,6 +51,9 @@ class _SuperGameState extends State<SuperGame> {
|
|||
}
|
||||
}
|
||||
|
||||
bool _checkValidChoice(List<TTCState> game, int index) =>
|
||||
game[index] == TTCState.empty;
|
||||
|
||||
Widget _subGameDialog(int subGame) {
|
||||
return Dialog(
|
||||
child: Padding(
|
||||
|
|
@ -58,13 +61,20 @@ class _SuperGameState extends State<SuperGame> {
|
|||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
"${Util.stateText(turn)} select cell",
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 5),
|
||||
child: Text(
|
||||
"${Util.stateText(turn)} select cell",
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
TTCGame(
|
||||
turn: turn,
|
||||
cellOnTapCallback: (int i) {
|
||||
if (!_checkValidChoice(data[subGame], i)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nextPlay = i;
|
||||
setState(() {
|
||||
data[subGame][i] = turn;
|
||||
|
|
@ -74,15 +84,18 @@ class _SuperGameState extends State<SuperGame> {
|
|||
},
|
||||
data: data[subGame],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text("Close"))
|
||||
],
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 5),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text("Close"))
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in New Issue