use crate::inspect::smp::catalog::*;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(in crate::inspect::smp) struct KnownSpecialConditionDefinition {
    pub(in crate::inspect::smp) slot_index: u8,
    pub(in crate::inspect::smp) hidden: bool,
    pub(in crate::inspect::smp) label_id: u32,
    pub(in crate::inspect::smp) help_id: u32,
    pub(in crate::inspect::smp) label: &'static str,
}

pub(in crate::inspect::smp) const KNOWN_SPECIAL_CONDITION_DEFINITIONS:
    [KnownSpecialConditionDefinition; SPECIAL_CONDITION_COUNT] = [
    KnownSpecialConditionDefinition {
        slot_index: 0,
        hidden: false,
        label_id: 2535,
        help_id: 2564,
        label: "Disable Stock Buying and Selling",
    },
    KnownSpecialConditionDefinition {
        slot_index: 1,
        hidden: false,
        label_id: 2536,
        help_id: 2565,
        label: "Disable Margin Buying/Short Selling Stock",
    },
    KnownSpecialConditionDefinition {
        slot_index: 2,
        hidden: false,
        label_id: 2537,
        help_id: 2566,
        label: "Disable Company Issue/Buy Back Stock",
    },
    KnownSpecialConditionDefinition {
        slot_index: 3,
        hidden: false,
        label_id: 2538,
        help_id: 2567,
        label: "Disable Issuing/Repaying Bonds",
    },
    KnownSpecialConditionDefinition {
        slot_index: 4,
        hidden: false,
        label_id: 2539,
        help_id: 2568,
        label: "Disable Declaring Bankruptcy",
    },
    KnownSpecialConditionDefinition {
        slot_index: 5,
        hidden: false,
        label_id: 2540,
        help_id: 2569,
        label: "Disable Changing the Dividend Rate",
    },
    KnownSpecialConditionDefinition {
        slot_index: 6,
        hidden: false,
        label_id: 2541,
        help_id: 2570,
        label: "Disable Replacing a Locomotive",
    },
    KnownSpecialConditionDefinition {
        slot_index: 7,
        hidden: false,
        label_id: 2542,
        help_id: 2571,
        label: "Disable Retiring a Train",
    },
    KnownSpecialConditionDefinition {
        slot_index: 8,
        hidden: false,
        label_id: 2543,
        help_id: 2572,
        label: "Disable Changing Cargo Consist On Train",
    },
    KnownSpecialConditionDefinition {
        slot_index: 9,
        hidden: false,
        label_id: 2544,
        help_id: 2573,
        label: "Disable Buying a Train",
    },
    KnownSpecialConditionDefinition {
        slot_index: 10,
        hidden: false,
        label_id: 2545,
        help_id: 2574,
        label: "Disable All Track Building",
    },
    KnownSpecialConditionDefinition {
        slot_index: 11,
        hidden: false,
        label_id: 2546,
        help_id: 2575,
        label: "Disable Unconnected Track Building",
    },
    KnownSpecialConditionDefinition {
        slot_index: 12,
        hidden: false,
        label_id: 2547,
        help_id: 2576,
        label: "Limited Track Building Amount",
    },
    KnownSpecialConditionDefinition {
        slot_index: 13,
        hidden: false,
        label_id: 2548,
        help_id: 2577,
        label: "Disable Building Stations",
    },
    KnownSpecialConditionDefinition {
        slot_index: 14,
        hidden: false,
        label_id: 2549,
        help_id: 2578,
        label: "Disable Building Hotel/Restaurant/Tavern/Post Office",
    },
    KnownSpecialConditionDefinition {
        slot_index: 15,
        hidden: false,
        label_id: 2550,
        help_id: 2579,
        label: "Disable Building Customs House",
    },
    KnownSpecialConditionDefinition {
        slot_index: 16,
        hidden: false,
        label_id: 2551,
        help_id: 2580,
        label: "Disable Building Industry Buildings",
    },
    KnownSpecialConditionDefinition {
        slot_index: 17,
        hidden: false,
        label_id: 2552,
        help_id: 2581,
        label: "Disable Buying Existing Industry Buildings",
    },
    KnownSpecialConditionDefinition {
        slot_index: 18,
        hidden: false,
        label_id: 2553,
        help_id: 2582,
        label: "Disable Being Fired As Chairman",
    },
    KnownSpecialConditionDefinition {
        slot_index: 19,
        hidden: false,
        label_id: 2554,
        help_id: 2583,
        label: "Disable Resigning as Chairman",
    },
    KnownSpecialConditionDefinition {
        slot_index: 20,
        hidden: false,
        label_id: 2555,
        help_id: 2584,
        label: "Disable Chairmanship Takeover",
    },
    KnownSpecialConditionDefinition {
        slot_index: 21,
        hidden: false,
        label_id: 2556,
        help_id: 2585,
        label: "Disable Starting Any Companies",
    },
    KnownSpecialConditionDefinition {
        slot_index: 22,
        hidden: false,
        label_id: 2557,
        help_id: 2586,
        label: "Disable Starting Multiple Companies",
    },
    KnownSpecialConditionDefinition {
        slot_index: 23,
        hidden: false,
        label_id: 2558,
        help_id: 2587,
        label: "Disable Merging Companies",
    },
    KnownSpecialConditionDefinition {
        slot_index: 24,
        hidden: false,
        label_id: 2559,
        help_id: 2588,
        label: "Disable Bulldozing",
    },
    KnownSpecialConditionDefinition {
        slot_index: 25,
        hidden: false,
        label_id: 2560,
        help_id: 2589,
        label: "Show Visited Track",
    },
    KnownSpecialConditionDefinition {
        slot_index: 26,
        hidden: false,
        label_id: 2561,
        help_id: 2590,
        label: "Show Visited Stations",
    },
    KnownSpecialConditionDefinition {
        slot_index: 27,
        hidden: false,
        label_id: 2562,
        help_id: 2591,
        label: "Use Slow Date",
    },
    KnownSpecialConditionDefinition {
        slot_index: 28,
        hidden: false,
        label_id: 2563,
        help_id: 2592,
        label: "Completely Disable Money-Related Things",
    },
    KnownSpecialConditionDefinition {
        slot_index: 29,
        hidden: false,
        label_id: 2874,
        help_id: 2875,
        label: "Use Bio-Accelerator Cars",
    },
    KnownSpecialConditionDefinition {
        slot_index: 30,
        hidden: false,
        label_id: 3722,
        help_id: 3723,
        label: "Disable Cargo Economy",
    },
    KnownSpecialConditionDefinition {
        slot_index: 31,
        hidden: false,
        label_id: 3835,
        help_id: 3836,
        label: "Use Wartime Cargos",
    },
    KnownSpecialConditionDefinition {
        slot_index: 32,
        hidden: false,
        label_id: 3850,
        help_id: 3851,
        label: "Disable Train Crashes",
    },
    KnownSpecialConditionDefinition {
        slot_index: 33,
        hidden: false,
        label_id: 3852,
        help_id: 3853,
        label: "Disable Train Crashes AND Breakdowns",
    },
    KnownSpecialConditionDefinition {
        slot_index: 34,
        hidden: false,
        label_id: 3920,
        help_id: 3921,
        label: "AI Ignore Territories At Startup",
    },
    KnownSpecialConditionDefinition {
        slot_index: 35,
        hidden: true,
        label_id: 3,
        help_id: 3,
        label: "Hidden sentinel",
    },
];

pub(in crate::inspect::smp) fn known_special_condition_definition_for_label_id(
    label_id: u32,
) -> Option<KnownSpecialConditionDefinition> {
    KNOWN_SPECIAL_CONDITION_DEFINITIONS
        .iter()
        .copied()
        .find(|definition| !definition.hidden && definition.label_id == label_id)
}
