From 73c12dc4284c6981015232d9cca26fcf529758e3 Mon Sep 17 00:00:00 2001 From: Tristan Debrunner Date: Thu, 27 Jul 2023 16:07:20 +1000 Subject: [PATCH] Add support for optional OT params from uwhscores --- uwh-common/src/uwhscores.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/uwh-common/src/uwhscores.rs b/uwh-common/src/uwhscores.rs index 9f8414d2..8a53aa9c 100644 --- a/uwh-common/src/uwhscores.rs +++ b/uwh-common/src/uwhscores.rs @@ -64,6 +64,9 @@ pub struct TimingRules { #[serde(deserialize_with = "deser_secs_to_dur")] pub min_game_break: Duration, pub overtime_allowed: bool, + pub pre_overtime_break: Option, + pub overtime_break_duration: Option, + pub overtime_duration: Option, pub sudden_death_allowed: bool, pub pre_sudden_death_break: Option, } @@ -78,6 +81,21 @@ impl Into for TimingRules { half_time_duration: self.half_time_duration, minimum_break: self.min_game_break, overtime_allowed: self.overtime_allowed, + pre_overtime_break: if let Some(len) = self.pre_overtime_break { + Duration::from_secs(len) + } else { + GameConfig::default().pre_overtime_break + }, + ot_half_time_duration: if let Some(len) = self.overtime_break_duration { + Duration::from_secs(len) + } else { + GameConfig::default().ot_half_time_duration + }, + ot_half_play_duration: if let Some(len) = self.overtime_duration { + Duration::from_secs(len) + } else { + GameConfig::default().ot_half_play_duration + }, sudden_death_allowed: self.sudden_death_allowed, pre_sudden_death_duration: if let Some(len) = self.pre_sudden_death_break { Duration::from_secs(len)