* Move app/helpers/granblue_wiki to lib/parsers/wiki This clears up the namespace beginning with "Granblue" * Removed some top-level Granblue libs DataImporter and DownloadManager exist inside of the PostDeployment namespace now so these files are redundant * Fix Downloaders namespace Our namespace was singular Downloader, now it is plural Downloaders to match the folder name * Fix import paths * DownloadManager was moved to downloaders/ * import_data task now uses the PostDeployment version of DataImporter * Update application.rb Eager-Load/Autoload the lib/ folder * Update cors.rb Add Granblue website and Extension ID to CORS * Add transformers Transformers take raw data from Granblue Fantasy and transforms them into hensei-compatible JSON. Transformers heavily borrow from vazkii/hensei-transfer. * Add ImportController and route This adds the controller that handles creating a full party from transformed Granblue Fantasy data
51 lines
1.6 KiB
Ruby
51 lines
1.6 KiB
Ruby
module Granblue
|
|
module Transformers
|
|
class CharacterTransformer < BaseTransformer
|
|
def transform
|
|
Rails.logger.info "[TRANSFORM] Starting CharacterTransformer#transform"
|
|
|
|
unless data.is_a?(Hash)
|
|
Rails.logger.error "[TRANSFORM] Invalid character data structure"
|
|
return []
|
|
end
|
|
|
|
characters = []
|
|
data.each_value do |char_data|
|
|
next unless char_data['master'] && char_data['param']
|
|
|
|
master = char_data['master']
|
|
param = char_data['param']
|
|
|
|
Rails.logger.debug "[TRANSFORM] Processing character: #{master['name']}"
|
|
|
|
character = {
|
|
name: master['name'],
|
|
id: master['id'],
|
|
uncap: param['evolution'].to_i
|
|
}
|
|
|
|
Rails.logger.debug "[TRANSFORM] Base character data: #{character}"
|
|
|
|
# Add perpetuity (rings) if present
|
|
if param['has_npcaugment_constant']
|
|
character[:ringed] = true
|
|
Rails.logger.debug "[TRANSFORM] Character is ringed"
|
|
end
|
|
|
|
# Add transcendence if present
|
|
phase = param['phase'].to_i
|
|
if phase && phase.positive?
|
|
character[:transcend] = phase
|
|
Rails.logger.debug "[TRANSFORM] Character has transcendence: #{phase}"
|
|
end
|
|
|
|
characters << character unless master['id'].nil?
|
|
Rails.logger.info "[TRANSFORM] Successfully processed character #{character[:name]}"
|
|
end
|
|
|
|
Rails.logger.info "[TRANSFORM] Completed processing #{characters.length} characters"
|
|
characters
|
|
end
|
|
end
|
|
end
|
|
end
|