2024-05-10 22:00:14 +02:00
|
|
|
import 'package:flutter/material.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;
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
game = Game(playernames: widget.playernames);
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
title: const Text("Werwolf"),
|
|
|
|
centerTitle: true,
|
|
|
|
),
|
|
|
|
body: Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(30.0, 40.0, 30.0, 0.0),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Anzahl der Spieler ${widget.playernames.length}", // hier muss noch die anzahl der spieler hin
|
|
|
|
style: const TextStyle(color: Colors.white, fontSize: 18),
|
|
|
|
),
|
|
|
|
const Divider(
|
|
|
|
height: 60,
|
|
|
|
color: Colors.grey,
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Anzahl der Werwölfe ${game.getWolves()}",
|
|
|
|
style: const TextStyle(color: Colors.white, fontSize: 18),
|
|
|
|
),
|
|
|
|
IconButton(
|
|
|
|
onPressed: () {
|
|
|
|
setState(() {
|
|
|
|
game.decrementWolves();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
icon: const Icon(Icons.remove, color: Colors.white)),
|
|
|
|
IconButton(
|
|
|
|
onPressed: () {
|
|
|
|
setState(() {
|
|
|
|
game.incrementWolves();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
icon: const Icon(Icons.add, color: Colors.white)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const Divider(
|
|
|
|
height: 60,
|
|
|
|
color: Colors.grey,
|
|
|
|
),
|
|
|
|
const Text(
|
|
|
|
"Spezielle Rollen",
|
|
|
|
style: TextStyle(color: Colors.white, fontSize: 18),
|
|
|
|
),
|
|
|
|
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,
|
|
|
|
style:
|
|
|
|
const TextStyle(color: Colors.white, fontSize: 16),
|
|
|
|
),
|
|
|
|
trailing: Switch(
|
|
|
|
value: game.specialRoles[role],
|
|
|
|
trackColor: const MaterialStatePropertyAll<Color>(
|
|
|
|
Color.fromARGB(255, 189, 189, 189)),
|
|
|
|
thumbColor: const MaterialStatePropertyAll<Color>(
|
|
|
|
Colors.black),
|
|
|
|
onChanged: (bool value) {
|
|
|
|
setState(() {
|
|
|
|
game.specialRoles[role] = value;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Container();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2024-05-10 23:20:18 +02:00
|
|
|
ElevatedButton(
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) =>
|
|
|
|
FlipingCard(players: game.getAllPlayers()),
|
|
|
|
));
|
|
|
|
},
|
|
|
|
child: const Text('Spiel starten!'),
|
|
|
|
),
|
2024-05-10 22:00:14 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|