changed games.dart to game.dart

main
Oeyuu 2024-05-10 23:21:21 +02:00
parent 5a4e32992e
commit df30b3efbb
2 changed files with 23 additions and 1 deletions

View File

@ -32,4 +32,26 @@ class Game {
int getWolves() {
return numWolves;
}
List<Player> getAllPlayers() {
players.clear();
List<Role> randomRoles = [];
for (var i = 0; i < numWolves; i++) {
randomRoles.add(Role.werwolf);
}
for (var specialRole in specialRoles.keys) {
if (specialRoles[specialRole]) {
randomRoles.add(specialRole);
}
}
for (var i = randomRoles.length; i < playernames.length; i++) {
randomRoles.add(Role.dorfbewohner);
}
randomRoles.shuffle();
for (var playerName in playernames) {
players.add(Player(name: playerName, role: randomRoles.last));
randomRoles.removeLast();
}
return players;
}
}

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:werwolf/screens/flippingcards.dart';
import '../models/games.dart';
import '../models/game.dart';
import '../models/role.dart';
class GameSettings extends StatefulWidget {