added prototype of GameRound model
This commit is contained in:
parent
368eae1014
commit
ea1c1a6840
1 changed files with 28 additions and 0 deletions
28
lib/pangea/pages/games/story_game/round_model.dart
Normal file
28
lib/pangea/pages/games/story_game/round_model.dart
Normal file
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue