(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:
Justin Edmund 2023-06-21 01:10:05 -07:00 committed by GitHub
parent 0befd788fc
commit e588b81d4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -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

View file

@ -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 } }