From df30b3efbb7d20c2681e95e8150aa9927500eae5 Mon Sep 17 00:00:00 2001 From: Oeyuu Date: Fri, 10 May 2024 23:21:21 +0200 Subject: [PATCH] changed games.dart to game.dart --- lib/models/{games.dart => game.dart} | 22 ++++++++++++++++++++++ lib/screens/settings.dart | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) rename lib/models/{games.dart => game.dart} (51%) 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 {