Skip to content

Commit

Permalink
chore(scdata): update loadout key
Browse files Browse the repository at this point in the history
  • Loading branch information
mortik committed May 16, 2024
1 parent 4873aa9 commit e500fb2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/lib/sc_data/hardpoints_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ def extract_from_components(model, components)

component_data = port_data["InstalledItem"] || {}

key = [key_modifier, hardpoint_type, category, size].compact.join("-")
loadout_key = extract_loadout_key(hardpoint_type, category, component_data)

key = [key_modifier, hardpoint_type, category, size, loadout_key].compact.join("-")

hardpoint = ModelHardpoint.find_or_create_by!(
source: :game_files,
Expand Down Expand Up @@ -233,6 +235,15 @@ def extract_from_components(model, components)
end.first
end

private def extract_loadout_key(hardpoint_type, category, component_data)
return unless %i[turrets].include?(hardpoint_type) && %w[manned_missile_turrets remote_missile_turrets].include?(category)

[
component_data.dig("InstalledItem", "Ports")&.size,
component_data.dig("InstalledItem", "Ports", 0, "Loadout") || component_data.dig("InstalledItem", "Ports", 0, "InstalledItem", "Name")
].compact.join("-")
end

private def category_for_thruster_mapping(port_data)
thruster_loadout_type = port_data.dig("InstalledItem", "Type")

Expand Down

0 comments on commit e500fb2

Please sign in to comment.