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; + } +}