Merge branch 'resync-hand' of https://github.com/uecasm/PretendYoureXyzzy into uecasm-resync-hand
This commit is contained in:
commit
2392883c32
|
@ -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;
|
||||
|
|
|
@ -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_();
|
||||
|
||||
|
|
Loading…
Reference in New Issue