Skip to content

Commit

Permalink
removed wait when playing invalid card
Browse files Browse the repository at this point in the history
fixes #59
  • Loading branch information
lpaulger committed Dec 4, 2014
1 parent a626932 commit 05a99a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions app/scripts/gameStates/PlayState.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ define(['jquery','gameStates/BaseState'],function($, BaseState){
setInitialCurrentPlayer.call(this);
if(this.game.currentPlayer === this.p2)
processAiTurn.call(this);
else
this.mediator.publish('messages-add', 'Select a card to play');
}

setAction.call(this);
Expand All @@ -34,18 +32,21 @@ define(['jquery','gameStates/BaseState'],function($, BaseState){
try {
this.p1.playCard(options.index);
switchPlayer.call(this);

if(this.p1.isWinner())
this.mediator.publish('transition', 'Summary', true);
else if(!isEndOfRound.call(this)){
this.renderOnly();
this.mediator.publish('transition', 'Play', true);
} else {
this.mediator.publish('transition', 'Play', false);
}
} catch(e) {
if(e.message === 'No Playable Cards')
this.mediator.publish('messages-add', 'No Playable Cards, Press \'Go!\'');
else if(e.message === 'Invalid Playable Card')
this.mediator.publish('messages-add', 'Try another card');
}
if(this.p1.isWinner())
this.mediator.publish('transition', 'Summary', true);
else if(!isEndOfRound.call(this)){
this.renderOnly();
this.mediator.publish('transition', 'Play', true);
} else {

this.mediator.publish('transition', 'Play', false);
}
};
Expand Down
4 changes: 2 additions & 2 deletions test/spec/modulesSpec/PlayerModuleSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ define(['modules/PlayerModule'], function(Player) {
describe('if 2 cards selected', function(){

beforeEach(function(){
_player.hand[0].selected = 'selected';
_player.hand[1].selected = 'selected';
_player.hand[0].selected = 'selected';
_player.hand[1].selected = 'selected';
});

it('should put cards in crib owners crib', function() {
Expand Down

0 comments on commit 05a99a5

Please sign in to comment.