global

def self.parse_variable(variable, type, _game_type)

Returns:
  • (String) -

Parameters:
  • _game_type (String) --
  • type (Integer) --
  • variable (String) --
def self.parse_variable(variable, type, _game_type)
    variable = variable.gsub(/\r?\n/, "\n")
    # for some reason it returns true if multi-line string contains carriage returns (wtf?)
    return nil if variable.match?(STRING_IS_ONLY_SYMBOLS_RE)

    if variable.split("\n").all? { |line| line.empty? || line.match?(/^#? ?<.*>.?$/) || line.match?(/^[a-z][0-9]$/) }
        return nil
    end

    return nil if variable.match?(/^[+-]?[0-9]+$/) || variable.match?(/---/) || variable.match?(/restrict eval/)

    case type
    when 0 # name
    when 1 # nickname
    when 2 # description
    when 3 # note
    else
        nil
    end

    variable
end