From 05a99a5715d700854cce1240422ce06ce3199520 Mon Sep 17 00:00:00 2001 From: Lucas Paulger Date: Thu, 4 Dec 2014 23:10:05 +0200 Subject: [PATCH] removed wait when playing invalid card fixes #59 --- app/scripts/gameStates/PlayState.js | 19 ++++++++++--------- test/spec/modulesSpec/PlayerModuleSpec.js | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/scripts/gameStates/PlayState.js b/app/scripts/gameStates/PlayState.js index ac767f5..4820362 100644 --- a/app/scripts/gameStates/PlayState.js +++ b/app/scripts/gameStates/PlayState.js @@ -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); @@ -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); } }; diff --git a/test/spec/modulesSpec/PlayerModuleSpec.js b/test/spec/modulesSpec/PlayerModuleSpec.js index 9eee114..96e0e44 100644 --- a/test/spec/modulesSpec/PlayerModuleSpec.js +++ b/test/spec/modulesSpec/PlayerModuleSpec.js @@ -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() {