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:
parent
3b9eab8b79
commit
86e5b9fffb
2 changed files with 30 additions and 10 deletions
|
|
@ -18,13 +18,33 @@ module Api
|
||||||
end
|
end
|
||||||
|
|
||||||
field :skills do |obj|
|
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 == {}
|
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'],
|
modifier: modifier,
|
||||||
strength: skill['strength'],
|
strength: strength,
|
||||||
level: skill['level']
|
level: level
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,11 @@ module ArtifactSkillValidations
|
||||||
return if quirk_artifact?
|
return if quirk_artifact?
|
||||||
|
|
||||||
modifier = skill_data['modifier']
|
modifier = skill_data['modifier']
|
||||||
strength = skill_data['strength']
|
quality = skill_data['quality']
|
||||||
skill_level = skill_data['level']
|
skill_level = skill_data['level']
|
||||||
|
|
||||||
unless modifier && strength && skill_level
|
unless modifier && quality && skill_level
|
||||||
errors.add(slot_name, 'must have modifier, strength, and level')
|
errors.add(slot_name, 'must have modifier, quality, and level')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -43,9 +43,9 @@ module ArtifactSkillValidations
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# Validate strength is a valid base value for this skill
|
# Validate quality is in valid range (1-5)
|
||||||
unless skill_def.valid_strength?(strength)
|
unless (1..5).cover?(quality)
|
||||||
errors.add(slot_name, "has invalid base strength #{strength}")
|
errors.add(slot_name, "has invalid quality #{quality}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue