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) {
|
Widget _subGameDialog(int subGame) {
|
||||||
return Dialog(
|
return Dialog(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
|
@ -58,13 +61,20 @@ class _SuperGameState extends State<SuperGame> {
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 5),
|
||||||
|
child: Text(
|
||||||
"${Util.stateText(turn)} select cell",
|
"${Util.stateText(turn)} select cell",
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
TTCGame(
|
TTCGame(
|
||||||
turn: turn,
|
turn: turn,
|
||||||
cellOnTapCallback: (int i) {
|
cellOnTapCallback: (int i) {
|
||||||
|
if (!_checkValidChoice(data[subGame], i)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nextPlay = i;
|
nextPlay = i;
|
||||||
setState(() {
|
setState(() {
|
||||||
data[subGame][i] = turn;
|
data[subGame][i] = turn;
|
||||||
|
|
@ -74,7 +84,9 @@ class _SuperGameState extends State<SuperGame> {
|
||||||
},
|
},
|
||||||
data: data[subGame],
|
data: data[subGame],
|
||||||
),
|
),
|
||||||
Row(
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 5),
|
||||||
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
|
|
@ -84,6 +96,7 @@ class _SuperGameState extends State<SuperGame> {
|
||||||
child: const Text("Close"))
|
child: const Text("Close"))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue