* Implements advanced filters (#90) * Add advanced filters Adds new filters to search: * Full auto * Charge attack * Auto guard * Number of weapons (user-selectable now) * Number of summons * Number of characters * Maximum number of turns * Maximum number of buttons * Maximum clear time * User quality (No anonymous users) * Name quality (No untitled teams) * Remixes (Only show original teams) * Update advanced filter params * Add default to party counter cache * Fix a bug where unauthenticated users couldn't view profiles (#92) * Implements advanced filters (#90) (#91) * Add advanced filters Adds new filters to search: * Full auto * Charge attack * Auto guard * Number of weapons (user-selectable now) * Number of summons * Number of characters * Maximum number of turns * Maximum number of buttons * Maximum clear time * User quality (No anonymous users) * Name quality (No untitled teams) * Remixes (Only show original teams) * Update advanced filter params * Add default to party counter cache * Fix being unable to see profiles when unauth * Add tables used for Siero's revival (#94) * Implements advanced filters (#90) (#91) * Add advanced filters Adds new filters to search: * Full auto * Charge attack * Auto guard * Number of weapons (user-selectable now) * Number of summons * Number of characters * Maximum number of turns * Maximum number of buttons * Maximum clear time * User quality (No anonymous users) * Name quality (No untitled teams) * Remixes (Only show original teams) * Update advanced filter params * Add default to party counter cache * Deploy unauthenticated profile fix (#93) * Implements advanced filters (#90) * Add advanced filters Adds new filters to search: * Full auto * Charge attack * Auto guard * Number of weapons (user-selectable now) * Number of summons * Number of characters * Maximum number of turns * Maximum number of buttons * Maximum clear time * User quality (No anonymous users) * Name quality (No untitled teams) * Remixes (Only show original teams) * Update advanced filter params * Add default to party counter cache * Fix a bug where unauthenticated users couldn't view profiles (#92) * Implements advanced filters (#90) (#91) * Add advanced filters Adds new filters to search: * Full auto * Charge attack * Auto guard * Number of weapons (user-selectable now) * Number of summons * Number of characters * Maximum number of turns * Maximum number of buttons * Maximum clear time * User quality (No anonymous users) * Name quality (No untitled teams) * Remixes (Only show original teams) * Update advanced filter params * Add default to party counter cache * Fix being unable to see profiles when unauth * Add guidebooks migration * Implement business logic for reading Guidebooks * Change to individual guidebook columns * Properly output guidebook description * Move to 1-index guidebooks * Update party-related files for 1-index guidebooks * Add tables for Siero * Update download and export scripts * Support for Siero, raids rework and edit party rework (#96) * Add guidebooks migration * Implement business logic for reading Guidebooks * Change to individual guidebook columns * Properly output guidebook description * Move to 1-index guidebooks * Update party-related files for 1-index guidebooks * Add tables for Siero * Add raid groups table * Update raid model To belong to the RaidGroup class * Update job class To have many job skills * Add endpoint for raid groups * Update Raid blueprint with views * Added down for creating table * Add guidebooks flag and auto summon flag * Guidebooks → RaidGroup * Auto summon → Party * Add views to Raid blueprint * Add views and guidebook flag to RaidGroup blueprint * Add auto summon and Raid view to Party blueprint * Add quick summons (#97) * Adds quick summon migration * Add route to update quick summon * Add logic to update quick summon * Remove ap call * Add logic to updating summon uncap You couldn't actually update summon transcendence on staging, maybe due to a bug? Now you can. And it won't let you update outside of the bounds of what is defined on the canonical object. * Fix summon logic Updated logic for updating summon uncap and transcendence levels and quick summon status. * Fix searching in Japanese (#99) This was broken because we were using the browser-provided locale as a prefix to our method, but that is 'ja' and our methods were prefixed with 'jp'. * Fix display of base skills (#100) Base skills were not displaying due to a missing case in our search code. This is now fixed. * Update awakenings (#101) * Deploy unauthenticated profile fix (#93) * Implements advanced filters (#90) * Add advanced filters Adds new filters to search: * Full auto * Charge attack * Auto guard * Number of weapons (user-selectable now) * Number of summons * Number of characters * Maximum number of turns * Maximum number of buttons * Maximum clear time * User quality (No anonymous users) * Name quality (No untitled teams) * Remixes (Only show original teams) * Update advanced filter params * Add default to party counter cache * Fix a bug where unauthenticated users couldn't view profiles (#92) * Implements advanced filters (#90) (#91) * Add advanced filters Adds new filters to search: * Full auto * Charge attack * Auto guard * Number of weapons (user-selectable now) * Number of summons * Number of characters * Maximum number of turns * Maximum number of buttons * Maximum clear time * User quality (No anonymous users) * Name quality (No untitled teams) * Remixes (Only show original teams) * Update advanced filter params * Add default to party counter cache * Fix being unable to see profiles when unauth * Add tables used for Siero's revival (#94) * Implements advanced filters (#90) (#91) * Add advanced filters Adds new filters to search: * Full auto * Charge attack * Auto guard * Number of weapons (user-selectable now) * Number of summons * Number of characters * Maximum number of turns * Maximum number of buttons * Maximum clear time * User quality (No anonymous users) * Name quality (No untitled teams) * Remixes (Only show original teams) * Update advanced filter params * Add default to party counter cache * Deploy unauthenticated profile fix (#93) * Implements advanced filters (#90) * Add advanced filters Adds new filters to search: * Full auto * Charge attack * Auto guard * Number of weapons (user-selectable now) * Number of summons * Number of characters * Maximum number of turns * Maximum number of buttons * Maximum clear time * User quality (No anonymous users) * Name quality (No untitled teams) * Remixes (Only show original teams) * Update advanced filter params * Add default to party counter cache * Fix a bug where unauthenticated users couldn't view profiles (#92) * Implements advanced filters (#90) (#91) * Add advanced filters Adds new filters to search: * Full auto * Charge attack * Auto guard * Number of weapons (user-selectable now) * Number of summons * Number of characters * Maximum number of turns * Maximum number of buttons * Maximum clear time * User quality (No anonymous users) * Name quality (No untitled teams) * Remixes (Only show original teams) * Update advanced filter params * Add default to party counter cache * Fix being unable to see profiles when unauth * Add guidebooks migration * Implement business logic for reading Guidebooks * Change to individual guidebook columns * Properly output guidebook description * Move to 1-index guidebooks * Update party-related files for 1-index guidebooks * Add tables for Siero * Adds guidebooks and gacha tables (#95) * Implements advanced filters (#90) * Add advanced filters Adds new filters to search: * Full auto * Charge attack * Auto guard * Number of weapons (user-selectable now) * Number of summons * Number of characters * Maximum number of turns * Maximum number of buttons * Maximum clear time * User quality (No anonymous users) * Name quality (No untitled teams) * Remixes (Only show original teams) * Update advanced filter params * Add default to party counter cache * Fix a bug where unauthenticated users couldn't view profiles (#92) * Implements advanced filters (#90) (#91) * Add advanced filters Adds new filters to search: * Full auto * Charge attack * Auto guard * Number of weapons (user-selectable now) * Number of summons * Number of characters * Maximum number of turns * Maximum number of buttons * Maximum clear time * User quality (No anonymous users) * Name quality (No untitled teams) * Remixes (Only show original teams) * Update advanced filter params * Add default to party counter cache * Fix being unable to see profiles when unauth * Add tables used for Siero's revival (#94) * Implements advanced filters (#90) (#91) * Add advanced filters Adds new filters to search: * Full auto * Charge attack * Auto guard * Number of weapons (user-selectable now) * Number of summons * Number of characters * Maximum number of turns * Maximum number of buttons * Maximum clear time * User quality (No anonymous users) * Name quality (No untitled teams) * Remixes (Only show original teams) * Update advanced filter params * Add default to party counter cache * Deploy unauthenticated profile fix (#93) * Implements advanced filters (#90) * Add advanced filters Adds new filters to search: * Full auto * Charge attack * Auto guard * Number of weapons (user-selectable now) * Number of summons * Number of characters * Maximum number of turns * Maximum number of buttons * Maximum clear time * User quality (No anonymous users) * Name quality (No untitled teams) * Remixes (Only show original teams) * Update advanced filter params * Add default to party counter cache * Fix a bug where unauthenticated users couldn't view profiles (#92) * Implements advanced filters (#90) (#91) * Add advanced filters Adds new filters to search: * Full auto * Charge attack * Auto guard * Number of weapons (user-selectable now) * Number of summons * Number of characters * Maximum number of turns * Maximum number of buttons * Maximum clear time * User quality (No anonymous users) * Name quality (No untitled teams) * Remixes (Only show original teams) * Update advanced filter params * Add default to party counter cache * Fix being unable to see profiles when unauth * Add guidebooks migration * Implement business logic for reading Guidebooks * Change to individual guidebook columns * Properly output guidebook description * Move to 1-index guidebooks * Update party-related files for 1-index guidebooks * Add tables for Siero * Update download and export scripts * Support for Siero, raids rework and edit party rework (#96) * Add guidebooks migration * Implement business logic for reading Guidebooks * Change to individual guidebook columns * Properly output guidebook description * Move to 1-index guidebooks * Update party-related files for 1-index guidebooks * Add tables for Siero * Add raid groups table * Update raid model To belong to the RaidGroup class * Update job class To have many job skills * Add endpoint for raid groups * Update Raid blueprint with views * Added down for creating table * Add guidebooks flag and auto summon flag * Guidebooks → RaidGroup * Auto summon → Party * Add views to Raid blueprint * Add views and guidebook flag to RaidGroup blueprint * Add auto summon and Raid view to Party blueprint * Remove ap call * Add quick summons (#97) * Adds quick summon migration * Add route to update quick summon * Add logic to update quick summon * Add logic to updating summon uncap You couldn't actually update summon transcendence on staging, maybe due to a bug? Now you can. And it won't let you update outside of the bounds of what is defined on the canonical object. * Fix summon logic Updated logic for updating summon uncap and transcendence levels and quick summon status. * Fix searching in Japanese (#99) This was broken because we were using the browser-provided locale as a prefix to our method, but that is 'ja' and our methods were prefixed with 'jp'. * Fix display of base skills (#100) Base skills were not displaying due to a missing case in our search code. This is now fixed. * Squash migrations into one file * Add migrations This adds migrations and data migrations for the awakening update. * A new `Awakenings` table now exists that stores all possible awakenings, with a column for object type. * GridCharacter and GridWeapon now have `awakening_id` and `awakening_level` fields. Their `awakening` and `awakening_type` fields were removed. * Weapons have a mapping table, `WeaponAwakenings`, as not all weapons can be awakened. * Data migrations are included to migrate existing user data. They should be run automatically when the migration is run with `rails db:migrate:with_data` * Add and update models This updates models for the awakening update. * Awakening and WeaponAwakening models were added * Weapon, GridWeapon and GridCharacter models get relationships to the new models defined * GridCharacter had a validation on `awakening_level` that needed to be fixed * Update controllers This updates the GridCharacters and GridWeapons controllers to accept the new fields `awakening_id` and `awakening_level` from clients * Update blueprints This updates the blueprints to match the new schema. The new AwakeningBlueprint was accidentally added already, oops. * Remove re-added migrations * Implement removing job skills (#103) This lets users remove job skills, for if they accidentally set them. * Fix migration
211 lines
5.4 KiB
Ruby
211 lines
5.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class GridCharacter < ApplicationRecord
|
|
belongs_to :awakening, optional: true
|
|
belongs_to :party,
|
|
counter_cache: :characters_count,
|
|
inverse_of: :characters
|
|
validates_presence_of :party
|
|
|
|
validate :validate_awakening_level, on: :update
|
|
validate :transcendence, on: :update
|
|
validate :validate_over_mastery_values, on: :update
|
|
validate :validate_aetherial_mastery_value, on: :update
|
|
validate :over_mastery_attack_matches_hp, on: :update
|
|
|
|
##### Amoeba configuration
|
|
amoeba do
|
|
set ring1: { modifier: nil, strength: nil }
|
|
set ring2: { modifier: nil, strength: nil }
|
|
set ring3: { modifier: nil, strength: nil }
|
|
set ring4: { modifier: nil, strength: nil }
|
|
set earring: { modifier: nil, strength: nil }
|
|
set perpetuity: false
|
|
end
|
|
|
|
def validate_awakening_level
|
|
errors.add(:awakening, 'awakening level too low') if awakening_level < 1
|
|
errors.add(:awakening, 'awakening level too high') if awakening_level > 9
|
|
end
|
|
|
|
def transcendence
|
|
errors.add(:transcendence_step, 'character has no transcendence') if transcendence_step.positive? && !character.ulb
|
|
errors.add(:transcendence_step, 'transcendence step too high') if transcendence_step > 5 && character.ulb
|
|
errors.add(:transcendence_step, 'transcendence step too low') if transcendence_step.negative? && character.ulb
|
|
end
|
|
|
|
def over_mastery_attack
|
|
errors.add(:ring1, 'invalid value') unless ring1['modifier'].nil? || atk_values.include?(ring1['strength'])
|
|
end
|
|
|
|
def over_mastery_hp
|
|
return if ring2['modifier'].nil?
|
|
|
|
errors.add(:ring2, 'invalid value') unless hp_values.include?(ring2['strength'])
|
|
end
|
|
|
|
def over_mastery_attack_matches_hp
|
|
return if ring1[:modifier].nil? && ring2[:modifier].nil?
|
|
|
|
return if ring2[:strength] == (ring1[:strength] / 2)
|
|
|
|
errors.add(:over_mastery,
|
|
'over mastery attack and hp values do not match')
|
|
end
|
|
|
|
def validate_over_mastery_values
|
|
[ring1, ring2, ring3, ring4].each_with_index do |ring, index|
|
|
next if ring['modifier'].nil?
|
|
|
|
modifier = over_mastery_modifiers[ring['modifier']]
|
|
check_value({ "ring#{index}": { ring[modifier] => ring['strength'] } },
|
|
'over_mastery')
|
|
end
|
|
end
|
|
|
|
def validate_aetherial_mastery_value
|
|
return if earring['modifier'].nil?
|
|
|
|
return unless earring['modifier'].positive?
|
|
|
|
modifier = aetherial_mastery_modifiers[earring['modifier']].to_sym
|
|
check_value({ "earring": { modifier => earring['strength'] } },
|
|
'aetherial_mastery')
|
|
end
|
|
|
|
def character
|
|
Character.find(character_id)
|
|
end
|
|
|
|
def blueprint
|
|
GridCharacterBlueprint
|
|
end
|
|
|
|
private
|
|
|
|
def check_value(property, type)
|
|
# Input format
|
|
# { ring1: { atk: 300 } }
|
|
|
|
key = property.keys.first
|
|
modifier = property[key].keys.first
|
|
|
|
return if modifier.nil?
|
|
|
|
case type
|
|
when 'over_mastery'
|
|
errors.add(key, 'invalid value') unless over_mastery_values.include?(key['strength'])
|
|
when 'aetherial_mastery'
|
|
errors.add(key, 'value too low') if aetherial_mastery_values[modifier][:min] > self[key]['strength']
|
|
errors.add(key, 'value too high') if aetherial_mastery_values[modifier][:max] < self[key]['strength']
|
|
end
|
|
end
|
|
|
|
def over_mastery_modifiers
|
|
{
|
|
1 => 'atk',
|
|
2 => 'hp',
|
|
3 => 'debuff_success',
|
|
4 => 'skill_cap',
|
|
5 => 'ca_dmg',
|
|
6 => 'ca_cap',
|
|
7 => 'stamina',
|
|
8 => 'enmity',
|
|
9 => 'crit',
|
|
10 => 'da',
|
|
11 => 'ta',
|
|
12 => 'def',
|
|
13 => 'heal',
|
|
14 => 'debuff_resist',
|
|
15 => 'dodge'
|
|
}
|
|
end
|
|
|
|
def over_mastery_values
|
|
{
|
|
atk: [300, 600, 900, 1200, 1500, 1800, 2100, 2400, 2700, 3000],
|
|
hp: [150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500],
|
|
debuff_success: [6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
|
skill_cap: [6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
|
ca_dmg: [10, 12, 14, 16, 18, 20, 22, 24, 27, 30],
|
|
ca_cap: [6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
|
crit: [10, 12, 14, 16, 18, 20, 22, 24, 27, 30],
|
|
enmity: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
|
stamina: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
|
def: [6, 7, 8, 9, 10, 12, 14, 16, 18, 20],
|
|
heal: [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],
|
|
debuff_resist: [6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
|
dodge: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
|
da: [6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
|
ta: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
}
|
|
end
|
|
|
|
def aetherial_mastery_modifiers
|
|
{
|
|
1 => 'da',
|
|
2 => 'ta',
|
|
3 => 'ele_atk',
|
|
4 => 'ele_resist',
|
|
5 => 'stamina',
|
|
6 => 'enmity',
|
|
7 => 'supplemental',
|
|
8 => 'crit',
|
|
9 => 'counter_dodge',
|
|
10 => 'counter_dmg'
|
|
}
|
|
end
|
|
|
|
def aetherial_mastery_values
|
|
{
|
|
da: {
|
|
min: 10,
|
|
max: 17
|
|
},
|
|
ta: {
|
|
min: 5,
|
|
max: 12
|
|
},
|
|
ele_atk: {
|
|
min: 15,
|
|
max: 22
|
|
},
|
|
ele_resist: {
|
|
min: 5,
|
|
max: 12
|
|
},
|
|
stamina: {
|
|
min: 5,
|
|
max: 12
|
|
},
|
|
enmity: {
|
|
min: 5,
|
|
max: 12
|
|
},
|
|
supplemental: {
|
|
min: 5,
|
|
max: 12
|
|
},
|
|
crit: {
|
|
min: 18,
|
|
max: 35
|
|
},
|
|
counter_dodge: {
|
|
min: 5,
|
|
max: 12
|
|
},
|
|
counter_dmg: {
|
|
min: 10,
|
|
max: 17
|
|
}
|
|
}
|
|
end
|
|
|
|
def atk_values
|
|
[300, 600, 900, 1200, 1500, 1800, 2100, 2400, 2700, 3000]
|
|
end
|
|
|
|
def hp_values
|
|
[150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]
|
|
end
|
|
end
|