use serde::{Deserialize, Serialize};
use std::sync::Arc;
use crate::clock::{self, Clock};
use crate::health::HealthConfig;
use crate::scoring::ScoringWeights;
#[derive(Clone, Serialize, Deserialize)]
pub struct EngineConfig {
pub scoring: ScoringWeights,
pub health: HealthConfig,
pub minimum_health_score: f32,
pub default_cooldown_seconds: u64,
#[serde(skip)]
pub(crate) clock: Option<Arc<dyn Clock>>,
}
impl EngineConfig {
pub fn with_clock(mut self, clock: Arc<dyn Clock>) -> Self {
self.clock = Some(clock);
self
}
pub(crate) fn clock(&self) -> Arc<dyn Clock> {
self.clock.clone().unwrap_or_else(clock::default_clock)
}
}
impl Default for EngineConfig {
fn default() -> Self {
Self {
scoring: ScoringWeights::default(),
health: HealthConfig::default(),
minimum_health_score: 0.2,
default_cooldown_seconds: 60,
clock: None,
}
}
}