class Minesweeprb::Commands::Play

def execute

def execute
  init_screen
  use_default_colors
  start_color
  curs_set(0)
  noecho
  self.ESCDELAY = 1
  mousemask(BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED | BUTTON4_CLICKED)
  loop do
    template = prompt_size
    break if template.nil?
    game = Game.new(**template.to_h, sprites: @theme.sprites)
    Gameboard.new(game, theme: @theme).draw
  end
ensure
  close_screen
end

def initialize(options)

def initialize(options)
  @options = options
  @theme = @options[:theme] ? Theme[@options[:theme]] : Theme.default
end

def prompt_size

def prompt_size
  screen_rows, screen_cols = IO.console.winsize
  options = SIZES.map do |tmpl|
    too_tall = tmpl.height + BOARD_CHROME_ROWS > screen_rows
    too_wide = (tmpl.width * 2) - 1 > screen_cols
    disabled = '(screen too small)' if too_tall || too_wide
    {
      disabled: disabled,
      name: tmpl.label,
      value: tmpl,
    }
  end
  options << { name: 'Quit', value: nil }
  Menu.select('Choose a size:', options)
end