use rrt_runtime::summary::RuntimeSummary;

use crate::schema::ExpectedRuntimeSummary;

pub(super) fn compare_world(
    expected: &ExpectedRuntimeSummary,
    actual: &RuntimeSummary,
    mismatches: &mut Vec<String>,
) {
    if let Some(calendar) = expected.calendar {
        if actual.calendar != calendar {
            mismatches.push(format!(
                "calendar mismatch: expected {:?}, got {:?}",
                calendar, actual.calendar
            ));
        }
    }
    if let Some(source) = &expected.calendar_projection_source {
        if actual.calendar_projection_source.as_ref() != Some(source) {
            mismatches.push(format!(
                "calendar_projection_source mismatch: expected {source:?}, got {:?}",
                actual.calendar_projection_source
            ));
        }
    }
    if let Some(is_placeholder) = expected.calendar_projection_is_placeholder {
        if actual.calendar_projection_is_placeholder != is_placeholder {
            mismatches.push(format!(
                "calendar_projection_is_placeholder mismatch: expected {is_placeholder}, got {}",
                actual.calendar_projection_is_placeholder
            ));
        }
    }
    if let Some(count) = expected.world_flag_count {
        if actual.world_flag_count != count {
            mismatches.push(format!(
                "world_flag_count mismatch: expected {count}, got {}",
                actual.world_flag_count
            ));
        }
    }
    if let Some(lane) = expected.world_restore_selected_year_profile_lane {
        if actual.world_restore_selected_year_profile_lane != Some(lane) {
            mismatches.push(format!(
                "world_restore_selected_year_profile_lane mismatch: expected {lane}, got {:?}",
                actual.world_restore_selected_year_profile_lane
            ));
        }
    }
    if let Some(enabled) = expected.world_restore_campaign_scenario_enabled {
        if actual.world_restore_campaign_scenario_enabled != Some(enabled) {
            mismatches.push(format!(
                "world_restore_campaign_scenario_enabled mismatch: expected {enabled}, got {:?}",
                actual.world_restore_campaign_scenario_enabled
            ));
        }
    }
    if let Some(enabled) = expected.world_restore_sandbox_enabled {
        if actual.world_restore_sandbox_enabled != Some(enabled) {
            mismatches.push(format!(
                "world_restore_sandbox_enabled mismatch: expected {enabled}, got {:?}",
                actual.world_restore_sandbox_enabled
            ));
        }
    }
    if let Some(enabled) = expected.world_restore_seed_tuple_written_from_raw_lane {
        if actual.world_restore_seed_tuple_written_from_raw_lane != Some(enabled) {
            mismatches.push(format!(
                "world_restore_seed_tuple_written_from_raw_lane mismatch: expected {enabled}, got {:?}",
                actual.world_restore_seed_tuple_written_from_raw_lane
            ));
        }
    }
    if let Some(enabled) = expected.world_restore_absolute_counter_requires_shell_context {
        if actual.world_restore_absolute_counter_requires_shell_context != Some(enabled) {
            mismatches.push(format!(
                "world_restore_absolute_counter_requires_shell_context mismatch: expected {enabled}, got {:?}",
                actual.world_restore_absolute_counter_requires_shell_context
            ));
        }
    }
    if let Some(enabled) = expected.world_restore_absolute_counter_reconstructible_from_save {
        if actual.world_restore_absolute_counter_reconstructible_from_save != Some(enabled) {
            mismatches.push(format!(
                "world_restore_absolute_counter_reconstructible_from_save mismatch: expected {enabled}, got {:?}",
                actual.world_restore_absolute_counter_reconstructible_from_save
            ));
        }
    }
    if let Some(value) = expected.world_restore_packed_year_word_raw_u16 {
        if actual.world_restore_packed_year_word_raw_u16 != Some(value) {
            mismatches.push(format!(
                "world_restore_packed_year_word_raw_u16 mismatch: expected {value}, got {:?}",
                actual.world_restore_packed_year_word_raw_u16
            ));
        }
    }
    if let Some(value) = expected.world_restore_partial_year_progress_raw_u8 {
        if actual.world_restore_partial_year_progress_raw_u8 != Some(value) {
            mismatches.push(format!(
                "world_restore_partial_year_progress_raw_u8 mismatch: expected {value}, got {:?}",
                actual.world_restore_partial_year_progress_raw_u8
            ));
        }
    }
    if let Some(value) = expected.world_restore_current_calendar_tuple_word_raw_u32 {
        if actual.world_restore_current_calendar_tuple_word_raw_u32 != Some(value) {
            mismatches.push(format!(
                "world_restore_current_calendar_tuple_word_raw_u32 mismatch: expected {value}, got {:?}",
                actual.world_restore_current_calendar_tuple_word_raw_u32
            ));
        }
    }
    if let Some(value) = expected.world_restore_current_calendar_tuple_word_2_raw_u32 {
        if actual.world_restore_current_calendar_tuple_word_2_raw_u32 != Some(value) {
            mismatches.push(format!(
                "world_restore_current_calendar_tuple_word_2_raw_u32 mismatch: expected {value}, got {:?}",
                actual.world_restore_current_calendar_tuple_word_2_raw_u32
            ));
        }
    }
    if let Some(value) = expected.world_restore_absolute_counter_raw_u32 {
        if actual.world_restore_absolute_counter_raw_u32 != Some(value) {
            mismatches.push(format!(
                "world_restore_absolute_counter_raw_u32 mismatch: expected {value}, got {:?}",
                actual.world_restore_absolute_counter_raw_u32
            ));
        }
    }
    if let Some(value) = expected.world_restore_absolute_counter_mirror_raw_u32 {
        if actual.world_restore_absolute_counter_mirror_raw_u32 != Some(value) {
            mismatches.push(format!(
                "world_restore_absolute_counter_mirror_raw_u32 mismatch: expected {value}, got {:?}",
                actual.world_restore_absolute_counter_mirror_raw_u32
            ));
        }
    }
    if let Some(slot) = expected.world_restore_disable_cargo_economy_special_condition_slot {
        if actual.world_restore_disable_cargo_economy_special_condition_slot != Some(slot) {
            mismatches.push(format!(
                "world_restore_disable_cargo_economy_special_condition_slot mismatch: expected {slot}, got {:?}",
                actual.world_restore_disable_cargo_economy_special_condition_slot
            ));
        }
    }
    if let Some(enabled) =
        expected.world_restore_disable_cargo_economy_special_condition_reconstructible_from_save
    {
        if actual.world_restore_disable_cargo_economy_special_condition_reconstructible_from_save
            != Some(enabled)
        {
            mismatches.push(format!(
                "world_restore_disable_cargo_economy_special_condition_reconstructible_from_save mismatch: expected {enabled}, got {:?}",
                actual.world_restore_disable_cargo_economy_special_condition_reconstructible_from_save
            ));
        }
    }
    if let Some(enabled) =
        expected.world_restore_disable_cargo_economy_special_condition_write_side_grounded
    {
        if actual.world_restore_disable_cargo_economy_special_condition_write_side_grounded
            != Some(enabled)
        {
            mismatches.push(format!(
                "world_restore_disable_cargo_economy_special_condition_write_side_grounded mismatch: expected {enabled}, got {:?}",
                actual.world_restore_disable_cargo_economy_special_condition_write_side_grounded
            ));
        }
    }
    if let Some(enabled) = expected.world_restore_disable_cargo_economy_special_condition_enabled {
        if actual.world_restore_disable_cargo_economy_special_condition_enabled != Some(enabled) {
            mismatches.push(format!(
                "world_restore_disable_cargo_economy_special_condition_enabled mismatch: expected {enabled}, got {:?}",
                actual.world_restore_disable_cargo_economy_special_condition_enabled
            ));
        }
    }
    if let Some(enabled) = expected.world_restore_use_bio_accelerator_cars_enabled {
        if actual.world_restore_use_bio_accelerator_cars_enabled != Some(enabled) {
            mismatches.push(format!(
                "world_restore_use_bio_accelerator_cars_enabled mismatch: expected {enabled}, got {:?}",
                actual.world_restore_use_bio_accelerator_cars_enabled
            ));
        }
    }
    if let Some(enabled) = expected.world_restore_use_wartime_cargos_enabled {
        if actual.world_restore_use_wartime_cargos_enabled != Some(enabled) {
            mismatches.push(format!(
                "world_restore_use_wartime_cargos_enabled mismatch: expected {enabled}, got {:?}",
                actual.world_restore_use_wartime_cargos_enabled
            ));
        }
    }
    if let Some(enabled) = expected.world_restore_disable_train_crashes_enabled {
        if actual.world_restore_disable_train_crashes_enabled != Some(enabled) {
            mismatches.push(format!(
                "world_restore_disable_train_crashes_enabled mismatch: expected {enabled}, got {:?}",
                actual.world_restore_disable_train_crashes_enabled
            ));
        }
    }
    if let Some(enabled) = expected.world_restore_disable_train_crashes_and_breakdowns_enabled {
        if actual.world_restore_disable_train_crashes_and_breakdowns_enabled != Some(enabled) {
            mismatches.push(format!(
                "world_restore_disable_train_crashes_and_breakdowns_enabled mismatch: expected {enabled}, got {:?}",
                actual.world_restore_disable_train_crashes_and_breakdowns_enabled
            ));
        }
    }
    if let Some(enabled) = expected.world_restore_ai_ignore_territories_at_startup_enabled {
        if actual.world_restore_ai_ignore_territories_at_startup_enabled != Some(enabled) {
            mismatches.push(format!(
                "world_restore_ai_ignore_territories_at_startup_enabled mismatch: expected {enabled}, got {:?}",
                actual.world_restore_ai_ignore_territories_at_startup_enabled
            ));
        }
    }
    if let Some(value) = expected.world_restore_limited_track_building_amount {
        if actual.world_restore_limited_track_building_amount != Some(value) {
            mismatches.push(format!(
                "world_restore_limited_track_building_amount mismatch: expected {value}, got {:?}",
                actual.world_restore_limited_track_building_amount
            ));
        }
    }
    if let Some(code) = expected.world_restore_economic_status_code {
        if actual.world_restore_economic_status_code != Some(code) {
            mismatches.push(format!(
                "world_restore_economic_status_code mismatch: expected {code}, got {:?}",
                actual.world_restore_economic_status_code
            ));
        }
    }
    if let Some(value) = expected.world_restore_territory_access_cost {
        if actual.world_restore_territory_access_cost != Some(value) {
            mismatches.push(format!(
                "world_restore_territory_access_cost mismatch: expected {value}, got {:?}",
                actual.world_restore_territory_access_cost
            ));
        }
    }
    if let Some(value) = expected.world_restore_issue_37_value {
        if actual.world_restore_issue_37_value != Some(value) {
            mismatches.push(format!(
                "world_restore_issue_37_value mismatch: expected {value}, got {:?}",
                actual.world_restore_issue_37_value
            ));
        }
    }
    if let Some(value) = expected.world_restore_issue_38_value {
        if actual.world_restore_issue_38_value != Some(value) {
            mismatches.push(format!(
                "world_restore_issue_38_value mismatch: expected {value}, got {:?}",
                actual.world_restore_issue_38_value
            ));
        }
    }
    if let Some(value) = expected.world_restore_issue_39_value {
        if actual.world_restore_issue_39_value != Some(value) {
            mismatches.push(format!(
                "world_restore_issue_39_value mismatch: expected {value}, got {:?}",
                actual.world_restore_issue_39_value
            ));
        }
    }
    if let Some(value) = expected.world_restore_issue_3a_value {
        if actual.world_restore_issue_3a_value != Some(value) {
            mismatches.push(format!(
                "world_restore_issue_3a_value mismatch: expected {value}, got {:?}",
                actual.world_restore_issue_3a_value
            ));
        }
    }
    if let Some(value) = expected.world_restore_issue_37_multiplier_raw_u32 {
        if actual.world_restore_issue_37_multiplier_raw_u32 != Some(value) {
            mismatches.push(format!(
                "world_restore_issue_37_multiplier_raw_u32 mismatch: expected {value}, got {:?}",
                actual.world_restore_issue_37_multiplier_raw_u32
            ));
        }
    }
    if let Some(value) = &expected.world_restore_issue_37_multiplier_value_f32_text {
        if actual
            .world_restore_issue_37_multiplier_value_f32_text
            .as_ref()
            != Some(value)
        {
            mismatches.push(format!(
                "world_restore_issue_37_multiplier_value_f32_text mismatch: expected {value:?}, got {:?}",
                actual.world_restore_issue_37_multiplier_value_f32_text
            ));
        }
    }
    if let Some(count) = expected.world_restore_finance_neighborhood_count {
        if actual.world_restore_finance_neighborhood_count != count {
            mismatches.push(format!(
                "world_restore_finance_neighborhood_count mismatch: expected {count}, got {}",
                actual.world_restore_finance_neighborhood_count
            ));
        }
    }
    if let Some(labels) = &expected.world_restore_finance_neighborhood_labels {
        if &actual.world_restore_finance_neighborhood_labels != labels {
            mismatches.push(format!(
                "world_restore_finance_neighborhood_labels mismatch: expected {labels:?}, got {:?}",
                actual.world_restore_finance_neighborhood_labels
            ));
        }
    }
    if let Some(value) = expected.world_restore_economic_tuning_mirror_raw_u32 {
        if actual.world_restore_economic_tuning_mirror_raw_u32 != Some(value) {
            mismatches.push(format!(
                "world_restore_economic_tuning_mirror_raw_u32 mismatch: expected {value}, got {:?}",
                actual.world_restore_economic_tuning_mirror_raw_u32
            ));
        }
    }
    if let Some(value) = &expected.world_restore_economic_tuning_mirror_value_f32_text {
        if actual
            .world_restore_economic_tuning_mirror_value_f32_text
            .as_ref()
            != Some(value)
        {
            mismatches.push(format!(
                "world_restore_economic_tuning_mirror_value_f32_text mismatch: expected {value:?}, got {:?}",
                actual.world_restore_economic_tuning_mirror_value_f32_text
            ));
        }
    }
    if let Some(count) = expected.world_restore_economic_tuning_lane_count {
        if actual.world_restore_economic_tuning_lane_count != count {
            mismatches.push(format!(
                "world_restore_economic_tuning_lane_count mismatch: expected {count}, got {}",
                actual.world_restore_economic_tuning_lane_count
            ));
        }
    }
    if let Some(values) = &expected.world_restore_economic_tuning_lane_value_f32_text {
        if &actual.world_restore_economic_tuning_lane_value_f32_text != values {
            mismatches.push(format!(
                "world_restore_economic_tuning_lane_value_f32_text mismatch: expected {values:?}, got {:?}",
                actual.world_restore_economic_tuning_lane_value_f32_text
            ));
        }
    }
    if let Some(kind) = &expected.world_restore_absolute_counter_restore_kind {
        if actual.world_restore_absolute_counter_restore_kind.as_ref() != Some(kind) {
            mismatches.push(format!(
                "world_restore_absolute_counter_restore_kind mismatch: expected {kind:?}, got {:?}",
                actual.world_restore_absolute_counter_restore_kind
            ));
        }
    }
    if let Some(context) = &expected.world_restore_absolute_counter_adjustment_context {
        if actual
            .world_restore_absolute_counter_adjustment_context
            .as_ref()
            != Some(context)
        {
            mismatches.push(format!(
                "world_restore_absolute_counter_adjustment_context mismatch: expected {context:?}, got {:?}",
                actual.world_restore_absolute_counter_adjustment_context
            ));
        }
    }
    if let Some(count) = expected.metadata_count {
        if actual.metadata_count != count {
            mismatches.push(format!(
                "metadata_count mismatch: expected {count}, got {}",
                actual.metadata_count
            ));
        }
    }
    if let Some(count) = expected.company_count {
        if actual.company_count != count {
            mismatches.push(format!(
                "company_count mismatch: expected {count}, got {}",
                actual.company_count
            ));
        }
    }
    if let Some(count) = expected.active_company_count {
        if actual.active_company_count != count {
            mismatches.push(format!(
                "active_company_count mismatch: expected {count}, got {}",
                actual.active_company_count
            ));
        }
    }
    if let Some(count) = expected.company_market_state_owner_count {
        if actual.company_market_state_owner_count != count {
            mismatches.push(format!(
                "company_market_state_owner_count mismatch: expected {count}, got {}",
                actual.company_market_state_owner_count
            ));
        }
    }
}
