From 79b9b4e22563bf68393c19e47376b7cac14c28c4 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 9 Jan 2023 00:05:18 -0800 Subject: [PATCH] Exclude certain values from remixing --- app/models/grid_character.rb | 36 ++++++++++++++++++++++++------------ app/models/grid_weapon.rb | 8 ++++++++ app/models/party.rb | 2 -- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/app/models/grid_character.rb b/app/models/grid_character.rb index b6bb12e..0e03291 100644 --- a/app/models/grid_character.rb +++ b/app/models/grid_character.rb @@ -12,34 +12,46 @@ class GridCharacter < ApplicationRecord validate :over_mastery_hp, on: :update validate :over_mastery_attack_matches_hp, on: :update + ##### Amoeba configuration + amoeba do + nullify :ring1 + nullify :ring2 + nullify :ring3 + nullify :ring4 + nullify :earring + nullify :perpetuity + end + def awakening_level - unless awakening.nil? - errors.add(:awakening, 'awakening level too low') if awakening["level"] < 1 - errors.add(:awakening, 'awakening level too high') if awakening["level"] > 9 - end + return if awakening.nil? + + 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 > 0 && !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 < 0 && character.ulb - end def over_mastery_attack - errors.add(:ring1, 'invalid value') unless ring1["modifier"].nil? || atk_values.include?(ring1["strength"]) + errors.add(:ring1, 'invalid value') unless ring1['modifier'].nil? || atk_values.include?(ring1['strength']) end def over_mastery_hp - unless ring2["modifier"].nil? - errors.add(:ring2, 'invalid value') unless hp_values.include?(ring2["strength"]) - end + return if ring2['modifier'].nil? + + errors.add(:ring2, 'invalid value') unless hp_values.include?(ring2['strength']) end def over_mastery_attack_matches_hp - unless ring1[:modifier].nil? && ring2[:modifier].nil? - errors.add(:over_mastery, 'over mastery attack and hp values do not match') unless ring2[:strength] == (ring1[:strength] / 2) - end + 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 character diff --git a/app/models/grid_weapon.rb b/app/models/grid_weapon.rb index 72d93cc..1048290 100644 --- a/app/models/grid_weapon.rb +++ b/app/models/grid_weapon.rb @@ -13,6 +13,14 @@ class GridWeapon < ApplicationRecord validate :compatible_with_position, on: :create validate :no_conflicts, on: :create + ##### Amoeba configuration + amoeba do + nullify :ax_modifier1 + nullify :ax_modifier2 + nullify :ax_strength1 + nullify :ax_strength2 + end + # Helper methods def blueprint GridWeaponBlueprint diff --git a/app/models/party.rb b/app/models/party.rb index 40330d8..87dd9d4 100644 --- a/app/models/party.rb +++ b/app/models/party.rb @@ -60,8 +60,6 @@ class Party < ApplicationRecord ##### Amoeba configuration amoeba do - enable - nullify :description nullify :shortcode