class Arena < ApplicationRecord
  validates :name, :area, presence: true
  has_many :battles

  # Convert arena area to matrix
  # @return SnekMath::Matrix
  def get_matrix
    matrix = SnekMath::Matrix.new(area[0].length, area.length, 'empty')
    area.each_with_index do |row, y|
      row.each_with_index do |cell, x|
        matrix.set(x, y, cell)
      end
    end
    matrix
  end



  class << self

    # Default arena 25x25 cells and a wall
    def default_arena
      [
          %w(wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall)
      ]
    end

    # Default arena 15x15 cells and a wall
    def default_small_arena
      [
          %w(wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall empty empty empty empty empty empty empty empty empty empty empty empty empty empty empty wall),
          %w(wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall wall)
      ]
    end



  end
end
