<commit_before># frozen_string_literal: true

class Scenario < ActiveRecord::Base
  # TODO: Convert all of the naked strings into constants
  validates :game_system, :type_of, :name, presence: true
  validates :scenario_number, presence: true, if: :scenario_number_needed?
  validates :season, presence: true, if: :season_needed?
  validates :tier, presence: true, if: :tier_needed?

  # TODO: Use constants instead of these strings
  TYPES = ['Scenario', 'Bounty', 'Quest', 'Module', 'Adventure Path', 'ACG', 'Other'].freeze
  SYSTEMS = %w[PFS2 SFS ACG Other PFS Playtest].freeze

  def group
    "#{game_system} Season #{season} #{type_of}"
  end

  def long_name
    if game_system == 'Other'
      name
    elsif scenario?
      "#{game_system} #{'%02d' % season}-#{'%02d' % scenario_number}: #{name}"
    elsif quest?
      if 'PFS2'.eql? game_system
        "#{game_system} Quest #{scenario_number}: #{name}"
      else
        "#{game_system} Season #{'%02d' % season} Quest: #{name}"
      end
    elsif bounty?
      # May have to add season if they add this in the future
      "#{game_system} Bounty #{scenario_number}: #{name}"
    elsif AP?
      "#{game_system} AP #{'%d' % scenario_number}: #{name}"
    else
      "#{game_system} #{name}"
    end
  end

  def short_name
    if scenario?
      "#{game_system} #{season}-#{'%02d' % scenario_number}"
    elsif AP?
      "#{game_system} AP #{'%d' % scenario_number}"
    else
      "#{game_system} #{name}"
    end
  end

  def scenario?
    type_of == 'Scenario'
  end

  def quest?
    type_of == 'Quest'
  end

  def bounty?
    type_of == 'Bounty'
  end

  def other_system?
    game_system == 'Other'
  end

  def opf_type?
    %w[PFS PFS2 SFS].include? game_system
  end

  # noinspection RubyInstanceMethodNamingConvention
  def AP?
    type_of == 'Adventure Path'
  end

  def season_needed?
    scenario? || quest?<commit_msg>Add constants for type and system<commit_after># frozen_string_literal: true

class Scenario < ActiveRecord::Base # rubocop:disable  Metrics/ClassLength
  validates :game_system, :type_of, :name, presence: true
  validates :scenario_number, presence: true, if: :scenario_number_needed?
  validates :season, presence: true, if: :season_needed?
  validates :tier, presence: true, if: :tier_needed?

  INTRO = 'Intro Scenario'
  SCENARIO = 'Scenario'
  BOUNTY = 'Bounty'
  QUEST = 'Quest'
  MODULE = 'Module'
  AP = 'Adventure Path'
  ACG = 'ACG'
  OTHER = 'Other'
  TYPES = [SCENARIO, INTRO, BOUNTY, QUEST, MODULE, AP, ACG, OTHER].freeze
  PFS2 = 'PFS2'
  PFS1 = 'PFS'
  SFS = 'SFS'
  PLAYTEST = 'Playtest'
  AL = 'D&D Adventurers League'
  SYSTEMS = [PFS2, SFS, ACG, OTHER, PFS1, PLAYTEST, AL].freeze

  def group
    "#{game_system} Season #{season} #{type_of}"
  end

  def long_name
    if game_system == OTHER || game_system == AL
      name
    elsif scenario?
      "#{game_system} #{'%02d' % season}-#{'%02d' % scenario_number}: #{name}"
    elsif quest?
      if 'PFS2'.eql? game_system
        "#{game_system} Quest #{scenario_number}: #{name}"
      else
        "#{game_system} Season #{'%02d' % season} Quest: #{name}"
      end
    elsif intro?
      "#{game_system} Intro #{scenario_number}: #{name}"
    elsif bounty?
      # May have to add season if they add this in the future
      "#{game_system} Bounty #{scenario_number}: #{name}"
    elsif AP?
      "#{game_system} AP #{'%d' % scenario_number}: #{name}"
    else
      "#{game_system} #{name}"
    end
  end

  def short_name
    if scenario?
      "#{game_system} #{season}-#{'%02d' % scenario_number}"
    elsif AP?
      "#{game_system} AP #{'%d' % scenario_number}"
    else
      "#{game_system} #{name}"
    end
  end

  def scenario?
    type_of == SCENARIO
  end

  def intro?
    type_of == INTRO
  end

  def quest?
    type_of == QUEST
  end

  def bounty?
    type_of == BOUNTY
  end

  def other_system?
    game_system == OTHER
  end

  def opf_type?
    %w[PFS PFS2 SFS].include? game_system
  end

  def AP?
    type_of == AP
  end

  def season_needed?
    scenario? || quest?
{'fraction_non_alphanumeric': 0.13530135301353013, 'fraction_numerical': 0.0063960639606396065, 'mean_word_length': 3.1745379876796713, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1964477', 'n_tokens_mistral': 1503, 'n_tokens_neox': 1462, 'n_words': 403}