GridWeapon decides if it is mainhand or not
This commit is contained in:
parent
2dd6dbae57
commit
260ca449a7
2 changed files with 12 additions and 0 deletions
|
|
@ -167,6 +167,7 @@ module Api
|
||||||
output = render_conflict_view([conflict_weapon], incoming_weapon, weapon_params[:position])
|
output = render_conflict_view([conflict_weapon], incoming_weapon, weapon_params[:position])
|
||||||
render json: output
|
render json: output
|
||||||
else
|
else
|
||||||
|
ap "Moving weapon to new position..."
|
||||||
# Move the original grid weapon to the new position
|
# Move the original grid weapon to the new position
|
||||||
# to preserve keys and other modifications
|
# to preserve keys and other modifications
|
||||||
old_position = conflict_weapon.position
|
old_position = conflict_weapon.position
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ class GridWeapon < ApplicationRecord
|
||||||
validate :compatible_with_position, on: :create
|
validate :compatible_with_position, on: :create
|
||||||
validate :no_conflicts, on: :create
|
validate :no_conflicts, on: :create
|
||||||
|
|
||||||
|
before_save :is_mainhand
|
||||||
|
|
||||||
##### Amoeba configuration
|
##### Amoeba configuration
|
||||||
amoeba do
|
amoeba do
|
||||||
nullify :ax_modifier1
|
nullify :ax_modifier1
|
||||||
|
|
@ -71,4 +73,13 @@ class GridWeapon < ApplicationRecord
|
||||||
# Check if the grid weapon conflicts with any of the other grid weapons in the party
|
# Check if the grid weapon conflicts with any of the other grid weapons in the party
|
||||||
errors.add(:series, 'must not conflict with existing weapons') unless conflicts(party).nil?
|
errors.add(:series, 'must not conflict with existing weapons') unless conflicts(party).nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Checks if the weapon should be a mainhand before saving the model
|
||||||
|
def is_mainhand
|
||||||
|
if self.position == -1
|
||||||
|
self.mainhand = true
|
||||||
|
else
|
||||||
|
self.mainhand = false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue