* Make weapon key series an array Draconic Weapons Providence can have original Draconic Weapon keys, but also have a new key that can only be equipped to them. Thanks, Cygames. * Update weapon.rb * Update to check key compatibility against an array instead of an int * Add convenience function to check if the weapon is part of a Draconic Weapon series * Update grid_weapon.rb Update conflict detection to: * Detect Draconic Weapons Providence * Add multiple weapons to conflicting weapons instead of just one * (WIP) Update conflict view rendering Conflict blueprints should render multiple conflict weapons instead of just one. Also adds Draconic Weapon Providence series to various places that check series by number * Finish last bugs We tested to ensure that conflict resolution appears for * Opus and Draconic * Draconic and Draconic 2 * Draconic 2 + Opus and Draconic 1
63 lines
1.7 KiB
Ruby
63 lines
1.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class Weapon < ApplicationRecord
|
|
include PgSearch::Model
|
|
|
|
multisearchable against: %i[name_en name_jp],
|
|
additional_attributes: lambda { |weapon|
|
|
{
|
|
name_en: weapon.name_en,
|
|
name_jp: weapon.name_jp,
|
|
nicknames_en: weapon.nicknames_en,
|
|
nicknames_jp: weapon.nicknames_jp,
|
|
granblue_id: weapon.granblue_id,
|
|
element: weapon.element
|
|
}
|
|
}
|
|
|
|
pg_search_scope :en_search,
|
|
against: %i[name_en nicknames_en],
|
|
using: {
|
|
tsearch: {
|
|
prefix: true,
|
|
dictionary: 'simple'
|
|
},
|
|
trigram: {
|
|
threshold: 0.18
|
|
}
|
|
}
|
|
|
|
pg_search_scope :ja_search,
|
|
against: %i[name_jp nicknames_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.include?(series)
|
|
end
|
|
|
|
# Returns whether the weapon is included in the Draconic or Dark Opus series
|
|
def opus_or_draconic?
|
|
[2, 3].include?(series)
|
|
end
|
|
|
|
# Returns whether the weapon belongs to the Draconic Weapon series or the Draconic Weapon Providence series
|
|
def draconic_or_providence?
|
|
[3, 34].include?(series)
|
|
end
|
|
end
|