(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
This commit is contained in:
parent
17cdd4cf2c
commit
251d7f708e
3 changed files with 12 additions and 9 deletions
|
|
@ -18,8 +18,8 @@ module Api
|
|||
end
|
||||
|
||||
view :weapons do
|
||||
field :conflicts, if: ->(_fn, _obj, options) { options.key?(:conflict_weapon) } do |_, options|
|
||||
GridWeaponBlueprint.render_as_hash(options[:conflict_weapon], view: :nested)
|
||||
field :conflicts, if: ->(_fn, _obj, options) { options.key?(:conflict_weapons) } do |_, options|
|
||||
GridWeaponBlueprint.render_as_hash(options[:conflict_weapons], view: :nested)
|
||||
end
|
||||
|
||||
field :incoming, if: ->(_fn, _obj, options) { options.key?(:incoming_weapon) } do |_, options|
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ module Api
|
|||
association :weapon_keys,
|
||||
blueprint: WeaponKeyBlueprint,
|
||||
if: lambda { |_field_name, w, _options|
|
||||
[2, 3, 17, 24].include?(w.weapon.series)
|
||||
[2, 3, 17, 24, 34].include?(w.weapon.series)
|
||||
}
|
||||
|
||||
field :ax, if: ->(_field_name, w, _options) { w.weapon.ax } do |w|
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ module Api
|
|||
|
||||
# Check if the incoming weapon is compatible with the specified position
|
||||
def compatible_with_position?(incoming_weapon, position)
|
||||
false if [9, 10, 11].include?(position.to_i) && ![11, 16, 17, 28, 29].include?(incoming_weapon.series)
|
||||
false if [9, 10, 11].include?(position.to_i) && ![11, 16, 17, 28, 29, 34].include?(incoming_weapon.series)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
@ -126,9 +126,9 @@ module Api
|
|||
end
|
||||
|
||||
# Render the conflict view as a string
|
||||
def render_conflict_view(conflict_weapon, incoming_weapon, incoming_position)
|
||||
def render_conflict_view(conflict_weapons, incoming_weapon, incoming_position)
|
||||
ConflictBlueprint.render(nil, view: :weapons,
|
||||
conflict_weapon: conflict_weapon,
|
||||
conflict_weapons: conflict_weapons,
|
||||
incoming_weapon: incoming_weapon,
|
||||
incoming_position: incoming_position)
|
||||
end
|
||||
|
|
@ -166,12 +166,15 @@ module Api
|
|||
end
|
||||
|
||||
def handle_conflict(weapon)
|
||||
conflict_weapon = weapon.conflicts(party)
|
||||
|
||||
if conflict_weapon.weapon.id != incoming_weapon.id
|
||||
conflict_weapons = weapon.conflicts(party)
|
||||
|
||||
# Map conflict weapon IDs into an array
|
||||
conflict_weapon_ids = conflict_weapons.map(&:id)
|
||||
if conflict_weapon_ids.include?(incoming_weapon.id)
|
||||
# Render conflict view if the underlying canonical weapons
|
||||
# are not identical
|
||||
output = render_conflict_view([conflict_weapon], incoming_weapon, weapon_params[:position])
|
||||
output = render_conflict_view(conflict_weapons, incoming_weapon, weapon_params[:position])
|
||||
render json: output
|
||||
else
|
||||
# Move the original grid weapon to the new position
|
||||
|
|
|
|||
Loading…
Reference in a new issue