From ea1c1a68403019744f63f0e834577814c6557ec0 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Mon, 12 Aug 2024 14:58:45 -0400 Subject: [PATCH] added prototype of GameRound model --- .../pages/games/story_game/round_model.dart | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lib/pangea/pages/games/story_game/round_model.dart diff --git a/lib/pangea/pages/games/story_game/round_model.dart b/lib/pangea/pages/games/story_game/round_model.dart new file mode 100644 index 000000000..e3ad65d89 --- /dev/null +++ b/lib/pangea/pages/games/story_game/round_model.dart @@ -0,0 +1,28 @@ +import 'dart:async'; + +enum RoundState { notStarted, inProgress, completed } + +class GameRoundModel { + static const Duration roundLength = Duration(minutes: 3); + + Timer? timer; + DateTime? startTime; + DateTime? endTime; + RoundState state = RoundState.notStarted; + + GameRoundModel() { + timer = Timer(roundLength, () => endRound()); + startTime = DateTime.now(); + } + + void startRound() { + state = RoundState.inProgress; + startTime = DateTime.now(); + timer = Timer(roundLength, () => endRound()); + } + + void endRound() { + endTime = DateTime.now(); + state = RoundState.completed; + } +}