Skip to content

Commit

Permalink
fix self hand-poker display error
Browse files Browse the repository at this point in the history
  • Loading branch information
leondelee committed Sep 6, 2018
1 parent a4ce72d commit c5f77ab
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
3 changes: 3 additions & 0 deletions core/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ def handle_shot_poker(self, pokers):
p.send(response)
logger.info('Player[%d] shot[%s]', self.uid, str(pokers))

import debug
if self.uid == debug.over_in_advance:
self.table.on_game_over(self)
if not self.hand_pokers:
self.table.on_game_over(self)

Expand Down
2 changes: 0 additions & 2 deletions core/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ def call_score_end(self):
for p in self.players:
p.send(response)
logger.info('Player[%d] IS LANDLORD[%s]', self.turn_player.uid, str(self.pokers))
# winner = self.players[0]
# self.on_game_over(winner)

def go_next_turn(self):
self.whose_turn += 1
Expand Down
16 changes: 11 additions & 5 deletions static/js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,8 @@ PG.Game.prototype = {
this.whoseTurn = this.uidToSeat(winner);
function gameOver() {
alert(this.players[this.whoseTurn].isLandlord ? "地主赢" : "农民赢");
this.players[loserBSeat].cleanPokers();
this.players[loserASeat].cleanPokers();
this.players[loserBSeat].uiLeftPoker.kill();
this.players[loserASeat].uiLeftPoker.kill();
this.players[this.whoseTurn].uiHead.frameName = 'icon_farmer.png';
PG.Socket.send([PG.Protocol.REQ_RESTART]);
this.cleanWorld(loserASeat, loserBSeat);
}
this.game.time.events.add(3000, gameOver, this);
break;
Expand All @@ -149,6 +145,16 @@ PG.Game.prototype = {
}
},

cleanWorld: function (loserASeat, loserBSeat) {
this.players[loserBSeat].cleanPokers();
this.players[loserASeat].cleanPokers();
this.players[loserBSeat].uiLeftPoker.kill();
this.players[loserASeat].uiLeftPoker.kill();
this.players[this.whoseTurn].cleanPokers();
this.players[loserBSeat].uiLeftPoker.kill();
this.players[this.whoseTurn].uiHead.frameName = 'icon_farmer.png';
},

restart: function () {
this.players = [];
this.shotLayer = null;
Expand Down
10 changes: 10 additions & 0 deletions static/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ PG.Player.prototype.updateInfo = function (uid, name) {
}
};

PG.Player.prototype.cleanPokers = function () {

var length = this.pokerInHand.length;
for (var i = 0; i < length; i++) {
var pid = this.pokerInHand[i];
var p = this.findAPoker(pid);
p.kill();
}
}

PG.Player.prototype.initShotLayer = function () {
this.shotLayer = this.game.add.group();
var group = this.shotLayer;
Expand Down

0 comments on commit c5f77ab

Please sign in to comment.