use rrt_runtime::summary::RuntimeSummary;

use crate::schema::ExpectedRuntimeSummary;

pub(super) fn compare_collections_prefix(
    expected: &ExpectedRuntimeSummary,
    actual: &RuntimeSummary,
    mismatches: &mut Vec<String>,
) {
    if let Some(count) = expected.player_count {
        if actual.player_count != count {
            mismatches.push(format!(
                "player_count mismatch: expected {count}, got {}",
                actual.player_count
            ));
        }
    }
    if let Some(count) = expected.chairman_profile_count {
        if actual.chairman_profile_count != count {
            mismatches.push(format!(
                "chairman_profile_count mismatch: expected {count}, got {}",
                actual.chairman_profile_count
            ));
        }
    }
    if let Some(count) = expected.active_chairman_profile_count {
        if actual.active_chairman_profile_count != count {
            mismatches.push(format!(
                "active_chairman_profile_count mismatch: expected {count}, got {}",
                actual.active_chairman_profile_count
            ));
        }
    }
    if let Some(selected_id) = expected.selected_chairman_profile_id {
        if actual.selected_chairman_profile_id != Some(selected_id) {
            mismatches.push(format!(
                "selected_chairman_profile_id mismatch: expected {selected_id:?}, got {:?}",
                actual.selected_chairman_profile_id
            ));
        }
    }
    if let Some(count) = expected.linked_chairman_company_count {
        if actual.linked_chairman_company_count != count {
            mismatches.push(format!(
                "linked_chairman_company_count mismatch: expected {count}, got {}",
                actual.linked_chairman_company_count
            ));
        }
    }
    if let Some(count) = expected.company_takeover_cooldown_count {
        if actual.company_takeover_cooldown_count != count {
            mismatches.push(format!(
                "company_takeover_cooldown_count mismatch: expected {count}, got {}",
                actual.company_takeover_cooldown_count
            ));
        }
    }
    if let Some(count) = expected.company_merger_cooldown_count {
        if actual.company_merger_cooldown_count != count {
            mismatches.push(format!(
                "company_merger_cooldown_count mismatch: expected {count}, got {}",
                actual.company_merger_cooldown_count
            ));
        }
    }
    if let Some(count) = expected.train_count {
        if actual.train_count != count {
            mismatches.push(format!(
                "train_count mismatch: expected {count}, got {}",
                actual.train_count
            ));
        }
    }
    if let Some(count) = expected.active_train_count {
        if actual.active_train_count != count {
            mismatches.push(format!(
                "active_train_count mismatch: expected {count}, got {}",
                actual.active_train_count
            ));
        }
    }
    if let Some(count) = expected.retired_train_count {
        if actual.retired_train_count != count {
            mismatches.push(format!(
                "retired_train_count mismatch: expected {count}, got {}",
                actual.retired_train_count
            ));
        }
    }
    if let Some(count) = expected.locomotive_catalog_count {
        if actual.locomotive_catalog_count != count {
            mismatches.push(format!(
                "locomotive_catalog_count mismatch: expected {count}, got {}",
                actual.locomotive_catalog_count
            ));
        }
    }
    if let Some(count) = expected.cargo_catalog_count {
        if actual.cargo_catalog_count != count {
            mismatches.push(format!(
                "cargo_catalog_count mismatch: expected {count}, got {}",
                actual.cargo_catalog_count
            ));
        }
    }
    if let Some(count) = expected.territory_count {
        if actual.territory_count != count {
            mismatches.push(format!(
                "territory_count mismatch: expected {count}, got {}",
                actual.territory_count
            ));
        }
    }
    if let Some(count) = expected.company_territory_track_count {
        if actual.company_territory_track_count != count {
            mismatches.push(format!(
                "company_territory_track_count mismatch: expected {count}, got {}",
                actual.company_territory_track_count
            ));
        }
    }
}

pub(super) fn compare_collections_suffix(
    expected: &ExpectedRuntimeSummary,
    actual: &RuntimeSummary,
    mismatches: &mut Vec<String>,
) {
    if let Some(count) = expected.event_runtime_record_count {
        if actual.event_runtime_record_count != count {
            mismatches.push(format!(
                "event_runtime_record_count mismatch: expected {count}, got {}",
                actual.event_runtime_record_count
            ));
        }
    }
    if let Some(count) = expected.candidate_availability_count {
        if actual.candidate_availability_count != count {
            mismatches.push(format!(
                "candidate_availability_count mismatch: expected {count}, got {}",
                actual.candidate_availability_count
            ));
        }
    }
    if let Some(count) = expected.zero_candidate_availability_count {
        if actual.zero_candidate_availability_count != count {
            mismatches.push(format!(
                "zero_candidate_availability_count mismatch: expected {count}, got {}",
                actual.zero_candidate_availability_count
            ));
        }
    }
    if let Some(count) = expected.named_locomotive_availability_count {
        if actual.named_locomotive_availability_count != count {
            mismatches.push(format!(
                "named_locomotive_availability_count mismatch: expected {count}, got {}",
                actual.named_locomotive_availability_count
            ));
        }
    }
    if let Some(count) = expected.zero_named_locomotive_availability_count {
        if actual.zero_named_locomotive_availability_count != count {
            mismatches.push(format!(
                "zero_named_locomotive_availability_count mismatch: expected {count}, got {}",
                actual.zero_named_locomotive_availability_count
            ));
        }
    }
    if let Some(count) = expected.named_locomotive_cost_count {
        if actual.named_locomotive_cost_count != count {
            mismatches.push(format!(
                "named_locomotive_cost_count mismatch: expected {count}, got {}",
                actual.named_locomotive_cost_count
            ));
        }
    }
    if let Some(count) = expected.cargo_production_override_count {
        if actual.cargo_production_override_count != count {
            mismatches.push(format!(
                "cargo_production_override_count mismatch: expected {count}, got {}",
                actual.cargo_production_override_count
            ));
        }
    }
    if let Some(count) = expected.world_runtime_variable_count {
        if actual.world_runtime_variable_count != count {
            mismatches.push(format!(
                "world_runtime_variable_count mismatch: expected {count}, got {}",
                actual.world_runtime_variable_count
            ));
        }
    }
    if let Some(count) = expected.company_runtime_variable_owner_count {
        if actual.company_runtime_variable_owner_count != count {
            mismatches.push(format!(
                "company_runtime_variable_owner_count mismatch: expected {count}, got {}",
                actual.company_runtime_variable_owner_count
            ));
        }
    }
    if let Some(count) = expected.player_runtime_variable_owner_count {
        if actual.player_runtime_variable_owner_count != count {
            mismatches.push(format!(
                "player_runtime_variable_owner_count mismatch: expected {count}, got {}",
                actual.player_runtime_variable_owner_count
            ));
        }
    }
    if let Some(count) = expected.territory_runtime_variable_owner_count {
        if actual.territory_runtime_variable_owner_count != count {
            mismatches.push(format!(
                "territory_runtime_variable_owner_count mismatch: expected {count}, got {}",
                actual.territory_runtime_variable_owner_count
            ));
        }
    }
    if let Some(count) = expected.world_scalar_override_count {
        if actual.world_scalar_override_count != count {
            mismatches.push(format!(
                "world_scalar_override_count mismatch: expected {count}, got {}",
                actual.world_scalar_override_count
            ));
        }
    }
    if let Some(count) = expected.special_condition_count {
        if actual.special_condition_count != count {
            mismatches.push(format!(
                "special_condition_count mismatch: expected {count}, got {}",
                actual.special_condition_count
            ));
        }
    }
    if let Some(count) = expected.enabled_special_condition_count {
        if actual.enabled_special_condition_count != count {
            mismatches.push(format!(
                "enabled_special_condition_count mismatch: expected {count}, got {}",
                actual.enabled_special_condition_count
            ));
        }
    }
    if let Some(kind) = &expected.save_profile_kind {
        if actual.save_profile_kind.as_ref() != Some(kind) {
            mismatches.push(format!(
                "save_profile_kind mismatch: expected {kind:?}, got {:?}",
                actual.save_profile_kind
            ));
        }
    }
    if let Some(family) = &expected.save_profile_family {
        if actual.save_profile_family.as_ref() != Some(family) {
            mismatches.push(format!(
                "save_profile_family mismatch: expected {family:?}, got {:?}",
                actual.save_profile_family
            ));
        }
    }
    if let Some(map_path) = &expected.save_profile_map_path {
        if actual.save_profile_map_path.as_ref() != Some(map_path) {
            mismatches.push(format!(
                "save_profile_map_path mismatch: expected {map_path:?}, got {:?}",
                actual.save_profile_map_path
            ));
        }
    }
    if let Some(display_name) = &expected.save_profile_display_name {
        if actual.save_profile_display_name.as_ref() != Some(display_name) {
            mismatches.push(format!(
                "save_profile_display_name mismatch: expected {display_name:?}, got {:?}",
                actual.save_profile_display_name
            ));
        }
    }
    if let Some(lane) = expected.save_profile_selected_year_profile_lane {
        if actual.save_profile_selected_year_profile_lane != Some(lane) {
            mismatches.push(format!(
                "save_profile_selected_year_profile_lane mismatch: expected {lane}, got {:?}",
                actual.save_profile_selected_year_profile_lane
            ));
        }
    }
    if let Some(enabled) = expected.save_profile_sandbox_enabled {
        if actual.save_profile_sandbox_enabled != Some(enabled) {
            mismatches.push(format!(
                "save_profile_sandbox_enabled mismatch: expected {enabled}, got {:?}",
                actual.save_profile_sandbox_enabled
            ));
        }
    }
    if let Some(enabled) = expected.save_profile_campaign_scenario_enabled {
        if actual.save_profile_campaign_scenario_enabled != Some(enabled) {
            mismatches.push(format!(
                "save_profile_campaign_scenario_enabled mismatch: expected {enabled}, got {:?}",
                actual.save_profile_campaign_scenario_enabled
            ));
        }
    }
    if let Some(enabled) = expected.save_profile_staged_profile_copy_on_restore {
        if actual.save_profile_staged_profile_copy_on_restore != Some(enabled) {
            mismatches.push(format!(
                "save_profile_staged_profile_copy_on_restore mismatch: expected {enabled}, got {:?}",
                actual.save_profile_staged_profile_copy_on_restore
            ));
        }
    }
    if let Some(count) = expected.total_event_record_service_count {
        if actual.total_event_record_service_count != count {
            mismatches.push(format!(
                "total_event_record_service_count mismatch: expected {count}, got {}",
                actual.total_event_record_service_count
            ));
        }
    }
    if let Some(count) = expected.periodic_boundary_call_count {
        if actual.periodic_boundary_call_count != count {
            mismatches.push(format!(
                "periodic_boundary_call_count mismatch: expected {count}, got {}",
                actual.periodic_boundary_call_count
            ));
        }
    }
    if let Some(count) = expected.total_trigger_dispatch_count {
        if actual.total_trigger_dispatch_count != count {
            mismatches.push(format!(
                "total_trigger_dispatch_count mismatch: expected {count}, got {}",
                actual.total_trigger_dispatch_count
            ));
        }
    }
    if let Some(count) = expected.dirty_rerun_count {
        if actual.dirty_rerun_count != count {
            mismatches.push(format!(
                "dirty_rerun_count mismatch: expected {count}, got {}",
                actual.dirty_rerun_count
            ));
        }
    }
    if let Some(total) = expected.total_company_cash {
        if actual.total_company_cash != total {
            mismatches.push(format!(
                "total_company_cash mismatch: expected {total}, got {}",
                actual.total_company_cash
            ));
        }
    }
}
