use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "snake_case")]
pub enum RuntimeCompanyConditionTestScope {
    #[default]
    Disabled,
    AllCompanies,
    SelectedCompanyOnly,
    AiCompaniesOnly,
    HumanCompaniesOnly,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "snake_case")]
pub enum RuntimePlayerConditionTestScope {
    #[default]
    Disabled,
    AllPlayers,
    SelectedPlayerOnly,
    AiPlayersOnly,
    HumanPlayersOnly,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum RuntimeCompanyMetric {
    CurrentCash,
    TotalDebt,
    CreditRating,
    PrimeRate,
    BookValuePerShare,
    InvestorConfidence,
    ManagementAttitude,
    TrackPiecesTotal,
    TrackPiecesSingle,
    TrackPiecesDouble,
    TrackPiecesTransition,
    TrackPiecesElectric,
    TrackPiecesNonElectric,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum RuntimeCompanyMarketMetric {
    OutstandingShares,
    BondCount,
    LargestLiveBondPrincipal,
    HighestCouponLiveBondPrincipal,
    AssignedSharePool,
    UnassignedSharePool,
    CachedSharePrice,
    ChairmanSalaryBaseline,
    ChairmanSalaryCurrent,
    ChairmanBonusAmount,
    CurrentIssueAbsoluteCounter,
    PriorIssueAbsoluteCounter,
    CurrentIssueAgeAbsoluteCounterDelta,
    CurrentIssueCalendarWord,
    CurrentIssueCalendarWord2,
    PriorIssueCalendarWord,
    PriorIssueCalendarWord2,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum RuntimeChairmanMetric {
    CurrentCash,
    HoldingsValueTotal,
    NetWorthTotal,
    PurchasingPowerTotal,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct RuntimeCompanyStatSelector {
    pub family_id: u32,
    pub slot_id: u32,
}

pub const RUNTIME_COMPANY_STAT_FAMILY_CONTROL_TRANSFER: u32 = 0x2329;
pub const RUNTIME_COMPANY_STAT_FAMILY_SPECIAL_232A: u32 = 0x232a;
pub const RUNTIME_COMPANY_STAT_SLOT_CURRENT_CASH: u32 = 0x0d;
pub const RUNTIME_COMPANY_STAT_SLOT_BOOK_VALUE_PER_SHARE: u32 = 0x1d;
pub const RUNTIME_COMPANY_STAT_SLOT_CREDIT_RATING: u32 = 0x19;
pub const RUNTIME_COMPANY_STAT_SLOT_COUNT: u32 = 0x2b;
pub const RUNTIME_COMPANY_YEAR_STAT_FAMILY_SPAN: u32 = 11;
pub const RUNTIME_WORLD_ISSUE_INVESTOR_CONFIDENCE: u32 = 0x37;
pub const RUNTIME_WORLD_ISSUE_CREDIT_MARKET: u32 = 0x38;
pub const RUNTIME_WORLD_ISSUE_PRIME_RATE: u32 = 0x39;
pub const RUNTIME_WORLD_ISSUE_MANAGEMENT_ATTITUDE: u32 = 0x3a;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct RuntimeWorldIssueState {
    pub issue_id: u32,
    pub raw_value_u32: u32,
    #[serde(default)]
    pub multiplier_raw_u32: Option<u32>,
    #[serde(default)]
    pub multiplier_value_f32_text: Option<String>,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct RuntimePackedCalendarTuple {
    pub year_word: u16,
    pub month_1_based: u8,
    pub week_1_based: u8,
    pub day_1_based: u8,
    pub hour_0_based: u8,
    pub quarter_day_1_based: u8,
    pub minute_0_based: u8,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum RuntimeTerritoryMetric {
    TrackPiecesTotal,
    TrackPiecesSingle,
    TrackPiecesDouble,
    TrackPiecesTransition,
    TrackPiecesElectric,
    TrackPiecesNonElectric,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum RuntimeTrackMetric {
    Total,
    Single,
    Double,
    Transition,
    Electric,
    NonElectric,
}
