added prototype of GameRound model

This commit is contained in:
ggurdin 2024-08-12 14:58:45 -04:00
parent 368eae1014
commit ea1c1a6840
No known key found for this signature in database
GPG key ID: A01CB41737CBB478

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