Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sashkent3 committed May 6, 2020
1 parent 6aacfe5 commit 30b3a14
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 90 deletions.
53 changes: 26 additions & 27 deletions lib/deathmatch_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,7 @@ abstract class _DeathmatchState with Store {
stopwatch.reset();
score += 1;
matchTimer.cancel();
matchTimer = Timer.periodic(Duration(seconds: 1), (Timer _timeout) {
timerTick();
if (mainTimer == 0) {
_timeout.cancel();
audioPlayer.play('round_start_timer_timeout.wav',
mode: PlayerMode.LOW_LATENCY);
setState('score');
}
});
resetMatchTimer();
if (score % 5 == 0) {
bool decreaseAdditionalTime;
if (additionalTime == 0) {
Expand Down Expand Up @@ -175,24 +167,7 @@ abstract class _DeathmatchState with Store {
mode: PlayerMode.LOW_LATENCY);
setState('main');
word = dictionary.getWords(1, difficulty, 5)[0];
matchTimer = Timer.periodic(Duration(seconds: 1), (Timer _timeout) {
timerTick();
if (mainTimer == 0) {
_timeout.cancel();
audioPlayer.play('round_start_timer_timeout.wav',
mode: PlayerMode.LOW_LATENCY);
gameLog['end_timestamp'] = DateTime.now().millisecondsSinceEpoch;
gameLog['attempts'].add({
'from': 0,
'to': 1,
'word': word,
'time': stopwatch.elapsedMilliseconds,
'extra_time': 0
});
stopwatch.stop();
setState('score');
}
});
resetMatchTimer();
}

@observable
Expand Down Expand Up @@ -223,4 +198,28 @@ abstract class _DeathmatchState with Store {
}
});
}

@action
void resetMatchTimer() {
matchTimer = Timer.periodic(Duration(seconds: 1), (Timer _timeout) {
timerTick();
if (mainTimer == 0) {
_timeout.cancel();
audioPlayer.play('round_start_timer_timeout.wav',
mode: PlayerMode.LOW_LATENCY);
gameLog['end_timestamp'] = DateTime
.now()
.millisecondsSinceEpoch;
gameLog['attempts'].add({
'from': 0,
'to': 1,
'word': word,
'time': stopwatch.elapsedMilliseconds,
'extra_time': 0
});
stopwatch.stop();
setState('score');
}
});
}
}
Loading

0 comments on commit 30b3a14

Please sign in to comment.