Merge branch 'main' into character-mods
This commit is contained in:
commit
3f914d3be7
2 changed files with 27 additions and 18 deletions
|
|
@ -115,15 +115,15 @@ module Api
|
||||||
# Render the conflict view as a string
|
# Render the conflict view as a string
|
||||||
def render_conflict_view(conflict_weapon, incoming_weapon, incoming_position)
|
def render_conflict_view(conflict_weapon, incoming_weapon, incoming_position)
|
||||||
ConflictBlueprint.render(nil, view: :weapons,
|
ConflictBlueprint.render(nil, view: :weapons,
|
||||||
conflict_weapon: conflict_weapon,
|
conflict_weapon: conflict_weapon,
|
||||||
incoming_weapon: incoming_weapon,
|
incoming_weapon: incoming_weapon,
|
||||||
incoming_position: incoming_position)
|
incoming_position: incoming_position)
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_grid_weapon_view(grid_weapon, conflict_position)
|
def render_grid_weapon_view(grid_weapon, conflict_position)
|
||||||
GridWeaponBlueprint.render(grid_weapon, view: :full,
|
GridWeaponBlueprint.render(grid_weapon, view: :full,
|
||||||
root: :grid_weapon,
|
root: :grid_weapon,
|
||||||
meta: { replaced: conflict_position })
|
meta: { replaced: conflict_position })
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_weapon(weapon)
|
def save_weapon(weapon)
|
||||||
|
|
@ -140,6 +140,9 @@ module Api
|
||||||
if weapon.position == -1
|
if weapon.position == -1
|
||||||
party.element = weapon.weapon.element
|
party.element = weapon.weapon.element
|
||||||
party.save!
|
party.save!
|
||||||
|
elsif [9, 10, 11].include?(weapon.position)
|
||||||
|
party.extra = true
|
||||||
|
party.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
# Render the weapon if it can be saved
|
# Render the weapon if it can be saved
|
||||||
|
|
|
||||||
|
|
@ -8,22 +8,28 @@ module Api
|
||||||
before_action :set, only: %w[update destroy]
|
before_action :set, only: %w[update destroy]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@party = Party.new(shortcode: random_string)
|
party = Party.new(shortcode: random_string)
|
||||||
@party.extra = party_params['extra']
|
party.user = current_user if current_user
|
||||||
|
|
||||||
# TODO: Extract this into a different method
|
if party_params
|
||||||
job = Job.find(party_params['job_id']) if party_params['job_id'].present?
|
party.attributes = party_params
|
||||||
if job
|
|
||||||
job_skills = JobSkill.where(job: job.id, main: true)
|
|
||||||
job_skills.each_with_index do |skill, index|
|
|
||||||
@party["skill#{index}_id"] = skill.id
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@party.user = current_user if current_user
|
# unless party_params.empty?
|
||||||
|
# party.attributes = party_params
|
||||||
|
#
|
||||||
|
# # TODO: Extract this into a different method
|
||||||
|
# job = Job.find(party_params['job_id']) if party_params['job_id'].present?
|
||||||
|
# if job
|
||||||
|
# job_skills = JobSkill.where(job: job.id, main: true)
|
||||||
|
# job_skills.each_with_index do |skill, index|
|
||||||
|
# party["skill#{index}_id"] = skill.id
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
if @party.save!
|
if party.save!
|
||||||
return render json: PartyBlueprint.render(@party, view: :full, root: :party),
|
return render json: PartyBlueprint.render(party, view: :full, root: :party),
|
||||||
status: :created
|
status: :created
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -150,7 +156,7 @@ module Api
|
||||||
:button_count,
|
:button_count,
|
||||||
:turn_count,
|
:turn_count,
|
||||||
:chain_count
|
:chain_count
|
||||||
)
|
) if params[:party].present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue