# frozen_string_literal: true

# Use of abilities in this application is to permit controller actions.
# ApplicationController should have "check_authorization" included at the top,
# and this will force any new controller actions to be assigned here before
# they can be invoked.
#
# For more information:
# https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities
# https://github.com/CanCanCommunity/cancancan/wiki/Non-RESTful-Controllers
class Ability
  include CanCan::Ability

  def initialize(player)
    if player.type == 'player'
      can %i[show], Player
      can %i[index show create update multi_delete], Character
      can %i[random], Distinction
      can %i[next], :launch
      can %i[index create destroy], :sample_item
    else
      logger.info "Unhandled player type: #{player.type}"
    end
  end
end
