2024-05-10 22:00:14 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2024-06-07 20:02:06 +02:00
|
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
2024-05-10 23:20:18 +02:00
|
|
|
import 'package:werwolf/screens/flippingcards.dart';
|
2024-05-10 22:00:14 +02:00
|
|
|
|
2024-05-10 23:21:21 +02:00
|
|
|
import '../models/game.dart';
|
2024-05-10 22:00:14 +02:00
|
|
|
import '../models/role.dart';
|
|
|
|
|
|
|
|
class GameSettings extends StatefulWidget {
|
|
|
|
final List<String> playernames;
|
|
|
|
const GameSettings({required this.playernames, super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<GameSettings> createState() => _GameSettingsState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _GameSettingsState extends State<GameSettings> {
|
|
|
|
late Game game;
|
2024-06-07 20:02:06 +02:00
|
|
|
|
2024-05-10 22:00:14 +02:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
game = Game(playernames: widget.playernames);
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
2024-06-07 20:02:06 +02:00
|
|
|
title: Text(
|
|
|
|
"Werwolf",
|
|
|
|
style: Theme.of(context).textTheme.titleLarge, // Apply text theme
|
|
|
|
),
|
2024-05-10 22:00:14 +02:00
|
|
|
centerTitle: true,
|
2024-06-07 20:02:06 +02:00
|
|
|
leading: IconButton(
|
|
|
|
icon: const Icon(FontAwesomeIcons.xmark),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.popUntil(context, ModalRoute.withName('/'));
|
|
|
|
},
|
|
|
|
),
|
2024-05-10 22:00:14 +02:00
|
|
|
),
|
|
|
|
body: Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(30.0, 40.0, 30.0, 0.0),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Text(
|
2024-06-07 20:02:06 +02:00
|
|
|
"Anzahl der Spieler ${widget.playernames.length}",
|
|
|
|
style: Theme.of(context).textTheme.titleLarge, // Apply text theme
|
2024-05-10 22:00:14 +02:00
|
|
|
),
|
|
|
|
const Divider(
|
|
|
|
height: 60,
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Anzahl der Werwölfe ${game.getWolves()}",
|
2024-06-07 20:02:06 +02:00
|
|
|
style:
|
|
|
|
Theme.of(context).textTheme.bodyLarge, // Apply text theme
|
2024-05-10 22:00:14 +02:00
|
|
|
),
|
|
|
|
IconButton(
|
2024-06-07 20:02:06 +02:00
|
|
|
onPressed: () {
|
|
|
|
setState(() {
|
|
|
|
game.decrementWolves();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
icon: const Icon(Icons.remove, color: Colors.white),
|
|
|
|
),
|
2024-05-10 22:00:14 +02:00
|
|
|
IconButton(
|
2024-06-07 20:02:06 +02:00
|
|
|
onPressed: () {
|
|
|
|
setState(() {
|
|
|
|
game.incrementWolves();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
icon: const Icon(Icons.add, color: Colors.white),
|
|
|
|
),
|
2024-05-10 22:00:14 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
const Divider(
|
|
|
|
height: 60,
|
|
|
|
),
|
2024-06-07 20:02:06 +02:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 8.0, bottom: 20),
|
|
|
|
child: Text(
|
|
|
|
"Spezielle Rollen",
|
|
|
|
style:
|
|
|
|
Theme.of(context).textTheme.titleLarge, // Apply text theme
|
|
|
|
),
|
2024-05-10 22:00:14 +02:00
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: ListView.builder(
|
|
|
|
itemCount: Role.values.length,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
if (Role.values[index] != Role.dorfbewohner &&
|
|
|
|
Role.values[index] != Role.werwolf) {
|
|
|
|
Role role = Role.values[index];
|
|
|
|
return ListTile(
|
|
|
|
title: Text(
|
|
|
|
role.stringValue,
|
2024-06-07 20:02:06 +02:00
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.bodyLarge, // Apply text theme
|
2024-05-10 22:00:14 +02:00
|
|
|
),
|
|
|
|
trailing: Switch(
|
2024-06-07 20:02:06 +02:00
|
|
|
value: game.specialRoles[role],
|
|
|
|
onChanged: (bool value) {
|
|
|
|
setState(() {
|
|
|
|
game.specialRoles[role] = value;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
2024-05-10 22:00:14 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return Container();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2024-05-10 23:20:18 +02:00
|
|
|
ElevatedButton(
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.push(
|
2024-06-07 20:02:06 +02:00
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) =>
|
|
|
|
FlipingCard(players: game.getAllPlayers()),
|
|
|
|
),
|
|
|
|
);
|
2024-05-10 23:20:18 +02:00
|
|
|
},
|
2024-06-07 20:02:06 +02:00
|
|
|
child: Text(
|
|
|
|
'Spiel starten!',
|
|
|
|
),
|
2024-05-10 23:20:18 +02:00
|
|
|
),
|
2024-06-07 20:02:06 +02:00
|
|
|
const Padding(padding: EdgeInsets.all(30)),
|
2024-05-10 22:00:14 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|