Disallow adding arbitrary weapons to Extra slots
This commit is contained in:
parent
ec25230bc5
commit
adbb5b6c7d
3 changed files with 32 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ module Api
|
||||||
rescue_from Api::V1::FavoriteAlreadyExistsError, with: :render_unprocessable_entity_response
|
rescue_from Api::V1::FavoriteAlreadyExistsError, with: :render_unprocessable_entity_response
|
||||||
rescue_from Api::V1::NoJobProvidedError, with: :render_unprocessable_entity_response
|
rescue_from Api::V1::NoJobProvidedError, with: :render_unprocessable_entity_response
|
||||||
rescue_from Api::V1::TooManySkillsOfTypeError, with: :render_unprocessable_entity_response
|
rescue_from Api::V1::TooManySkillsOfTypeError, with: :render_unprocessable_entity_response
|
||||||
|
rescue_from Api::V1::IncompatibleWeaponForPositionError, with: :render_unprocessable_entity_response
|
||||||
rescue_from Api::V1::UnauthorizedError, with: :render_unauthorized_response
|
rescue_from Api::V1::UnauthorizedError, with: :render_unauthorized_response
|
||||||
rescue_from ActionController::ParameterMissing, with: :render_unprocessable_entity_response
|
rescue_from ActionController::ParameterMissing, with: :render_unprocessable_entity_response
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@ module Api
|
||||||
# Set up conflict_position in case it is used
|
# Set up conflict_position in case it is used
|
||||||
conflict_position = nil
|
conflict_position = nil
|
||||||
|
|
||||||
|
if [9, 10, 11].include?(weapon_params[:position].to_i) && ![11, 16, 17, 28, 29].include?(incoming_weapon.series)
|
||||||
|
raise Api::V1::IncompatibleWeaponForPositionError.new(weapon: incoming_weapon)
|
||||||
|
end
|
||||||
|
|
||||||
# 1. If the weapon has a limit
|
# 1. If the weapon has a limit
|
||||||
# 2. If the weapon does not match a weapon already in grid
|
# 2. If the weapon does not match a weapon already in grid
|
||||||
# 3. If the incoming weapon has a limit and other weapons of the same series are in grid
|
# 3. If the incoming weapon has a limit and other weapons of the same series are in grid
|
||||||
|
|
|
||||||
27
app/errors/api/v1/incompatible_weapon_for_position_error.rb
Normal file
27
app/errors/api/v1/incompatible_weapon_for_position_error.rb
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Api
|
||||||
|
module V1
|
||||||
|
class IncompatibleWeaponForPositionError < GranblueError
|
||||||
|
def http_status
|
||||||
|
422
|
||||||
|
end
|
||||||
|
|
||||||
|
def code
|
||||||
|
'incompatible_weapon_for_position'
|
||||||
|
end
|
||||||
|
|
||||||
|
def message
|
||||||
|
'A weapon of this series cannot be added to Additional Weapons'
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_hash
|
||||||
|
{
|
||||||
|
message: message,
|
||||||
|
code: code,
|
||||||
|
weapon: @data[:weapon]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue