Move enums into GranblueEnums
We don't use these yet, but it gives us a structured place to pull them from.
This commit is contained in:
parent
fc90014039
commit
3b560d07cc
2 changed files with 65 additions and 69 deletions
|
|
@ -48,73 +48,4 @@ class Character < ApplicationRecord
|
||||||
def display_resource(character)
|
def display_resource(character)
|
||||||
character.name_en
|
character.name_en
|
||||||
end
|
end
|
||||||
|
|
||||||
# enum rarities: {
|
|
||||||
# R: 1,
|
|
||||||
# SR: 2,
|
|
||||||
# SSR: 3
|
|
||||||
# }
|
|
||||||
|
|
||||||
# enum elements: {
|
|
||||||
# Null: 0,
|
|
||||||
# Wind: 1,
|
|
||||||
# Fire: 2,
|
|
||||||
# Water: 3,
|
|
||||||
# Earth: 4,
|
|
||||||
# Dark: 5,
|
|
||||||
# Light: 6
|
|
||||||
# }
|
|
||||||
|
|
||||||
# enum proficiency1s: {
|
|
||||||
# Sabre: 1,
|
|
||||||
# Dagger: 2,
|
|
||||||
# Axe: 3,
|
|
||||||
# Spear: 4,
|
|
||||||
# Bow: 5,
|
|
||||||
# Staff: 6,
|
|
||||||
# Melee: 7,
|
|
||||||
# Harp: 8,
|
|
||||||
# Gun: 9,
|
|
||||||
# Katana: 10
|
|
||||||
# }, _prefix: "proficiency1"
|
|
||||||
|
|
||||||
# enum proficiency2s: {
|
|
||||||
# None: 0,
|
|
||||||
# Sabre: 1,
|
|
||||||
# Dagger: 2,
|
|
||||||
# Axe: 3,
|
|
||||||
# Spear: 4,
|
|
||||||
# Bow: 5,
|
|
||||||
# Staff: 6,
|
|
||||||
# Melee: 7,
|
|
||||||
# Harp: 8,
|
|
||||||
# Gun: 9,
|
|
||||||
# Katana: 10,
|
|
||||||
# }, _default: :None, _prefix: "proficiency2"
|
|
||||||
|
|
||||||
# enum race1s: {
|
|
||||||
# Unknown: 0,
|
|
||||||
# Human: 1,
|
|
||||||
# Erune: 2,
|
|
||||||
# Draph: 3,
|
|
||||||
# Harvin: 4,
|
|
||||||
# Primal: 5
|
|
||||||
# }, _prefix: "race1"
|
|
||||||
|
|
||||||
# enum race2s: {
|
|
||||||
# Unknown: 0,
|
|
||||||
# Human: 1,
|
|
||||||
# Erune: 2,
|
|
||||||
# Draph: 3,
|
|
||||||
# Harvin: 4,
|
|
||||||
# Primal: 5,
|
|
||||||
# None: 6
|
|
||||||
# }, _default: :None, _prefix: "race2"
|
|
||||||
|
|
||||||
# enum gender: {
|
|
||||||
# Unknown: 0,
|
|
||||||
# Male: 1,
|
|
||||||
# Female: 2,
|
|
||||||
# "Male/Female": 3
|
|
||||||
# }
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
65
app/models/concerns/granblue_enums.rb
Normal file
65
app/models/concerns/granblue_enums.rb
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
module GranblueEnums
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
# Define constants for shared enum mappings.
|
||||||
|
RARITIES = { R: 1, SR: 2, SSR: 3 }.freeze
|
||||||
|
ELEMENTS = { Null: 0, Wind: 1, Fire: 2, Water: 3, Earth: 4, Dark: 5, Light: 6 }.freeze
|
||||||
|
GENDERS = { Unknown: 0, Male: 1, Female: 2, "Male/Female": 3 }.freeze
|
||||||
|
|
||||||
|
# Single proficiency enum mapping used for both proficiency1 and proficiency2.
|
||||||
|
PROFICIENCY = {
|
||||||
|
None: 0,
|
||||||
|
Sabre: 1,
|
||||||
|
Dagger: 2,
|
||||||
|
Axe: 3,
|
||||||
|
Spear: 4,
|
||||||
|
Bow: 5,
|
||||||
|
Staff: 6,
|
||||||
|
Melee: 7,
|
||||||
|
Harp: 8,
|
||||||
|
Gun: 9,
|
||||||
|
Katana: 10
|
||||||
|
}.freeze
|
||||||
|
|
||||||
|
# Single race enum mapping used for both race1 and race2.
|
||||||
|
RACES = {
|
||||||
|
Unknown: 0,
|
||||||
|
Human: 1,
|
||||||
|
Erune: 2,
|
||||||
|
Draph: 3,
|
||||||
|
Harvin: 4,
|
||||||
|
Primal: 5,
|
||||||
|
None: 6
|
||||||
|
}.freeze
|
||||||
|
|
||||||
|
included do
|
||||||
|
# Make sure the model has been loaded with its table before calling enum.
|
||||||
|
if respond_to?(:column_names) && table_exists? && column_names.include?('rarity')
|
||||||
|
enum rarity: RARITIES
|
||||||
|
end
|
||||||
|
|
||||||
|
if respond_to?(:column_names) && table_exists? && column_names.include?('element')
|
||||||
|
enum element: ELEMENTS
|
||||||
|
end
|
||||||
|
|
||||||
|
if respond_to?(:column_names) && table_exists? && column_names.include?('gender')
|
||||||
|
enum gender: GENDERS
|
||||||
|
end
|
||||||
|
|
||||||
|
if respond_to?(:column_names) && table_exists? && column_names.include?('proficiency1')
|
||||||
|
enum proficiency1: PROFICIENCY, _prefix: :proficiency1, _default: :None
|
||||||
|
end
|
||||||
|
|
||||||
|
if respond_to?(:column_names) && table_exists? && column_names.include?('proficiency2')
|
||||||
|
enum proficiency2: PROFICIENCY, _prefix: :proficiency2, _default: :None
|
||||||
|
end
|
||||||
|
|
||||||
|
if respond_to?(:column_names) && table_exists? && column_names.include?('race1')
|
||||||
|
enum race1: RACES, _prefix: :race1, _default: :Unknown
|
||||||
|
end
|
||||||
|
|
||||||
|
if respond_to?(:column_names) && table_exists? && column_names.include?('race2')
|
||||||
|
enum race2: RACES, _prefix: :race2, _default: :None
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue