diff --git a/lib/models/games.dart b/lib/models/game.dart similarity index 51% rename from lib/models/games.dart rename to lib/models/game.dart index 10fa84a..410dd06 100644 --- a/lib/models/games.dart +++ b/lib/models/game.dart @@ -32,4 +32,26 @@ class Game { int getWolves() { return numWolves; } + + List getAllPlayers() { + players.clear(); + List 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; + } } diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index 0543f1a..5bcbe3c 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -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 {