Add /hand command to resync hand
This commit is contained in:
parent
7e7be6c54e
commit
5da2e97f53
|
@ -163,6 +163,17 @@ function chatsubmit_click(game_id, parent_element) {
|
||||||
// this could also be an IP address
|
// this could also be an IP address
|
||||||
ajax = cah.Ajax.build(cah.$.AjaxOperation.BAN).withNickname(text.split(' ')[0]);
|
ajax = cah.Ajax.build(cah.$.AjaxOperation.BAN).withNickname(text.split(' ')[0]);
|
||||||
break;
|
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':
|
case 'names':
|
||||||
ajax = cah.Ajax.build(cah.$.AjaxOperation.NAMES);
|
ajax = cah.Ajax.build(cah.$.AjaxOperation.NAMES);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -462,6 +462,24 @@ cah.Game.prototype.removeCardFromHand = function(card) {
|
||||||
this.resizeHandCards_();
|
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.
|
* Set the round white cards.
|
||||||
*
|
*
|
||||||
|
@ -1160,19 +1178,8 @@ cah.Game.prototype.stateChange = function(data) {
|
||||||
|
|
||||||
switch (this.state_) {
|
switch (this.state_) {
|
||||||
case cah.$.GameState.LOBBY:
|
case cah.$.GameState.LOBBY:
|
||||||
var handCount = this.hand_.length;
|
this.removeAllCards();
|
||||||
for ( var i = 0; i < handCount; i++) {
|
|
||||||
this.removeCardFromHand(this.hand_[0]);
|
|
||||||
}
|
|
||||||
this.handSelectedCard_ = null;
|
|
||||||
this.judge_ = null;
|
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_();
|
this.showOptions_();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue