update import service for weapon_stat_modifier fks and befoulments
This commit is contained in:
parent
62450304dc
commit
4ace9a9d49
1 changed files with 64 additions and 20 deletions
|
|
@ -33,6 +33,7 @@ class WeaponImportService
|
||||||
@skipped = []
|
@skipped = []
|
||||||
@errors = []
|
@errors = []
|
||||||
@awakening_cache = {}
|
@awakening_cache = {}
|
||||||
|
@modifier_cache = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
@ -146,9 +147,18 @@ class WeaponImportService
|
||||||
awakening_attrs = parse_awakening(param['arousal'])
|
awakening_attrs = parse_awakening(param['arousal'])
|
||||||
attrs.merge!(awakening_attrs) if awakening_attrs
|
attrs.merge!(awakening_attrs) if awakening_attrs
|
||||||
|
|
||||||
# Parse AX skills if present
|
# Check if this is an Odiant (befoulment) weapon
|
||||||
ax_attrs = parse_ax_skills(param['augment_skill_info'])
|
odiant = param['odiant']
|
||||||
attrs.merge!(ax_attrs) if ax_attrs
|
if odiant && odiant['is_odiant_weapon'] == true
|
||||||
|
# Parse befoulment from augment_skill_info
|
||||||
|
befoulment_attrs = parse_befoulment(param['augment_skill_info'])
|
||||||
|
attrs.merge!(befoulment_attrs) if befoulment_attrs
|
||||||
|
attrs[:exorcism_level] = odiant['exorcision_level'].to_i.clamp(0, 5)
|
||||||
|
else
|
||||||
|
# Regular weapon - parse AX skills
|
||||||
|
ax_attrs = parse_ax_skills(param['augment_skill_info'])
|
||||||
|
attrs.merge!(ax_attrs) if ax_attrs
|
||||||
|
end
|
||||||
|
|
||||||
attrs
|
attrs
|
||||||
end
|
end
|
||||||
|
|
@ -207,18 +217,18 @@ class WeaponImportService
|
||||||
|
|
||||||
# First AX skill
|
# First AX skill
|
||||||
if skills[0].is_a?(Hash)
|
if skills[0].is_a?(Hash)
|
||||||
ax1 = parse_single_ax_skill(skills[0])
|
ax1 = parse_single_augment_skill(skills[0])
|
||||||
if ax1
|
if ax1
|
||||||
attrs[:ax_modifier1] = ax1[:modifier]
|
attrs[:ax_modifier1_id] = ax1[:modifier_id]
|
||||||
attrs[:ax_strength1] = ax1[:strength]
|
attrs[:ax_strength1] = ax1[:strength]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Second AX skill
|
# Second AX skill
|
||||||
if skills[1].is_a?(Hash)
|
if skills[1].is_a?(Hash)
|
||||||
ax2 = parse_single_ax_skill(skills[1])
|
ax2 = parse_single_augment_skill(skills[1])
|
||||||
if ax2
|
if ax2
|
||||||
attrs[:ax_modifier2] = ax2[:modifier]
|
attrs[:ax_modifier2_id] = ax2[:modifier_id]
|
||||||
attrs[:ax_strength2] = ax2[:strength]
|
attrs[:ax_strength2] = ax2[:strength]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -227,26 +237,60 @@ class WeaponImportService
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Parses a single AX skill from game data.
|
# Parses befoulment data from game format.
|
||||||
|
# Odiant weapons have a single befoulment in augment_skill_info.
|
||||||
#
|
#
|
||||||
# @param skill [Hash] Single AX skill data with skill_id and effect_value
|
# @param augment_skill_info [Array] The game's augment skill data
|
||||||
# @return [Hash, nil] { modifier:, strength: } or nil
|
# @return [Hash, nil] Befoulment attributes or nil if no befoulment
|
||||||
def parse_single_ax_skill(skill)
|
def parse_befoulment(augment_skill_info)
|
||||||
return nil unless skill['skill_id'].present?
|
return nil if augment_skill_info.blank? || !augment_skill_info.is_a?(Array)
|
||||||
|
|
||||||
# The skill_id maps to our AX modifier
|
skills = augment_skill_info.first
|
||||||
modifier = skill['skill_id'].to_i
|
return nil if skills.blank? || !skills.is_a?(Array)
|
||||||
|
|
||||||
# Parse strength from effect_value (may be "3" or "1_3" format)
|
skill = skills.first
|
||||||
# or from show_value (may be "3%" format)
|
return nil unless skill.is_a?(Hash)
|
||||||
strength = parse_ax_strength(skill['effect_value'], skill['show_value'])
|
|
||||||
|
|
||||||
return nil unless strength
|
result = parse_single_augment_skill(skill)
|
||||||
|
return nil unless result
|
||||||
|
|
||||||
{ modifier: modifier, strength: strength }
|
{
|
||||||
|
befoulment_modifier_id: result[:modifier_id],
|
||||||
|
befoulment_strength: result[:strength]
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_ax_strength(effect_value, show_value)
|
##
|
||||||
|
# Parses a single augment skill (AX or befoulment) from game data.
|
||||||
|
#
|
||||||
|
# @param skill [Hash] Single skill data with skill_id and effect_value
|
||||||
|
# @return [Hash, nil] { modifier_id:, strength: } or nil
|
||||||
|
def parse_single_augment_skill(skill)
|
||||||
|
return nil unless skill['skill_id'].present?
|
||||||
|
|
||||||
|
game_skill_id = skill['skill_id'].to_i
|
||||||
|
modifier = find_modifier_by_game_skill_id(game_skill_id)
|
||||||
|
|
||||||
|
unless modifier
|
||||||
|
# Log unknown skill ID with icon for discovery
|
||||||
|
Rails.logger.warn(
|
||||||
|
"[WeaponImportService] Unknown augment skill_id=#{game_skill_id} " \
|
||||||
|
"icon=#{skill['augment_skill_icon_image']}"
|
||||||
|
)
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
strength = parse_augment_strength(skill['effect_value'], skill['show_value'])
|
||||||
|
return nil unless strength
|
||||||
|
|
||||||
|
{ modifier_id: modifier.id, strength: strength }
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_modifier_by_game_skill_id(game_skill_id)
|
||||||
|
@modifier_cache[game_skill_id] ||= WeaponStatModifier.find_by(game_skill_id: game_skill_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_augment_strength(effect_value, show_value)
|
||||||
# Try effect_value first
|
# Try effect_value first
|
||||||
if effect_value.present?
|
if effect_value.present?
|
||||||
# Handle "1_3" format (seems to be "tier_value")
|
# Handle "1_3" format (seems to be "tier_value")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue