hensei-api/app/models/weapon.rb
Justin Edmund 9ac60b1949 Add and update models
This updates models for the awakening update.

* Awakening and WeaponAwakening models were added
* Weapon, GridWeapon and GridCharacter models get relationships to the new models defined
* GridCharacter had a validation on `awakening_level` that needed to be fixed
2023-06-19 00:30:54 -07:00

42 lines
932 B
Ruby

# frozen_string_literal: true
class Weapon < ApplicationRecord
include PgSearch::Model
pg_search_scope :en_search,
against: :name_en,
using: {
trigram: {
threshold: 0.18
}
}
pg_search_scope :ja_search,
against: :name_jp,
using: {
tsearch: {
prefix: true,
dictionary: 'simple'
}
}
has_many :weapon_awakenings
has_many :awakenings, through: :weapon_awakenings
def blueprint
WeaponBlueprint
end
def display_resource(weapon)
weapon.name_en
end
def compatible_with_key?(key)
key.series == series
end
# Returns whether the weapon is included in the Draconic or Dark Opus series
def opus_or_draconic?
[2, 3].include?(series)
end
end