use serde::{Deserialize, Serialize};

use crate::event::targets::RuntimeCargoClass;

fn runtime_train_default_active() -> bool {
    true
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct RuntimeTrain {
    pub train_id: u32,
    pub owner_company_id: u32,
    #[serde(default)]
    pub territory_id: Option<u32>,
    #[serde(default)]
    pub locomotive_name: Option<String>,
    #[serde(default = "runtime_train_default_active")]
    pub active: bool,
    #[serde(default)]
    pub retired: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct RuntimeLocomotiveCatalogEntry {
    pub locomotive_id: u32,
    pub name: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct RuntimeCargoCatalogEntry {
    pub slot_id: u32,
    pub label: String,
    #[serde(default)]
    pub cargo_class: RuntimeCargoClass,
    #[serde(default)]
    pub supplied_token_stem: Option<String>,
    #[serde(default)]
    pub demanded_token_stem: Option<String>,
}
