Compare commits
5 Commits
master
...
plain-thir
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f5f4145e9 | |||
| 50508da8f8 | |||
| 8b74af11c6 | |||
| 825d22e827 | |||
| 381f67f93b |
@ -21,10 +21,12 @@
|
|||||||
// require_tree .
|
// require_tree .
|
||||||
|
|
||||||
|
|
||||||
|
// // If not your turn, poll the table
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
// $('#table-component').load("#{request.path} #table-component");
|
if ( $('.taking-turn.player[data-soft-token=' + soft_token + ']').length < 1 ) {
|
||||||
$('#play-to-beat').load("#{request.path} #play-to-beat");
|
$('#flash_message').load(window.location.pathname +" #flash_message");
|
||||||
$('#play-buttons').load("#{request.path} #play-buttons");
|
$('#table-component').load(window.location.pathname +" #table-component");
|
||||||
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -35,7 +35,13 @@ 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?")
|
||||||
@game.controlling_player.auto_play
|
bot_action = @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
|
||||||
|
|||||||
@ -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" if self.is_bot?
|
return "BotPlayer #{self.id}" 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,6 +36,7 @@ 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
|
||||||
|
|||||||
@ -30,6 +30,10 @@ 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
|
||||||
|
|||||||
@ -7,7 +7,7 @@ class TablePolicy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def index?
|
def index?
|
||||||
@current_user.admin?
|
@current_user.admin? || true
|
||||||
end
|
end
|
||||||
|
|
||||||
def show?
|
def show?
|
||||||
@ -24,7 +24,7 @@ class TablePolicy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def play_now?
|
def play_now?
|
||||||
@current_user.admin? || @current_user.email == "bort@13.24x7.hk"
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_game?
|
def new_game?
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
.original_flash_message_code
|
.original_flash_message_code#flash_message
|
||||||
- flash.each do |key, value|
|
- flash.each do |key, value|
|
||||||
%div{class: "alert alert-#{key}"}
|
%div{class: "alert alert-#{key}"}
|
||||||
= value
|
= value
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<%# <li><%= link_to 'Main Menu', root_path %1></li> %>
|
<li><%= link_to 'Main Menu', root_path %></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 %>
|
||||||
|
|||||||
@ -22,9 +22,9 @@
|
|||||||
<%= yield %>
|
<%= yield %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer>
|
<%#<footer>%>
|
||||||
<%= render "layouts/footer" %>
|
<%#<%= render "layouts/footer" %>
|
||||||
</footer>
|
<%#</footer>%>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
#main-menu
|
#main-menu
|
||||||
- if policy(:table).play_now?
|
- if policy(:table).play_now?
|
||||||
= link_to 'Play', play_now_path
|
= link_to 'Play Now', 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')
|
||||||
|
|||||||
@ -14,8 +14,16 @@ 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'
|
||||||
expect(page).to have_content "Bot is passes"
|
bot_player = @game.players.first
|
||||||
|
# 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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -1,15 +1,9 @@
|
|||||||
Capybara.server = :puma # Until your setup is working
|
Capybara.server = :puma
|
||||||
# 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'
|
|
||||||
#}
|
|
||||||
|
|
||||||
#if ENV['RAILS_ENV'] == 'staging'
|
Capybara.register_driver :firefox do |app|
|
||||||
# #Capybara.run_server = false
|
Capybara::Selenium::Driver.new(app, browser: :firefox)
|
||||||
# Capybara.app_host = asset_hosts[ENV['RAILS_ENV'].to_sym]
|
end
|
||||||
#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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user