From ff9deee2186a7aefb0eecaeda18993eb21843d6d Mon Sep 17 00:00:00 2001 From: Gustl22 Date: Tue, 16 Jan 2024 16:02:42 +0100 Subject: [PATCH] fix: Set initial period --- .../lib/ui/display/bout/bout_display.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wrestling_scoreboard_client/lib/ui/display/bout/bout_display.dart b/wrestling_scoreboard_client/lib/ui/display/bout/bout_display.dart index de40ae7d..ef332dc8 100644 --- a/wrestling_scoreboard_client/lib/ui/display/bout/bout_display.dart +++ b/wrestling_scoreboard_client/lib/ui/display/bout/bout_display.dart @@ -143,6 +143,8 @@ class BoutState extends ConsumerState { HornSound(); boutConfig = widget.boutConfig; bout = widget.bout; + // Set the current period based on the duration: + period = (bout.duration.inSeconds ~/ boutConfig.periodDuration.inSeconds) + 1; _r = ParticipantStateModel(bout.r); _b = ParticipantStateModel(bout.b); _r.injuryStopwatch.limit = boutConfig.injuryDuration; @@ -183,6 +185,7 @@ class BoutState extends ConsumerState { if (stopwatch == _boutStopwatch) { bout = bout.copyWith(duration: event); + // If is above the time of the current period, then trigger the break if (bout.duration.compareTo(boutConfig.periodDuration * period) >= 0) { _boutStopwatch.stop(); if (_r.activityStopwatch != null) {