diff --git a/WebContent/js/cah.app.js b/WebContent/js/cah.app.js index 11801b9..723ab32 100644 --- a/WebContent/js/cah.app.js +++ b/WebContent/js/cah.app.js @@ -163,6 +163,17 @@ function chatsubmit_click(game_id, parent_element) { // this could also be an IP address ajax = cah.Ajax.build(cah.$.AjaxOperation.BAN).withNickname(text.split(' ')[0]); break; + case 'hand': + if (game_id !== null) { + var game = cah.currentGames[game_id]; + if (game) { + game.removeAllCards(); + } + ajax = cah.Ajax.build(cah.$.AjaxOperation.GET_CARDS).withGameId(game_id); + } else { + cah.log.error("This command only works in a game."); + } + break; case 'names': ajax = cah.Ajax.build(cah.$.AjaxOperation.NAMES); break; diff --git a/WebContent/js/cah.game.js b/WebContent/js/cah.game.js index f3c4d8d..2e46ce5 100644 --- a/WebContent/js/cah.game.js +++ b/WebContent/js/cah.game.js @@ -472,6 +472,24 @@ cah.Game.prototype.removeCardFromHand = function(card) { this.resizeHandCards_(); }; +/** + * Remove all cards from the screen. + */ +cah.Game.prototype.removeAllCards = function() { + var handCount = this.hand_.length; + for ( var i = 0; i < handCount; i++) { + this.removeCardFromHand(this.hand_[0]); + } + this.handSelectedCard_ = null; + $(".confirm_card", this.element_).attr("disabled", "disabled"); + $(".game_black_card", this.element_).empty(); + for ( var index in this.roundCards_) { + $(this.roundCards_[index]).off(".round"); + } + this.roundCards_ = {}; + $(".game_white_cards", this.element_).empty(); +}; + /** * Set the round white cards. * @@ -1245,19 +1263,8 @@ cah.Game.prototype.stateChange = function(data) { switch (this.state_) { case cah.$.GameState.LOBBY: - var handCount = this.hand_.length; - for ( var i = 0; i < handCount; i++) { - this.removeCardFromHand(this.hand_[0]); - } - this.handSelectedCard_ = null; + this.removeAllCards(); this.judge_ = null; - $(".confirm_card", this.element_).attr("disabled", "disabled"); - $(".game_black_card", this.element_).empty(); - for ( var index in this.roundCards_) { - $(this.roundCards_[index]).off(".round"); - } - this.roundCards_ = {}; - $(".game_white_cards", this.element_).empty(); this.showOptions_();