Compare commits
5 commits
main
...
jedmund/sk
| Author | SHA1 | Date | |
|---|---|---|---|
| 7879cccf23 | |||
| 36b706882d | |||
| e0c38a60ba | |||
| a6bf326655 | |||
| 7b88932e2c |
22 changed files with 796 additions and 468 deletions
|
|
@ -34,6 +34,16 @@ class Character < ApplicationRecord
|
|||
}
|
||||
}
|
||||
|
||||
has_many :character_skills,
|
||||
primary_key: 'granblue_id',
|
||||
foreign_key: 'character_granblue_id'
|
||||
has_many :skills,
|
||||
through: :character_skills
|
||||
has_many :charge_attacks,
|
||||
-> { where(owner_type: 'character') },
|
||||
primary_key: 'granblue_id',
|
||||
foreign_key: 'owner_id'
|
||||
|
||||
AWAKENINGS = [
|
||||
{ slug: 'character-balanced', name_en: 'Balanced', name_jp: 'バランス', order: 0 },
|
||||
{ slug: 'character-atk', name_en: 'Attack', name_jp: '攻撃', order: 1 },
|
||||
|
|
|
|||
15
app/models/character_skill.rb
Normal file
15
app/models/character_skill.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CharacterSkill < ApplicationRecord
|
||||
belongs_to :skill
|
||||
belongs_to :alt_skill, class_name: 'Skill', optional: true
|
||||
belongs_to :character, primary_key: 'granblue_id', foreign_key: 'character_granblue_id', optional: true
|
||||
|
||||
validates :character_granblue_id, presence: true
|
||||
validates :position, presence: true
|
||||
validates :position, uniqueness: { scope: %i[character_granblue_id unlock_level] }
|
||||
|
||||
scope :by_position, ->(position) { where(position: position) }
|
||||
scope :unlocked_at, ->(level) { where('unlock_level <= ?', level) }
|
||||
scope :improved_at, ->(level) { where('improve_level <= ?', level) }
|
||||
end
|
||||
14
app/models/charge_attack.rb
Normal file
14
app/models/charge_attack.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ChargeAttack < ApplicationRecord
|
||||
belongs_to :skill
|
||||
belongs_to :alt_skill, class_name: 'Skill', optional: true
|
||||
|
||||
validates :owner_id, presence: true
|
||||
validates :owner_type, presence: true
|
||||
validates :uncap_level, uniqueness: { scope: %i[owner_id owner_type] }
|
||||
|
||||
scope :for_character, -> { where(owner_type: 'character') }
|
||||
scope :for_weapon, -> { where(owner_type: 'weapon') }
|
||||
scope :by_uncap_level, ->(level) { where(uncap_level: level) }
|
||||
end
|
||||
16
app/models/effect.rb
Normal file
16
app/models/effect.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Effect < ApplicationRecord
|
||||
belongs_to :effect_family, class_name: 'Effect', optional: true
|
||||
has_many :child_effects, class_name: 'Effect', foreign_key: 'effect_family_id'
|
||||
has_many :skill_effects
|
||||
has_many :skills, through: :skill_effects
|
||||
|
||||
validates :name_en, presence: true
|
||||
validates :effect_type, presence: true
|
||||
|
||||
enum effect_type: { buff: 1, debuff: 2, special: 3 }
|
||||
|
||||
scope :by_class, ->(effect_class) { where(effect_class: effect_class) }
|
||||
scope :stackable, -> { where(stackable: true) }
|
||||
end
|
||||
24
app/models/skill.rb
Normal file
24
app/models/skill.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Skill < ApplicationRecord
|
||||
has_many :skill_values
|
||||
has_many :skill_effects
|
||||
has_many :effects, through: :skill_effects
|
||||
has_many :character_skills
|
||||
has_many :weapon_skills
|
||||
has_many :summon_calls
|
||||
has_many :charge_attacks
|
||||
has_many :alt_character_skills, class_name: 'CharacterSkill', foreign_key: 'alt_skill_id'
|
||||
has_many :alt_summon_calls, class_name: 'SummonCall', foreign_key: 'alt_skill_id'
|
||||
has_many :alt_charge_attacks, class_name: 'ChargeAttack', foreign_key: 'alt_skill_id'
|
||||
|
||||
validates :name_en, presence: true
|
||||
validates :skill_type, presence: true
|
||||
|
||||
enum skill_type: { character: 1, weapon: 2, summon_call: 3, charge_attack: 4 }
|
||||
enum border_type: { damage: 1, healing: 2, buff: 3, debuff: 4, field: 5 }
|
||||
|
||||
def value_at_level(level)
|
||||
skill_values.find_by(level: level)
|
||||
end
|
||||
end
|
||||
17
app/models/skill_effect.rb
Normal file
17
app/models/skill_effect.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SkillEffect < ApplicationRecord
|
||||
belongs_to :skill
|
||||
belongs_to :effect
|
||||
|
||||
validates :target_type, presence: true
|
||||
validates :duration_type, presence: true
|
||||
|
||||
enum target_type: { self: 1, ally: 2, all_allies: 3, enemy: 4, all_enemies: 5 }
|
||||
enum duration_type: { turns: 1, seconds: 2, indefinite: 3, one_time: 4 }
|
||||
|
||||
scope :local, -> { where(local: true) }
|
||||
scope :global, -> { where(local: false) }
|
||||
scope :permanent, -> { where(permanent: true) }
|
||||
scope :undispellable, -> { where(undispellable: true) }
|
||||
end
|
||||
7
app/models/skill_value.rb
Normal file
7
app/models/skill_value.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SkillValue < ApplicationRecord
|
||||
belongs_to :skill
|
||||
|
||||
validates :level, presence: true, uniqueness: { scope: :skill_id }
|
||||
end
|
||||
|
|
@ -34,6 +34,15 @@ class Summon < ApplicationRecord
|
|||
}
|
||||
}
|
||||
|
||||
has_many :summon_calls,
|
||||
primary_key: 'granblue_id',
|
||||
foreign_key: 'summon_granblue_id'
|
||||
has_many :summon_auras,
|
||||
primary_key: 'granblue_id',
|
||||
foreign_key: 'summon_granblue_id'
|
||||
has_many :skills,
|
||||
through: :summon_calls
|
||||
|
||||
def blueprint
|
||||
SummonBlueprint
|
||||
end
|
||||
|
|
|
|||
14
app/models/summon_aura.rb
Normal file
14
app/models/summon_aura.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal.rb
|
||||
|
||||
class SummonAura < ApplicationRecord
|
||||
belongs_to :summon, primary_key: 'granblue_id', foreign_key: 'summon_granblue_id', optional: true
|
||||
|
||||
validates :summon_granblue_id, presence: true
|
||||
validates :aura_type, presence: true
|
||||
validates :aura_type, uniqueness: { scope: %i[summon_granblue_id uncap_level] }
|
||||
|
||||
enum aura_type: { main: 1, sub: 2 }
|
||||
enum boost_type: { weapon_skill: 1, elemental: 2, stat: 3 }
|
||||
|
||||
scope :by_uncap_level, ->(level) { where(uncap_level: level) }
|
||||
end
|
||||
12
app/models/summon_call.rb
Normal file
12
app/models/summon_call.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SummonCall < ApplicationRecord
|
||||
belongs_to :skill
|
||||
belongs_to :alt_skill, class_name: 'Skill', optional: true
|
||||
belongs_to :summon, primary_key: 'granblue_id', foreign_key: 'summon_granblue_id', optional: true
|
||||
|
||||
validates :summon_granblue_id, presence: true
|
||||
validates :uncap_level, uniqueness: { scope: :summon_granblue_id }
|
||||
|
||||
scope :by_uncap_level, ->(level) { where(uncap_level: level) }
|
||||
end
|
||||
|
|
@ -36,6 +36,15 @@ class Weapon < ApplicationRecord
|
|||
|
||||
has_many :weapon_awakenings
|
||||
has_many :awakenings, through: :weapon_awakenings
|
||||
has_many :weapon_skills,
|
||||
primary_key: 'granblue_id',
|
||||
foreign_key: 'weapon_granblue_id'
|
||||
has_many :skills,
|
||||
through: :weapon_skills
|
||||
has_many :charge_attacks,
|
||||
-> { where(owner_type: 'weapon') },
|
||||
primary_key: 'granblue_id',
|
||||
foreign_key: 'owner_id'
|
||||
|
||||
SERIES_SLUGS = {
|
||||
1 => 'seraphic',
|
||||
|
|
|
|||
15
app/models/weapon_skill.rb
Normal file
15
app/models/weapon_skill.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class WeaponSkill < ApplicationRecord
|
||||
belongs_to :skill
|
||||
belongs_to :weapon, primary_key: 'granblue_id', foreign_key: 'weapon_granblue_id', optional: true
|
||||
|
||||
validates :weapon_granblue_id, presence: true
|
||||
validates :position, presence: true
|
||||
validates :position, uniqueness: { scope: %i[weapon_granblue_id unlock_level] }
|
||||
|
||||
scope :by_position, ->(position) { where(position: position) }
|
||||
scope :unlocked_at, ->(level) { where('unlock_level <= ?', level) }
|
||||
scope :by_series, ->(series) { where(skill_series: series) }
|
||||
scope :by_modifier, ->(modifier) { where(skill_modifier: modifier) }
|
||||
end
|
||||
21
db/migrate/20250302080159_create_effects.rb
Normal file
21
db/migrate/20250302080159_create_effects.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
class CreateEffects < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :effects, id: :uuid do |t|
|
||||
t.string :name_en, null: false
|
||||
t.string :name_jp
|
||||
t.text :description_en
|
||||
t.text :description_jp
|
||||
t.string :icon_path
|
||||
t.integer :effect_type, null: false # 1=buff, 2=debuff, 3=special
|
||||
t.string :effect_class # classification (cant_act, burn, poison)
|
||||
t.uuid :effect_family_id # no foreign key here
|
||||
t.boolean :stackable, default: false
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_foreign_key :effects, :effects, column: :effect_family_id
|
||||
|
||||
add_index :effects, :effect_class
|
||||
add_index :effects, :name_en
|
||||
end
|
||||
end
|
||||
17
db/migrate/20250302080203_create_skills.rb
Normal file
17
db/migrate/20250302080203_create_skills.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
class CreateSkills < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :skills, id: :uuid do |t|
|
||||
t.string :name_en, null: false
|
||||
t.string :name_jp
|
||||
t.text :description_en
|
||||
t.text :description_jp
|
||||
t.integer :border_type # 1=red(dmg), 2=green(heal), 3=yellow(buff), 4=blue(debuff), 5=purple(field)
|
||||
t.integer :cooldown
|
||||
t.integer :skill_type # 1=character, 2=weapon, 3=summon call, 4=charge attack
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_index :skills, :name_en
|
||||
add_index :skills, :skill_type
|
||||
end
|
||||
end
|
||||
14
db/migrate/20250302080212_create_skill_values.rb
Normal file
14
db/migrate/20250302080212_create_skill_values.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
class CreateSkillValues < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :skill_values, id: :uuid do |t|
|
||||
t.references :skill, type: :uuid, null: false
|
||||
t.integer :level, null: false, default: 1 # skill level or uncap level
|
||||
t.decimal :value # numeric value for multiplier
|
||||
t.string :text_value # text description for non-numeric values
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_foreign_key :skill_values, :skills
|
||||
add_index :skill_values, %i[skill_id level], unique: true
|
||||
end
|
||||
end
|
||||
23
db/migrate/20250302080218_create_skill_effects.rb
Normal file
23
db/migrate/20250302080218_create_skill_effects.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
class CreateSkillEffects < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :skill_effects, id: :uuid do |t|
|
||||
t.references :skill, type: :uuid, null: false
|
||||
t.references :effect, type: :uuid, null: false
|
||||
t.integer :target_type # 1=self, 2=ally, 3=all allies, 4=enemy, 5=all enemies
|
||||
t.integer :duration_type # 1=turns, 2=seconds, 3=indefinite, 4=one-time
|
||||
t.integer :duration_value # number of turns/seconds if applicable
|
||||
t.text :condition # condition text
|
||||
t.integer :chance # percentage chance to apply
|
||||
t.decimal :value # value for effect if applicable
|
||||
t.decimal :cap # cap for effect if applicable
|
||||
t.boolean :local, default: true # local vs global effect
|
||||
t.boolean :permanent, default: false # permanent
|
||||
t.boolean :undispellable, default: false # can't be dispelled
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_foreign_key :skill_effects, :skills, name: 'fk_skill_effects_skills'
|
||||
add_foreign_key :skill_effects, :effects, name: 'fk_skill_effects_effects'
|
||||
add_index :skill_effects, %i[skill_id effect_id target_type]
|
||||
end
|
||||
end
|
||||
19
db/migrate/20250302080224_create_character_skills.rb
Normal file
19
db/migrate/20250302080224_create_character_skills.rb
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
class CreateCharacterSkills < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :character_skills, id: :uuid do |t|
|
||||
t.string :character_granblue_id, null: false
|
||||
t.references :skill, type: :uuid, null: false
|
||||
t.integer :position, null: false # 1, 2, 3, 4 for skill slots
|
||||
t.integer :unlock_level # level when skill unlocked
|
||||
t.integer :improve_level # level when skill improved (+)
|
||||
t.references :alt_skill, type: :uuid
|
||||
t.text :alt_condition # condition for alt version
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_foreign_key :character_skills, :skills
|
||||
add_foreign_key :character_skills, :skills, column: :alt_skill_id
|
||||
add_index :character_skills, %i[character_granblue_id position]
|
||||
add_index :character_skills, :character_granblue_id
|
||||
end
|
||||
end
|
||||
19
db/migrate/20250302080231_create_weapon_skills.rb
Normal file
19
db/migrate/20250302080231_create_weapon_skills.rb
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
class CreateWeaponSkills < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :weapon_skills, id: :uuid do |t|
|
||||
t.string :weapon_granblue_id, null: false
|
||||
t.references :skill, type: :uuid, null: false
|
||||
t.integer :position, null: false # 1, 2, 3 for skill slots
|
||||
t.string :skill_modifier # Modifier like "Might", "Majesty"
|
||||
t.string :skill_series # Series like "Ironflame", "Hoarfrost"
|
||||
t.string :skill_size # Size like "Small", "Medium", "Big", "Massive"
|
||||
t.integer :unlock_level # level when skill unlocked
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_foreign_key :weapon_skills, :skills
|
||||
add_index :weapon_skills, %i[weapon_granblue_id position]
|
||||
add_index :weapon_skills, :weapon_granblue_id
|
||||
add_index :weapon_skills, :skill_series
|
||||
end
|
||||
end
|
||||
18
db/migrate/20250302080239_create_summon_auras.rb
Normal file
18
db/migrate/20250302080239_create_summon_auras.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
class CreateSummonAuras < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :summon_auras, id: :uuid do |t|
|
||||
t.string :summon_granblue_id, null: false
|
||||
t.text :description_en
|
||||
t.text :description_jp
|
||||
t.integer :aura_type # 1=main, 2=sub
|
||||
t.integer :boost_type # 1=weapon skill, 2=elemental, 3=stat
|
||||
t.string :boost_target # what is being boosted
|
||||
t.decimal :boost_value # percentage value
|
||||
t.integer :uncap_level # 0, 3, 4, 5 for uncap level
|
||||
t.text :condition # any conditions
|
||||
t.timestamps null: false
|
||||
end
|
||||
add_index :summon_auras, %i[summon_granblue_id aura_type uncap_level]
|
||||
add_index :summon_auras, :summon_granblue_id
|
||||
end
|
||||
end
|
||||
18
db/migrate/20250302080243_create_summon_calls.rb
Normal file
18
db/migrate/20250302080243_create_summon_calls.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
class CreateSummonCalls < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :summon_calls, id: :uuid do |t|
|
||||
t.string :summon_granblue_id, null: false
|
||||
t.references :skill, type: :uuid, null: false
|
||||
t.integer :cooldown
|
||||
t.integer :uncap_level # 0, 3, 4, 5 for uncap level
|
||||
t.references :alt_skill, type: :uuid
|
||||
t.text :alt_condition # condition for alt version
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_foreign_key :summon_calls, :skills
|
||||
add_foreign_key :summon_calls, :skills, column: :alt_skill_id
|
||||
add_index :summon_calls, %i[summon_granblue_id uncap_level]
|
||||
add_index :summon_calls, :summon_granblue_id
|
||||
end
|
||||
end
|
||||
17
db/migrate/20250302080540_create_charge_attacks.rb
Normal file
17
db/migrate/20250302080540_create_charge_attacks.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
class CreateChargeAttacks < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :charge_attacks, id: :uuid do |t|
|
||||
t.string :owner_id, null: false # can be character_granblue_id or weapon_granblue_id
|
||||
t.string :owner_type, null: false # "character" or "weapon"
|
||||
t.references :skill, type: :uuid, null: false
|
||||
t.integer :uncap_level # 0, 3, 4, 5 for uncap level
|
||||
t.references :alt_skill, type: :uuid
|
||||
t.text :alt_condition # condition for alt version
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_foreign_key :charge_attacks, :skills
|
||||
add_foreign_key :charge_attacks, :skills, column: :alt_skill_id
|
||||
add_index :charge_attacks, %i[owner_type owner_id uncap_level]
|
||||
end
|
||||
end
|
||||
936
db/schema.rb
936
db/schema.rb
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue