(Hotfix) Fix awakening-related API errors (#108)
* Remove print statements from data migration * (Hotfix) Fix data migration failing due to nil * Fix stale migration errors * Ensure new characters have Awakenings Every character starts with Balanced Lv1 awakening * Ensure weapons without awakenings do not expose key
This commit is contained in:
parent
0befd788fc
commit
e588b81d4a
2 changed files with 10 additions and 1 deletions
|
|
@ -39,7 +39,7 @@ module Api
|
|||
}
|
||||
end
|
||||
|
||||
field :awakenings, if: ->(_field_name, w, _options) { w.awakenings } do |w|
|
||||
field :awakenings, if: lambda { |_fn, obj, _opt| obj.awakenings.length.positive? } do |w|
|
||||
w.awakenings.map do |a|
|
||||
AwakeningBlueprint.render_as_hash(a)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ class GridCharacter < ApplicationRecord
|
|||
set perpetuity: false
|
||||
end
|
||||
|
||||
# Add awakening before the model saves
|
||||
before_save :add_awakening
|
||||
|
||||
def validate_awakening_level
|
||||
errors.add(:awakening, 'awakening level too low') if awakening_level < 1
|
||||
errors.add(:awakening, 'awakening level too high') if awakening_level > 9
|
||||
|
|
@ -83,6 +86,12 @@ class GridCharacter < ApplicationRecord
|
|||
|
||||
private
|
||||
|
||||
def add_awakening
|
||||
if self.awakening.nil?
|
||||
self.awakening = Awakening.where(slug: "character-balanced").sole
|
||||
end
|
||||
end
|
||||
|
||||
def check_value(property, type)
|
||||
# Input format
|
||||
# { ring1: { atk: 300 } }
|
||||
|
|
|
|||
Loading…
Reference in a new issue