Compare commits

..

No commits in common. "7f5f4145e9266d994d37e155e83690cb4ff2d5e4" and "8e2cbb61466c0fb8d9800c2d7251ade32d6d68d9" have entirely different histories.

12 changed files with 32 additions and 47 deletions

View File

@ -21,12 +21,10 @@
// require_tree . // require_tree .
// // If not your turn, poll the table
$(document).ready(function(){ $(document).ready(function(){
setInterval(function() { setInterval(function() {
if ( $('.taking-turn.player[data-soft-token=' + soft_token + ']').length < 1 ) { // $('#table-component').load("#{request.path} #table-component");
$('#flash_message').load(window.location.pathname +" #flash_message"); $('#play-to-beat').load("#{request.path} #play-to-beat");
$('#table-component').load(window.location.pathname +" #table-component"); $('#play-buttons').load("#{request.path} #play-buttons");
}
}, 2000); }, 2000);
}); });

View File

@ -35,13 +35,7 @@ class TablesController < ApplicationController
# TODO refactor to ensure play for 2nd and 3rd place # TODO refactor to ensure play for 2nd and 3rd place
if @game.controlling_player.try("is_bot?") if @game.controlling_player.try("is_bot?")
bot_action = @game.controlling_player.auto_play @game.controlling_player.auto_play
flash[:notice] ||= ""
if bot_action == "pass" # TODO bot passes notify
flash[:notice] << " #{@game.controlling_player.display_name} passed."
else
flash[:notice] << " #{@game.controlling_player.display_name} played #{bot_action}"
end
@game.save @game.save
@game.reload @game.reload
end end

View File

@ -16,7 +16,7 @@ class Player < ActiveRecord::Base
def display_name def display_name
return user.email.split("@")[0] if self.user return user.email.split("@")[0] if self.user
return "BotPlayer #{self.id}" if self.is_bot? return "BotPlayer" if self.is_bot?
return ("Guest" + self.soft_token)[0..9] if self.soft_token return ("Guest" + self.soft_token)[0..9] if self.soft_token
return "Empty" return "Empty"
end end
@ -36,7 +36,6 @@ class Player < ActiveRecord::Base
self.game.play_to_beat_id = nil self.game.play_to_beat_id = nil
end end
self.game.save self.game.save
return "pass"
end end
def runs def runs

View File

@ -30,10 +30,6 @@ class SeatPolicy
true true
end end
def stand?
true # TODO check that user is sitting here
end
def add_bot? def add_bot?
true true
end end

View File

@ -7,7 +7,7 @@ class TablePolicy
end end
def index? def index?
@current_user.admin? || true @current_user.admin?
end end
def show? def show?
@ -24,7 +24,7 @@ class TablePolicy
end end
def play_now? def play_now?
true @current_user.admin? || @current_user.email == "bort@13.24x7.hk"
end end
def new_game? def new_game?

View File

@ -1,4 +1,4 @@
.original_flash_message_code#flash_message .original_flash_message_code
- flash.each do |key, value| - flash.each do |key, value|
%div{class: "alert alert-#{key}"} %div{class: "alert alert-#{key}"}
= value = value

View File

@ -1,6 +1,6 @@
<nav> <nav>
<ul> <ul>
<li><%= link_to 'Main Menu', root_path %></li> <%# <li><%= link_to 'Main Menu', root_path %1></li> %>
<% if policy(:table).index? %> <% if policy(:table).index? %>
<li><%= link_to 'Tables', tables_path %></li> <li><%= link_to 'Tables', tables_path %></li>
<% end %> <% end %>

View File

@ -22,9 +22,9 @@
<%= yield %> <%= yield %>
</div> </div>
<%#<footer>%> <footer>
<%#<%= render "layouts/footer" %> <%= render "layouts/footer" %>
<%#</footer>%> </footer>
</body> </body>
</html> </html>

View File

@ -3,9 +3,9 @@
#main-menu #main-menu
- if policy(:table).play_now? - if policy(:table).play_now?
= link_to 'Play Now', play_now_path = link_to 'Play', play_now_path
- else - else
Soon Soon
= link_to 'Browse Tables', tables_path -# = link_to 'Browse Tables', tables_path
= link_to 'Tutorial', tutorial_path -# = link_to 'Tutorial', tutorial_path
= link_to 'About', page_path('about') -# = link_to 'About', page_path('about')

View File

@ -14,16 +14,8 @@ feature 'Bot takes turn', type: :feature do
expect(page).to have_content "BotPlayer" expect(page).to have_content "BotPlayer"
@button = page.find_button('Sit', match: :first).click @button = page.find_button('Sit', match: :first).click
click_button "Start" click_button "Start"
# click_button 'Pass' click_button 'Pass'
bot_player = @game.players.first expect(page).to have_content "Bot is passes"
# set bot inventory value low so has to pass
# kind of hacky
bot_player.inventory.map{|i| i.value = 2; i.save}
@game = @table.current_game
@card_to_play = @game.controlling_player.inventory.first
find("[data-card-name='#{@card_to_play.to_s}']").click
click_button 'Play Hand'
expect(page).to have_content "#{bot_player.display_name} passed."
end end
scenario 'bot player plays single' do scenario 'bot player plays single' do

View File

@ -4,8 +4,8 @@ require 'spec_helper'
require File.expand_path('../../config/environment', __FILE__) require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails' require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point! # Add additional requires below this line. Rails is not loaded until this point!
# `trash tmp/capybara/*` `trash tmp/capybara/*`
# require 'capybara-screenshot/rspec' require 'capybara-screenshot/rspec'
# Requires supporting ruby files with custom matchers and macros, etc, in # Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are

View File

@ -1,9 +1,15 @@
Capybara.server = :puma Capybara.server = :puma # Until your setup is working
# Capybara.server = :puma, { Silent: true } # To clean up your test output
#asset_hosts = {
# staging: 'http://13staging.owlephant.icu',
# development: 'http://localhost:3000',
# test: 'http://localhost:3000'
#}
Capybara.register_driver :firefox do |app| #if ENV['RAILS_ENV'] == 'staging'
Capybara::Selenium::Driver.new(app, browser: :firefox) # #Capybara.run_server = false
end # Capybara.app_host = asset_hosts[ENV['RAILS_ENV'].to_sym]
#end
#Capybara.asset_host = asset_hosts[ENV['RAILS_ENV'].to_sym]
# Capybara.default_driver = :firefox
# Capybara.javascript_driver = :chrome
Capybara.javascript_driver = :selenium_chrome_headless Capybara.javascript_driver = :selenium_chrome_headless