Merge pull request #47 from jedmund/transcendence

Adds support for transcendence
This commit is contained in:
Justin Edmund 2023-01-22 23:14:40 -08:00 committed by GitHub
commit 0797306569
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 12 deletions

View file

@ -5,11 +5,11 @@ module Api
class GridSummonBlueprint < ApiBlueprint
view :uncap do
association :party, blueprint: PartyBlueprint, view: :minimal
fields :position, :uncap_level
fields :position, :uncap_level, :transcendence_step
end
view :nested do
fields :main, :friend, :position, :uncap_level
fields :main, :friend, :position, :uncap_level, :transcendence_step
association :summon, name: :object, blueprint: SummonBlueprint
end

View file

@ -47,13 +47,9 @@ module Api
@character.attributes = character_params.merge(mastery)
if @character.save
ap 'Saved character'
return render json: GridCharacterBlueprint.render(@character, view: :full) if @character.save
else
ap 'Could not save'
render_validation_error_response(@character)
end
return render json: GridCharacterBlueprint.render(@character, view: :full) if @character.save
render_validation_error_response(@character)
end
def resolve
@ -89,6 +85,7 @@ module Api
render_unauthorized_response if current_user && (character.party.user != current_user)
character.uncap_level = character_params[:uncap_level]
character.transcendence_step = character_params[:transcendence_step]
return unless character.save!
render json: GridCharacterBlueprint.render(character, view: :nested, root: :grid_character)

View file

@ -3,7 +3,7 @@
module Api
module V1
class GridSummonsController < Api::V1::ApiController
before_action :set, only: %w[destroy]
before_action :set, only: %w[update destroy]
attr_reader :party, :incoming_summon
@ -24,6 +24,14 @@ module Api
end
end
def update
@summon.attributes = summon_params
return render json: GridSummonBlueprint.render(@summon, view: :nested, root: :grid_summon) if @summon.save
render_validation_error_response(@character)
end
def save_summon(summon)
if (grid_summon = GridSummon.where(
party_id: party.id,
@ -57,6 +65,8 @@ module Api
render_unauthorized_response if current_user && (summon.party.user != current_user)
summon.uncap_level = summon_params[:uncap_level]
summon.transcendence_step = 0
return unless summon.save!
render json: GridSummonBlueprint.render(summon, view: :nested, root: :grid_summon)
@ -91,7 +101,8 @@ module Api
# Specify whitelisted properties that can be modified.
def summon_params
params.require(:summon).permit(:id, :party_id, :summon_id, :position, :main, :friend, :uncap_level)
params.require(:summon).permit(:id, :party_id, :summon_id, :position, :main, :friend, :uncap_level,
:transcendence_step)
end
end
end

View file

@ -10,7 +10,7 @@ Rails.application.routes.draw do
resources :users, only: %i[create update show]
resources :grid_weapons, only: %i[update destroy]
resources :grid_characters, only: %i[update destroy]
resources :grid_summons, only: %i[destroy]
resources :grid_summons, only: %i[update destroy]
resources :favorites, only: [:create]
get 'users/info/:id', to: 'users#info'

View file

@ -36,6 +36,11 @@ namespace :granblue do
f.write("#{build_summon_url("#{s.granblue_id}_02",
size)} \n")
end
if s.xlb
f.write("#{build_summon_url("#{s.granblue_id}_03",
size)} \n")
end
end
end