Compare commits
5 Commits
master
...
plain-thir
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f5f4145e9 | |||
| 50508da8f8 | |||
| 8b74af11c6 | |||
| 825d22e827 | |||
| 381f67f93b |
@ -21,10 +21,12 @@
|
||||
// require_tree .
|
||||
|
||||
|
||||
// // If not your turn, poll the table
|
||||
$(document).ready(function(){
|
||||
setInterval(function() {
|
||||
// $('#table-component').load("#{request.path} #table-component");
|
||||
$('#play-to-beat').load("#{request.path} #play-to-beat");
|
||||
$('#play-buttons').load("#{request.path} #play-buttons");
|
||||
if ( $('.taking-turn.player[data-soft-token=' + soft_token + ']').length < 1 ) {
|
||||
$('#flash_message').load(window.location.pathname +" #flash_message");
|
||||
$('#table-component').load(window.location.pathname +" #table-component");
|
||||
}
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
@ -35,7 +35,13 @@ class TablesController < ApplicationController
|
||||
# TODO refactor to ensure play for 2nd and 3rd place
|
||||
|
||||
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.reload
|
||||
end
|
||||
|
||||
@ -16,7 +16,7 @@ class Player < ActiveRecord::Base
|
||||
|
||||
def display_name
|
||||
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 "Empty"
|
||||
end
|
||||
@ -36,6 +36,7 @@ class Player < ActiveRecord::Base
|
||||
self.game.play_to_beat_id = nil
|
||||
end
|
||||
self.game.save
|
||||
return "pass"
|
||||
end
|
||||
|
||||
def runs
|
||||
|
||||
@ -30,6 +30,10 @@ class SeatPolicy
|
||||
true
|
||||
end
|
||||
|
||||
def stand?
|
||||
true # TODO check that user is sitting here
|
||||
end
|
||||
|
||||
def add_bot?
|
||||
true
|
||||
end
|
||||
|
||||
@ -7,7 +7,7 @@ class TablePolicy
|
||||
end
|
||||
|
||||
def index?
|
||||
@current_user.admin?
|
||||
@current_user.admin? || true
|
||||
end
|
||||
|
||||
def show?
|
||||
@ -24,7 +24,7 @@ class TablePolicy
|
||||
end
|
||||
|
||||
def play_now?
|
||||
@current_user.admin? || @current_user.email == "bort@13.24x7.hk"
|
||||
true
|
||||
end
|
||||
|
||||
def new_game?
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
.original_flash_message_code
|
||||
.original_flash_message_code#flash_message
|
||||
- flash.each do |key, value|
|
||||
%div{class: "alert alert-#{key}"}
|
||||
= value
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<nav>
|
||||
<ul>
|
||||
<%# <li><%= link_to 'Main Menu', root_path %1></li> %>
|
||||
<li><%= link_to 'Main Menu', root_path %></li>
|
||||
<% if policy(:table).index? %>
|
||||
<li><%= link_to 'Tables', tables_path %></li>
|
||||
<% end %>
|
||||
|
||||
@ -22,9 +22,9 @@
|
||||
<%= yield %>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<%= render "layouts/footer" %>
|
||||
</footer>
|
||||
<%#<footer>%>
|
||||
<%#<%= render "layouts/footer" %>
|
||||
<%#</footer>%>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
|
||||
#main-menu
|
||||
- if policy(:table).play_now?
|
||||
= link_to 'Play', play_now_path
|
||||
= link_to 'Play Now', play_now_path
|
||||
- else
|
||||
Soon
|
||||
-# = link_to 'Browse Tables', tables_path
|
||||
-# = link_to 'Tutorial', tutorial_path
|
||||
-# = link_to 'About', page_path('about')
|
||||
= link_to 'Browse Tables', tables_path
|
||||
= link_to 'Tutorial', tutorial_path
|
||||
= link_to 'About', page_path('about')
|
||||
|
||||
@ -14,8 +14,16 @@ feature 'Bot takes turn', type: :feature do
|
||||
expect(page).to have_content "BotPlayer"
|
||||
@button = page.find_button('Sit', match: :first).click
|
||||
click_button "Start"
|
||||
click_button 'Pass'
|
||||
expect(page).to have_content "Bot is passes"
|
||||
# click_button 'Pass'
|
||||
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
|
||||
|
||||
scenario 'bot player plays single' do
|
||||
|
||||
@ -4,8 +4,8 @@ require 'spec_helper'
|
||||
require File.expand_path('../../config/environment', __FILE__)
|
||||
require 'rspec/rails'
|
||||
# Add additional requires below this line. Rails is not loaded until this point!
|
||||
`trash tmp/capybara/*`
|
||||
require 'capybara-screenshot/rspec'
|
||||
# `trash tmp/capybara/*`
|
||||
# require 'capybara-screenshot/rspec'
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc, in
|
||||
# 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, { Silent: true } # To clean up your test output
|
||||
#asset_hosts = {
|
||||
# staging: 'http://13staging.owlephant.icu',
|
||||
# development: 'http://localhost:3000',
|
||||
# test: 'http://localhost:3000'
|
||||
#}
|
||||
Capybara.server = :puma
|
||||
|
||||
#if ENV['RAILS_ENV'] == 'staging'
|
||||
# #Capybara.run_server = false
|
||||
# Capybara.app_host = asset_hosts[ENV['RAILS_ENV'].to_sym]
|
||||
#end
|
||||
#Capybara.asset_host = asset_hosts[ENV['RAILS_ENV'].to_sym]
|
||||
Capybara.register_driver :firefox do |app|
|
||||
Capybara::Selenium::Driver.new(app, browser: :firefox)
|
||||
end
|
||||
|
||||
# Capybara.default_driver = :firefox
|
||||
# Capybara.javascript_driver = :chrome
|
||||
Capybara.javascript_driver = :selenium_chrome_headless
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user