Skip to content

Commit

Permalink
fix who-wins bug
Browse files Browse the repository at this point in the history
  • Loading branch information
leondelee committed Sep 6, 2018
1 parent 84e3c2a commit 9cf1d56
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions core/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ def handle_shot_poker(self, pokers):
self.table.last_shot_poker = pokers
for p in pokers:
self.hand_pokers.remove(p)
if not self.hand_pokers:
self.table.on_game_over(self)
return

import debug
if self.uid == debug.over_in_advance:
Expand All @@ -88,6 +85,10 @@ def handle_shot_poker(self, pokers):
p.send(response)
logger.info('Player[%d] shot[%s]', self.uid, str(pokers))

if not self.hand_pokers:
self.table.on_game_over(self)
return

def join_table(self, t):
self.ready = True
self.table = t
Expand Down
2 changes: 1 addition & 1 deletion core/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def on_game_over(self, winner):
# return
coin = self.room.entrance_fee * self.call_score * self.multiple
for p in self.players:
response = [Pt.RSP_GAME_OVER, p.uid, coin if p != winner else coin * 2 - 100]
response = [Pt.RSP_GAME_OVER, winner.uid, coin if p != winner else coin * 2 - 100]
for pp in self.players:
if pp != p:
response.append([pp.uid, *pp.hand_pokers])
Expand Down
3 changes: 2 additions & 1 deletion handlers/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ class Protocol(IntEnum):
RSP_CHAT = 44

REQ_RESTART = 45
RSP_RESTART = 46
RSP_RESTART = 46

1 change: 1 addition & 0 deletions static/js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ PG.Game.prototype = {
// this.players[loserASeat].pokerInHand = [];

this.whoseTurn = this.uidToSeat(winner);

function gameOver() {
alert(this.players[this.whoseTurn].isLandlord ? "地主赢" : "农民赢");
PG.Socket.send([PG.Protocol.REQ_RESTART]);
Expand Down

0 comments on commit 9cf1d56

Please sign in to comment.