39 lines
791 B
Dart
39 lines
791 B
Dart
import 'player.dart';
|
|
|
|
class Game {
|
|
List<Player> players = [];
|
|
int numWolves;
|
|
|
|
Game(this.numWolves);
|
|
|
|
void addPlayer(String name) {
|
|
players.add(Player(name: name));
|
|
}
|
|
|
|
void assignRoles() {
|
|
List<int> indexes = List.generate(players.length, (index) => index)..shuffle();
|
|
for (var player in players) {
|
|
player.role = 'Dorfbewohner'; // Reset roles
|
|
}
|
|
for (int i = 0; i < numWolves; i++) {
|
|
players[indexes[i]].role = 'Werwolf';
|
|
}
|
|
}
|
|
|
|
void incrementWolves() {
|
|
if (numWolves < players.length) {
|
|
numWolves++;
|
|
}
|
|
}
|
|
|
|
void decrementWolves() {
|
|
if (numWolves > 1) {
|
|
numWolves--;
|
|
}
|
|
}
|
|
|
|
void toggleReveal(int index) {
|
|
players[index].isRevealed = !players[index].isRevealed;
|
|
}
|
|
}
|