Merge branch 'character-mods' into summon-renewal
This commit is contained in:
commit
d343adeca3
1 changed files with 6 additions and 7 deletions
|
|
@ -21,17 +21,16 @@ module Api
|
||||||
conflict_view = render_conflict_view(conflict_characters, incoming_character, character_params[:position])
|
conflict_view = render_conflict_view(conflict_characters, incoming_character, character_params[:position])
|
||||||
render json: conflict_view
|
render json: conflict_view
|
||||||
else
|
else
|
||||||
# Replace the grid character in the position if it is already filled
|
# Destroy the grid character in the position if it is already filled
|
||||||
if GridCharacter.where(party_id: party.id, position: character_params[:position]).exists?
|
if GridCharacter.where(party_id: party.id, position: character_params[:position]).exists?
|
||||||
character = GridCharacter.where(party_id: party.id, position: character_params[:position]).limit(1)[0]
|
character = GridCharacter.where(party_id: party.id, position: character_params[:position]).limit(1)[0]
|
||||||
character.character_id = incoming_character.id
|
character.destroy
|
||||||
|
|
||||||
# Otherwise, create a new grid character
|
|
||||||
else
|
|
||||||
character = GridCharacter.create!(character_params.merge(party_id: party.id,
|
|
||||||
character_id: incoming_character.id))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Then, create a new grid character
|
||||||
|
character = GridCharacter.create!(character_params.merge(party_id: party.id,
|
||||||
|
character_id: incoming_character.id))
|
||||||
|
|
||||||
if character.save!
|
if character.save!
|
||||||
grid_character_view = render_grid_character_view(character)
|
grid_character_view = render_grid_character_view(character)
|
||||||
render json: grid_character_view, status: :created
|
render json: grid_character_view, status: :created
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue