Stashy stashy

This commit is contained in:
Jesse C. Fisher 2015-11-25 00:47:33 -08:00
parent 2fd3351101
commit a4fb8e6613
11 changed files with 33 additions and 55 deletions

View File

@ -35,7 +35,7 @@ guard :bundler do
files.each { |file| watch(helper.real_path(file)) } files.each { |file| watch(helper.real_path(file)) }
end end
guard 'rails', host: '127.0.0.1' do guard 'rails', host: '0.0.0.0' do
watch('Gemfile.lock') watch('Gemfile.lock')
watch(%r{^(config|lib)/.*}) watch(%r{^(config|lib)/.*})
end end

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 KiB

View File

@ -20,6 +20,7 @@ var Inventory = React.createClass({
form={"player_controls_" + card.player_id} form={"player_controls_" + card.player_id}
type="checkbox" type="checkbox"
name="player_card_ids[]" name="player_card_ids[]"
data-card-name={card.rank.replace('11','J').replace('12','Q').replace('13','K').replace('14','A').replace('15','2') + ' ' + card.suit}
value={card.id} /> value={card.id} />
{/* TODO: Don't hard code face cards here */} {/* TODO: Don't hard code face cards here */}
{/* <span>{card.rank.replace('11','J').replace('12','Q').replace('13','K').replace('14','A').replace('15','2')} {card.suit}</span> */} {/* <span>{card.rank.replace('11','J').replace('12','Q').replace('13','K').replace('14','A').replace('15','2')} {card.suit}</span> */}

View File

@ -22,7 +22,11 @@ var Player = React.createClass({
player_id={this.props.id} player_id={this.props.id}
inventory={this.props.inventory} inventory={this.props.inventory}
controlling_player_id={this.props.game.controlling_player_id} /> ) controlling_player_id={this.props.game.controlling_player_id} /> )
: null } :
<div className='inventory'>
{[...Array(this.props.inventory_count)].map((card, index) => <img key={index} src='/assets/cards/png/back-pink.png' />)}
</div>
}
</div> </div>
); );
} }

View File

@ -1,38 +0,0 @@
// Hide Header on on scroll down
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('header > nav').outerHeight();
$(window).scroll(function(event){
didScroll = true;
});
setInterval(function() {
if (didScroll) {
hasScrolled();
didScroll = false;
}
}, 250);
function hasScrolled() {
var st = $(this).scrollTop();
// Make sure they scroll more than delta
if(Math.abs(lastScrollTop - st) <= delta)
return;
// If they scrolled down and are past the navbar, add class .nav-up.
// This is necessary so you never see what is "behind" the navbar.
if (st > lastScrollTop && st > navbarHeight){
// Scroll Down
$('header > nav').removeClass('nav-down').addClass('nav-up');
} else {
// Scroll Up
if(st + $(window).height() < $(document).height()) {
$('header > nav').removeClass('nav-up').addClass('nav-down');
}
}
lastScrollTop = st;
}

View File

@ -27,7 +27,7 @@ body
min-height: 100vh min-height: 100vh
margin: 0 margin: 0
background: image-url('backgrounds/felt-green.png') background: image-url('backgrounds/felt-green.png')
font-size: 4vmin font-size: 2vmin
a a
text-decoration: none text-decoration: none
@ -40,11 +40,10 @@ h1
header header
font-size: 3vmin font-size: 3vmin
margin-bottom: 10vmin
nav nav
padding: 1vmin padding: 1vmin
background: #222 background: #222
position: fixed //position: fixed
top: 0 top: 0
transition: top 0.2s ease-in-out transition: top 0.2s ease-in-out
width: 100% width: 100%

View File

@ -118,4 +118,11 @@ button
&:checked ~ img &:checked ~ img
box-shadow: 0px 0px 2px 6px cadetblue box-shadow: 0px 0px 2px 6px cadetblue
img img
width: 6vw width: 6vmin
border: 1px solid black
border-radius: .3vmin
.inventory
img
width: 6vmin
border: 1px solid black
border-radius: .3vmin

View File

@ -6,6 +6,7 @@ set :repo_url, 'git@bitbucket.org:jessecfisher/thirteen-tien-len.git'
set :assets_dir, %w(public/assets public/system) set :assets_dir, %w(public/assets public/system)
#set :local_assets_dir, %w(public/assets public/att) #set :local_assets_dir, %w(public/assets public/att)
set :branch, proc { `git rev-parse --abbrev-ref stash`.chomp }
#ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp } #ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
set :deploy_to, '/home/jesse/web/thirteen-tien-len' set :deploy_to, '/home/jesse/web/thirteen-tien-len'

View File

@ -21,7 +21,7 @@ feature 'Play a hand', type: :feature, js: true do
# Play the highest card # Play the highest card
@card_to_play = @player.inventory.last @card_to_play = @player.inventory.last
check @card_to_play.to_s find("[data-card-name='#{@card_to_play.to_s}'] ~ img").click
#click_button 'Play Hand' #click_button 'Play Hand'
click_button "play_hand_button_#{@player.id}" click_button "play_hand_button_#{@player.id}"
@ -39,7 +39,7 @@ feature 'Play a hand', type: :feature, js: true do
# Then I see the hand to beat is this play # Then I see the hand to beat is this play
scenario 'first play contains lowest card' do scenario 'first play contains lowest card' do
@card_to_play = @game.lowest_card @card_to_play = @game.lowest_card
check @card_to_play.to_s find("[data-card-name='#{@card_to_play.to_s}'] ~ img").click
#click_button 'Play Hand' #click_button 'Play Hand'
click_button "play_hand_button_#{@player.id}" click_button "play_hand_button_#{@player.id}"
#expect(page).to have_content(/Hand to beat.*#{@game.lowest_card.to_s}/) #expect(page).to have_content(/Hand to beat.*#{@game.lowest_card.to_s}/)
@ -54,7 +54,7 @@ feature 'Play a hand', type: :feature, js: true do
# Store initial state of players inventory # Store initial state of players inventory
@player_inventory = @player.inventory.join(' ') @player_inventory = @player.inventory.join(' ')
@card_to_play = @player.inventory.first @card_to_play = @player.inventory.first
check @card_to_play.to_s find("[data-card-name='#{@card_to_play.to_s}'] ~ img").click
#click_button 'Play Hand' #click_button 'Play Hand'
click_button "play_hand_button_#{@player.id}" click_button "play_hand_button_#{@player.id}"
#wait_for_ajax #wait_for_ajax
@ -71,7 +71,7 @@ feature 'Play a hand', type: :feature, js: true do
scenario 'invalid hand played cards are not removed from the players inventory' do scenario 'invalid hand played cards are not removed from the players inventory' do
#@game.reload #@game.reload
# Store initial state of players inventory # Store initial state of players inventory
@player_inventory = @player.inventory.join(' ') @initial_player_inventory = @player.inventory
# Create invalid hand # Create invalid hand
@cards_to_play = [] @cards_to_play = []
@ -79,7 +79,7 @@ feature 'Play a hand', type: :feature, js: true do
@cards_to_play << @player.inventory.first @cards_to_play << @player.inventory.first
# Select each card to play # Select each card to play
@cards_to_play.map {|card| check card.to_s } @cards_to_play.map {|card| find("[data-card-name='#{card.to_s}'] ~ img").click }
#click_button 'Play Hand' #click_button 'Play Hand'
click_button "play_hand_button_#{@player.id}" click_button "play_hand_button_#{@player.id}"
@ -87,7 +87,9 @@ feature 'Play a hand', type: :feature, js: true do
# TODO: Flash messages # TODO: Flash messages
#expect(page).to have_content("Invalid pair") #expect(page).to have_content("Invalid pair")
# Player inventory is rendered with played cards # Player inventory is rendered with played cards
expect(page).to have_content(@player_inventory) @initial_player_inventory.each do |card|
expect(page).to have_selector("[data-card-name='#{card.to_s}'] ~ img")
end
# TODO: This scenario is causing other scenarios to fail unless we slow down here # TODO: This scenario is causing other scenarios to fail unless we slow down here
sleep 1 sleep 1
# Player inventory method still returns played cards because the play was invalid # Player inventory method still returns played cards because the play was invalid
@ -106,7 +108,7 @@ feature 'Play a hand', type: :feature, js: true do
@controlling_player_index = @game.player_ids.index(@game.controlling_player_id) @controlling_player_index = @game.player_ids.index(@game.controlling_player_id)
@card_to_play = @player.inventory.first @card_to_play = @player.inventory.first
check @card_to_play.to_s find("[data-card-name='#{@card_to_play.to_s}'] ~ img").click
#click_button 'Play Hand' #click_button 'Play Hand'
click_button "play_hand_button_#{@player.id}" click_button "play_hand_button_#{@player.id}"
@ -131,7 +133,7 @@ feature 'Play a hand', type: :feature, js: true do
#@game.reload #@game.reload
@cards_to_play = [@game.controlling_player.player_cards.order(:value).first.to_s, @game.controlling_player.player_cards.order(:value).last.to_s] @cards_to_play = [@game.controlling_player.player_cards.order(:value).first.to_s, @game.controlling_player.player_cards.order(:value).last.to_s]
@cards_to_play.each do |card| @cards_to_play.each do |card|
check card find("[data-card-name='#{card.to_s}'] ~ img").click
end end
#click_button 'Play Hand' #click_button 'Play Hand'
click_button "play_hand_button_#{@player.id}" click_button "play_hand_button_#{@player.id}"
@ -140,7 +142,9 @@ feature 'Play a hand', type: :feature, js: true do
#:TODO: Flash messages #:TODO: Flash messages
#expect(page).to have_content("Invalid pair.") #expect(page).to have_content("Invalid pair.")
# expect inventory to remain unchanged # expect inventory to remain unchanged
expect(page).to have_content("#{@game.controlling_player.inventory.map {|c| c.to_s}.join ' '}") @game.controlling_player.inventory.each do |card|
expect(page).to have_selector("[data-card-name='#{card.to_s}'] ~ img")
end
# TODO: This scenario is causing other scenarios to fail unless we slow down here # TODO: This scenario is causing other scenarios to fail unless we slow down here
sleep 1 sleep 1
end end
@ -192,7 +196,7 @@ feature 'Play a hand', type: :feature, js: true do
@game.reload @game.reload
@player = @game.controlling_player @player = @game.controlling_player
@card_to_play = @player.inventory.first @card_to_play = @player.inventory.first
check @card_to_play.to_s find("[data-card-name='#{@card_to_play.to_s}'] ~ img").click
#click_button 'Play Hand' #click_button 'Play Hand'
click_button "play_hand_button_#{@player.id}" click_button "play_hand_button_#{@player.id}"