Skip to content

Commit

Permalink
fix table card bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
leondelee committed Sep 6, 2018
1 parent 2f4d402 commit 84e3c2a
Show file tree
Hide file tree
Showing 8 changed files with 1,451 additions and 19 deletions.
589 changes: 589 additions & 0 deletions core/extra/card.py

Large diffs are not rendered by default.

824 changes: 824 additions & 0 deletions core/extra/utils.py

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions core/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def handle_call_score(self, score):
if score > self.table.max_call_score:
self.table.max_call_score = score
self.table.max_call_score_turn = self.seat

response = [Pt.RSP_CALL_SCORE, self.uid, score, call_end]
for p in self.table.players:
p.send(response)
Expand All @@ -75,18 +74,20 @@ 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:
self.table.on_game_over(self)
return

response = [Pt.RSP_SHOT_POKER, self.uid, pokers]
for p in self.table.players:
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)

def join_table(self, t):
self.ready = True
self.table = t
Expand Down
Binary file added core/res/encoding.npy
Binary file not shown.
2 changes: 1 addition & 1 deletion core/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def reset(self):
self.last_shot_poker = []
self.players[0].send([Pt.RSP_RESTART])
for player in self.players:
player.join_table(self)
# player.join_table(self)
player.hand_pokers = []
if self.is_full():
self.deal_poker()
Expand Down
38 changes: 27 additions & 11 deletions static/js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ PG.Game.prototype = {
this.roomId = roomId;
},

debug_log(obj) {
console.log('*******');
console.log(obj);
console.log('********');
},

create: function () {
this.stage.backgroundColor = '#182d3b';

Expand Down Expand Up @@ -92,6 +98,7 @@ PG.Game.prototype = {
var score = packet[2];
var callend = packet[3];
this.whoseTurn = this.uidToSeat(playerId);
//this.debug_log(playerId);

var hanzi = ['不叫', "一分", "两分", "三分"];
this.players[this.whoseTurn].say(hanzi[score]);
Expand Down Expand Up @@ -129,7 +136,7 @@ PG.Game.prototype = {
function gameOver() {
alert(this.players[this.whoseTurn].isLandlord ? "地主赢" : "农民赢");
PG.Socket.send([PG.Protocol.REQ_RESTART]);
this.cleanWorld(loserASeat, loserBSeat);
this.cleanWorld();
}
this.game.time.events.add(3000, gameOver, this);
break;
Expand All @@ -145,14 +152,22 @@ 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';
cleanWorld: function () {
for (i =0; i < 3; i ++) {
this.players[i].cleanPokers();
try {
this.players[i].uiLeftPoker.kill();
}
catch (err) {
}
this.players[i].uiHead.frameName = 'icon_farmer.png';
}

for (var i = 0; i < this.tablePoker.length; i++) {
var p = this.tablePokerPic[this.tablePoker[i]];
// p.kill();
p.destroy();
}
},

restart: function () {
Expand All @@ -170,10 +185,10 @@ PG.Game.prototype = {
this.players.push(PG.createPlay(0, this));
this.players.push(PG.createPlay(1, this));
this.players.push(PG.createPlay(2, this));
//this.players[0].updateInfo(this.uid, this.username);
player_id = [1, 11, 12];
for (var i = 0; i < 3; i++) {
//this.players[i].uiHead.kill();
this.players[i].updateInfo(this.players[i].uid, ' ');
this.players[i].updateInfo(player_id[i], ' ');
}

// this.send_message([PG.Protocol.REQ_DEAL_POKEER, -1]);
Expand All @@ -185,6 +200,7 @@ PG.Game.prototype = {

uidToSeat: function (uid) {
for (var i = 0; i < 3; i++) {
// this.debug_log(this.players[i].uid);
if (uid == this.players[i].uid)
return i;
}
Expand Down
1 change: 1 addition & 0 deletions static/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ PG.Player.prototype.cleanPokers = function () {
var p = this.findAPoker(pid);
p.kill();
}
this.pokerInHand = [];
}

PG.Player.prototype.initShotLayer = function () {
Expand Down
1 change: 1 addition & 0 deletions static/js/player_net.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ PG.NetPlayer.prototype.cleanPokers = function () {
var p = this.findAPoker(pid);
p.kill();
}
this.pokerInHand = [];
}

PG.NetPlayer.prototype.dealPokerAnim = function (p, i) {
Expand Down

0 comments on commit 84e3c2a

Please sign in to comment.