Ensure new characters have Awakenings

Every character starts with Balanced Lv1 awakening
This commit is contained in:
Justin Edmund 2023-06-21 01:07:45 -07:00
parent a66f115678
commit d1979358d2

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