cpd_David_und_Yusuf/lib/models/game.dart

49 lines
994 B
Dart
Raw Normal View History

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;
// }
}