Compare commits
2 Commits
03987378c0
...
25483be0ae
| Author | SHA1 | Date |
|---|---|---|
|
|
25483be0ae | |
|
|
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,33 @@ class _SuperGameState extends State<SuperGame> {
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Padding(
|
||||||
"${Util.stateText(turn)} select cell",
|
padding: const EdgeInsets.only(bottom: 5),
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
child: Text(
|
||||||
|
"${Util.stateText(turn)} select cell",
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
TTCGame(
|
TTCGame(
|
||||||
turn: turn,
|
turn: turn,
|
||||||
cellOnTapCallback: (int i) {
|
cellOnTapCallback: (int i) {
|
||||||
|
if (!_checkValidChoice(data[subGame], i)) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
content:
|
||||||
|
Text("${data[subGame][i].name.toUpperCase()}"
|
||||||
|
" already claimed "
|
||||||
|
"[${i % 3}, ${(i / 3).floor()}]"),
|
||||||
|
actions: [
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: const Text("Close"))
|
||||||
|
],
|
||||||
|
));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nextPlay = i;
|
nextPlay = i;
|
||||||
setState(() {
|
setState(() {
|
||||||
data[subGame][i] = turn;
|
data[subGame][i] = turn;
|
||||||
|
|
@ -74,15 +97,18 @@ class _SuperGameState extends State<SuperGame> {
|
||||||
},
|
},
|
||||||
data: data[subGame],
|
data: data[subGame],
|
||||||
),
|
),
|
||||||
Row(
|
Padding(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
padding: const EdgeInsets.only(top: 5),
|
||||||
children: [
|
child: Row(
|
||||||
ElevatedButton(
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
onPressed: () {
|
children: [
|
||||||
Navigator.pop(context);
|
ElevatedButton(
|
||||||
},
|
onPressed: () {
|
||||||
child: const Text("Close"))
|
Navigator.pop(context);
|
||||||
],
|
},
|
||||||
|
child: const Text("Close"))
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue