parent
b5f9889c00
commit
3f734a0389
3 changed files with 8 additions and 10 deletions
|
|
@ -1,8 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class GridCharacter < ApplicationRecord
|
||||
has_one :object, class_name: 'Character', foreign_key: :id, primary_key: :character_id
|
||||
|
||||
belongs_to :awakening, optional: true
|
||||
belongs_to :party,
|
||||
counter_cache: :characters_count,
|
||||
|
|
@ -89,9 +87,9 @@ class GridCharacter < ApplicationRecord
|
|||
private
|
||||
|
||||
def add_awakening
|
||||
return unless awakening.nil?
|
||||
|
||||
self.awakening = Awakening.where(slug: 'character-balanced').sole
|
||||
if self.awakening.nil?
|
||||
self.awakening = Awakening.where(slug: "character-balanced").sole
|
||||
end
|
||||
end
|
||||
|
||||
def check_value(property, type)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ class GridSummon < ApplicationRecord
|
|||
counter_cache: :summons_count,
|
||||
inverse_of: :summons
|
||||
validates_presence_of :party
|
||||
has_one :object, class_name: 'Summon', foreign_key: :id, primary_key: :summon_id
|
||||
|
||||
validate :compatible_with_position, on: :create
|
||||
validate :no_conflicts, on: :create
|
||||
|
|
@ -24,7 +23,6 @@ class GridSummon < ApplicationRecord
|
|||
|
||||
party.summons.find do |grid_summon|
|
||||
return unless grid_summon.id
|
||||
|
||||
grid_summon if summon.id == grid_summon.summon.id
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ class GridWeapon < ApplicationRecord
|
|||
inverse_of: :weapons
|
||||
validates_presence_of :party
|
||||
|
||||
has_one :object, class_name: 'Weapon', foreign_key: :id, primary_key: :weapon_id
|
||||
|
||||
belongs_to :weapon_key1, class_name: 'WeaponKey', foreign_key: :weapon_key1_id, optional: true
|
||||
belongs_to :weapon_key2, class_name: 'WeaponKey', foreign_key: :weapon_key2_id, optional: true
|
||||
belongs_to :weapon_key3, class_name: 'WeaponKey', foreign_key: :weapon_key3_id, optional: true
|
||||
|
|
@ -80,6 +78,10 @@ class GridWeapon < ApplicationRecord
|
|||
|
||||
# Checks if the weapon should be a mainhand before saving the model
|
||||
def is_mainhand
|
||||
self.mainhand = position == -1
|
||||
if self.position == -1
|
||||
self.mainhand = true
|
||||
else
|
||||
self.mainhand = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue