compute strength from quality at display time

blueprint looks up skill and calculates strength
validation checks quality range instead of strength value
This commit is contained in:
Justin Edmund 2025-12-18 22:30:44 -08:00
parent 3b9eab8b79
commit 86e5b9fffb
2 changed files with 30 additions and 10 deletions

View file

@ -18,13 +18,33 @@ module Api
end
field :skills do |obj|
[obj.skill1, obj.skill2, obj.skill3, obj.skill4].map do |skill|
[
[obj.skill1, 1],
[obj.skill2, 2],
[obj.skill3, 3],
[obj.skill4, 4]
].map do |skill, slot|
next nil if skill.blank? || skill == {}
# Determine skill group based on slot
group = case slot
when 1, 2 then 1 # Group I
when 3 then 2 # Group II
when 4 then 3 # Group III
end
# Look up skill and compute strength from quality
modifier = skill['modifier']
quality = skill['quality'] || 1
level = skill['level'] || 1
artifact_skill = ArtifactSkill.find_skill(group, modifier)
strength = artifact_skill&.strength_for_quality(quality)
{
modifier: skill['modifier'],
strength: skill['strength'],
level: skill['level']
modifier: modifier,
strength: strength,
level: level
}
end
end

View file

@ -24,11 +24,11 @@ module ArtifactSkillValidations
return if quirk_artifact?
modifier = skill_data['modifier']
strength = skill_data['strength']
quality = skill_data['quality']
skill_level = skill_data['level']
unless modifier && strength && skill_level
errors.add(slot_name, 'must have modifier, strength, and level')
unless modifier && quality && skill_level
errors.add(slot_name, 'must have modifier, quality, and level')
return
end
@ -43,9 +43,9 @@ module ArtifactSkillValidations
return
end
# Validate strength is a valid base value for this skill
unless skill_def.valid_strength?(strength)
errors.add(slot_name, "has invalid base strength #{strength}")
# Validate quality is in valid range (1-5)
unless (1..5).cover?(quality)
errors.add(slot_name, "has invalid quality #{quality}")
end
end