Rails.application.routes.draw do
  resources :metapurses do
    member do
      get 'data'
    end
  end
  get '/games', to: "visitors#games_index"
  resources :rooms do
    resources :messages
  end
  resources :commands do
    member do
      get 'run'
    end
  end
  resources :bots do
    member do
      get 'telegram_listen'
    end
  end
  resources :social_links
  resources :profiles do
    member do
      get :followers
    end
  end
  resources :tokens do
    get 'add_existing', on: :new
    member do
      get 'refresh'
      get 'launch'
    end
  end
  resources :projects
  resources :doodads
  resources :canisters
  resources :players
  resources :tables do
    member do
      post 'new_game'
      post 'end_game'
    end
    resources :seats do
      member do
        patch 'sit'
        patch 'stand'
      end
    end
    resources :games do
      # member do
      #   post :join
      # end
    end
  end

  resources :seats do
    member do
      post 'sit'
      post 'stand'
      post 'add_bot'
      post 'remove_bot'
      post 'empty'
      post 'remove_player'
    end
  end
 
  resources :games do
    member do
      get 'my-inventory'
      post 'start'
      post 'join'
      post 'play_hand'
    end
    resources :seats do
      member do
        patch 'sit'
        patch 'stand'
      end
    end
  end

  constraints query_string: /website=theneedfuldo/ do
    root to: 'doodads#index', as: :needful_root
  end
  constraints host: 'theneedfuldo.tendy.zone' do
    root to: 'projects#show', id: 2, as: :needful_host_root
  end
  get '/play-now', to: 'tables#play_now', as: 'play_now'
  get '/tutorial', to: 'tables#tutorial', as: 'tutorial'
  devise_for :users, controllers: { registrations: "users/registrations" }
  get '/loaderio-456644f4db1fcd1e8578be882d2fc476.txt', to: redirect('/assets/loaderio-456644f4db1fcd1e8578be882d2fc476.txt')
  get '/loaderio-eb4afd672bf5b9af467fbadcba243f26.txt', to: redirect('/assets/loaderio-eb4afd672bf5b9af467fbadcba243f26.txt')
  get '/calls', to: 'calls#root'
  get '/wallet', to: 'visitors#wallet'
  resources :calls, only: :create
  mount ActionCable.server, at: '/cable'
  resources :video_rooms, only: [:new, :create, :show]
  resources :users do
    member do
      get :following
    end
  end
  resources :relationships,       only: [:create, :destroy]
  resources :visitors,       only: [:index]
  resources :microposts,          only: [:create, :destroy]

  devise_scope :user do
    authenticated do
      root 'users#home', as: :authenticated_root
    end

    unauthenticated do
      root 'visitors#index', as: :unauthenticated_root
    end
  end
  root to: 'visitors#index'
  get '/public', to: "visitors#index"

end
