49 lines
994 B
Dart
49 lines
994 B
Dart
|
import 'package:werwolf/models/role.dart';
|
||
|
|
||
|
import 'player.dart';
|
||
|
|
||
|
class Game {
|
||
|
List<Player> players = [];
|
||
|
List playernames = [];
|
||
|
int numWolves = 1;
|
||
|
|
||
|
Game({required this.playernames, required this.numWolves}) {
|
||
|
assignRoles();
|
||
|
}
|
||
|
|
||
|
void addPlayer(String name, Role role) {
|
||
|
players.add(Player(name: name, role: role));
|
||
|
}
|
||
|
|
||
|
List<Player> getPlayers() {
|
||
|
return players;
|
||
|
}
|
||
|
|
||
|
void assignRoles() {
|
||
|
List<int> indexes = List.generate(playernames.length, (index) => index)
|
||
|
..shuffle();
|
||
|
for (var player in playernames) {
|
||
|
//addPlayer(player, Role.dorfbewohner);
|
||
|
for (int i = 0; i < numWolves; i++) {
|
||
|
addPlayer(player[0], Role.dorfbewohner);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void incrementWolves() {
|
||
|
if (numWolves < players.length) {
|
||
|
numWolves++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void decrementWolves() {
|
||
|
if (numWolves > 1) {
|
||
|
numWolves--;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// void toggleReveal(int index) {
|
||
|
// players[index].isRevealed = !players[index].isRevealed;
|
||
|
// }
|
||
|
}
|