From ed6fc388acb0743a081d0b0ae559adf4116c6c28 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Tue, 26 Dec 2023 03:20:45 -0800 Subject: [PATCH] Finish last bugs We tested to ensure that conflict resolution appears for * Opus and Draconic * Draconic and Draconic 2 * Draconic 2 + Opus and Draconic 1 --- .../api/v1/grid_weapons_controller.rb | 3 +- app/models/grid_weapon.rb | 9 +- db/schema.rb | 90 +++---------------- 3 files changed, 17 insertions(+), 85 deletions(-) diff --git a/app/controllers/api/v1/grid_weapons_controller.rb b/app/controllers/api/v1/grid_weapons_controller.rb index 43955ba..3887e95 100644 --- a/app/controllers/api/v1/grid_weapons_controller.rb +++ b/app/controllers/api/v1/grid_weapons_controller.rb @@ -166,12 +166,11 @@ module Api end def handle_conflict(weapon) - conflict_weapons = weapon.conflicts(party) # Map conflict weapon IDs into an array conflict_weapon_ids = conflict_weapons.map(&:id) - if conflict_weapon_ids.include?(incoming_weapon.id) + if !conflict_weapon_ids.include?(incoming_weapon.id) # Render conflict view if the underlying canonical weapons # are not identical output = render_conflict_view(conflict_weapons, incoming_weapon, weapon_params[:position]) diff --git a/app/models/grid_weapon.rb b/app/models/grid_weapon.rb index 014a328..c24dcbe 100644 --- a/app/models/grid_weapon.rb +++ b/app/models/grid_weapon.rb @@ -17,7 +17,7 @@ class GridWeapon < ApplicationRecord validate :compatible_with_position, on: :create validate :no_conflicts, on: :create - before_save :is_mainhand + before_save :mainhand? ##### Amoeba configuration amoeba do @@ -57,7 +57,6 @@ class GridWeapon < ApplicationRecord conflicting_weapons << party_weapon if (series_match || both_opus_or_draconic || both_draconic) && !id_match end - conflicting_weapons end @@ -88,11 +87,13 @@ class GridWeapon < ApplicationRecord # Validates whether there is a conflict with the party def no_conflicts # Check if the grid weapon conflicts with any of the other grid weapons in the party - errors.add(:series, 'must not conflict with existing weapons') unless conflicts(party).nil? + return unless !conflicts(party).nil? && !conflicts(party).empty? + + errors.add(:series, 'must not conflict with existing weapons') end # Checks if the weapon should be a mainhand before saving the model - def is_mainhand + def mainhand? self.mainhand = position == -1 end end diff --git a/db/schema.rb b/db/schema.rb index 8d4f9ab..1211378 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_08_24_222107) do +ActiveRecord::Schema[7.0].define(version: 2023_11_19_051231) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gin" enable_extension "pg_trgm" @@ -30,50 +30,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_24_222107) do t.integer "order", default: 0, null: false end - create_table "character_charge_attacks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "character_id" - t.string "name_en", null: false - t.string "name_jp", null: false - t.string "description_en", null: false - t.string "description_jp", null: false - t.integer "order", null: false - t.string "form" - t.uuid "effects", array: true - t.index ["character_id"], name: "index_character_charge_attacks_on_character_id" - end - - create_table "character_skills", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "character_id" - t.string "name_en", null: false - t.string "name_jp", null: false - t.string "description_en", null: false - t.string "description_jp", null: false - t.integer "type", null: false - t.integer "position", null: false - t.string "form" - t.integer "cooldown", default: 0, null: false - t.integer "lockout", default: 0, null: false - t.integer "duration", array: true - t.boolean "recast", default: false, null: false - t.integer "obtained_at", default: 1, null: false - t.uuid "effects", array: true - t.index ["character_id"], name: "index_character_skills_on_character_id" - end - - create_table "character_support_skills", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "character_id" - t.string "name_en", null: false - t.string "name_jp", null: false - t.string "description_en", null: false - t.string "description_jp", null: false - t.integer "position", null: false - t.integer "obtained_at" - t.boolean "emp", default: false, null: false - t.boolean "transcendence", default: false, null: false - t.uuid "effects", array: true - t.index ["character_id"], name: "index_character_support_skills_on_character_id" - end - create_table "characters", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "name_en" t.string "name_jp" @@ -101,8 +57,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_24_222107) do t.integer "max_hp_ulb" t.integer "max_atk_ulb" t.integer "character_id", default: [], null: false, array: true - t.string "nicknames_en", default: [], null: false, array: true - t.string "nicknames_jp", default: [], null: false, array: true t.string "wiki_en", default: "", null: false t.date "release_date" t.date "flb_date" @@ -110,29 +64,11 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_24_222107) do t.string "wiki_ja", default: "", null: false t.string "gamewith", default: "", null: false t.string "kamigame", default: "", null: false + t.string "nicknames_en", default: [], null: false, array: true + t.string "nicknames_jp", default: [], null: false, array: true t.index ["name_en"], name: "index_characters_on_name_en", opclass: :gin_trgm_ops, using: :gin end - create_table "data_migrations", primary_key: "version", id: :string, force: :cascade do |t| - end - - create_table "effects", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "name_en", null: false - t.string "name_jp", null: false - t.string "description_en", null: false - t.string "description_jp", null: false - t.integer "accuracy_value" - t.string "accuracy_suffix" - t.string "accuracy_comparator" - t.jsonb "strength", array: true - t.integer "healing_cap" - t.boolean "duration_indefinite", default: false, null: false - t.integer "duration_value" - t.string "duration_unit" - t.string "notes_en" - t.string "notes_jp" - end - create_table "favorites", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "user_id" t.uuid "party_id" @@ -179,10 +115,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_24_222107) do t.jsonb "ring3", default: {"modifier"=>nil, "strength"=>nil}, null: false t.jsonb "ring4", default: {"modifier"=>nil, "strength"=>nil}, null: false t.jsonb "earring", default: {"modifier"=>nil, "strength"=>nil}, null: false - t.boolean "skill0_enabled", default: true, null: false - t.boolean "skill1_enabled", default: true, null: false - t.boolean "skill2_enabled", default: true, null: false - t.boolean "skill3_enabled", default: true, null: false t.uuid "awakening_id" t.integer "awakening_level", default: 1 t.index ["awakening_id"], name: "index_grid_characters_on_awakening_id" @@ -200,7 +132,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_24_222107) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "transcendence_step", default: 0, null: false - t.boolean "quick_summon", default: false, null: false + t.boolean "quick_summon", default: false t.index ["party_id"], name: "index_grid_summons_on_party_id" t.index ["summon_id"], name: "index_grid_summons_on_summon_id" end @@ -302,7 +234,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_24_222107) do t.datetime "revoked_at", precision: nil t.datetime "created_at", precision: nil, null: false t.string "scopes" - t.string "previous_refresh_token", default: "" + t.string "previous_refresh_token", default: "", null: false t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id" t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true @@ -353,7 +285,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_24_222107) do t.uuid "guidebook3_id" t.uuid "guidebook1_id" t.uuid "guidebook2_id" - t.boolean "auto_summon", default: false, null: false + t.boolean "auto_summon", default: false t.boolean "remix", default: false, null: false t.integer "visibility", default: 1, null: false t.index ["accessory_id"], name: "index_parties_on_accessory_id" @@ -440,8 +372,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_24_222107) do t.boolean "xlb", default: false, null: false t.integer "max_atk_xlb" t.integer "max_hp_xlb" - t.string "nicknames_en", default: [], null: false, array: true - t.string "nicknames_jp", default: [], null: false, array: true t.integer "summon_id" t.date "release_date" t.date "flb_date" @@ -451,6 +381,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_24_222107) do t.string "gamewith", default: "" t.string "kamigame", default: "" t.date "xlb_date" + t.string "nicknames_en", default: [], null: false, array: true + t.string "nicknames_jp", default: [], null: false, array: true t.index ["name_en"], name: "index_summons_on_name_en", opclass: :gin_trgm_ops, using: :gin end @@ -480,12 +412,12 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_24_222107) do create_table "weapon_keys", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "name_en" t.string "name_jp" - t.integer "series" t.integer "slot" t.integer "group" t.integer "order" t.string "slug" t.integer "granblue_id" + t.integer "series", default: [], null: false, array: true end create_table "weapons", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| @@ -512,8 +444,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_24_222107) do t.integer "ax_type" t.boolean "limit", default: false, null: false t.boolean "ax", default: false, null: false - t.string "nicknames_en", default: [], null: false, array: true - t.string "nicknames_jp", default: [], null: false, array: true t.uuid "recruits_id" t.integer "max_awakening_level" t.date "release_date" @@ -523,6 +453,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_24_222107) do t.string "wiki_ja", default: "" t.string "gamewith", default: "" t.string "kamigame", default: "" + t.string "nicknames_en", default: [], null: false, array: true + t.string "nicknames_jp", default: [], null: false, array: true t.index ["name_en"], name: "index_weapons_on_name_en", opclass: :gin_trgm_ops, using: :gin t.index ["recruits_id"], name: "index_weapons_on_recruits_id" end