Added created DateTime to game session class
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
import 'dart:math';
|
||||
|
||||
class GameSession {
|
||||
final String gameTitle;
|
||||
final List<String> players;
|
||||
final int gameMode;
|
||||
final DateTime createdAt = DateTime.now().subtract(Duration(
|
||||
milliseconds: Random().nextInt(
|
||||
Duration(days: 21).inMilliseconds + 1))); // DEBUG: Random Timestamp
|
||||
int round = 1;
|
||||
String? winner;
|
||||
|
||||
GameSession({
|
||||
required this.gameTitle,
|
||||
required this.players,
|
||||
required this.winner,
|
||||
required this.gameMode,
|
||||
});
|
||||
List<List<int>> playerScores = [
|
||||
@@ -22,7 +25,7 @@ class GameSession {
|
||||
@override
|
||||
String toString() {
|
||||
return ('GameSession: [gameTitle: $gameTitle, '
|
||||
'players: $players, winner: $winner, '
|
||||
'players: $players, '
|
||||
'round: $round, gameMode: $gameMode, '
|
||||
'playerScores: $playerScores]');
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class _ActiveGameViewState extends State<ActiveGameView> {
|
||||
playerIndices.sort((a, b) {
|
||||
int scoreA = widget.gameSession.playerScores[a][0];
|
||||
int scoreB = widget.gameSession.playerScores[b][0];
|
||||
return scoreA.compareTo(scoreB); // Absteigende Sortierung
|
||||
return scoreA.compareTo(scoreB);
|
||||
});
|
||||
return playerIndices;
|
||||
}
|
||||
|
||||
@@ -275,7 +275,6 @@ class _CreateGameState extends State<CreateGame> {
|
||||
GameSession gameSession = GameSession(
|
||||
gameTitle: _gameTitleTextController.text,
|
||||
players: players,
|
||||
winner: players[0],
|
||||
gameMode: selectedMode == '101 Pkt.' ? 0 : 1,
|
||||
);
|
||||
Navigator.push(
|
||||
|
||||
Reference in New Issue
Block a user