Skip to content

Commit

Permalink
bugfix and improve demo ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Liming Xie committed Jan 8, 2015
1 parent 9c78727 commit c3f850a
Show file tree
Hide file tree
Showing 17 changed files with 251 additions and 79 deletions.
Binary file modified dump.rdb
Binary file not shown.
21 changes: 19 additions & 2 deletions lib/gamer.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,16 @@ Gamer.prototype.getName = function() {

Gamer.prototype.saveData = function( reply ){
var gamer = this;
var db = gamer.server.db;
if(typeof reply !== 'function') reply = function(err,ret){};

var db = null;
if(gamer.server) db = gamer.server.db;
else if(gamer.room) db = gamer.room.db;
else {
reply(500, 'db err');
return;
}

var p = gamer.profile;

var uid_key = 'user:#' + gamer.uid;
Expand All @@ -112,7 +121,15 @@ Gamer.prototype.saveData = function( reply ){

Gamer.prototype.refresh = function( reply ){
var gamer = this;
var db = gamer.server.db;
if(typeof reply !== 'function') reply = function(err,ret){};

var db = null;
if(gamer.server) db = gamer.server.db;
else if(gamer.room) db = gamer.room.db;
else {
reply(500, 'db err');
return;
}

var uid_key = 'user:#' + gamer.uid;
db.hgetall(uid_key, function(err,userinfo){
Expand Down
2 changes: 0 additions & 2 deletions lib/holdem_game.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,6 @@ HoldemGame.prototype.gamerMoveTurn = function(move) {

if(move) room.moveTurnToNext();

console.log( room.state, room.no_raise_counter + ' / ' + room.ingamers_count );

var deal_card = false;
if(room.no_raise_counter === room.ingamers_count) {
room.state ++;
Expand Down
22 changes: 11 additions & 11 deletions lib/holdem_poker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ var HIGH_CARD = 1, // 高牌, AQ953
ROYAL_FLUSH = 10; // 皇家同花顺, AKQJ10

var HOLDEM_PATTERNS = {
0: 'Invalid', // 错误
1: 'High Card', // 高牌
2: 'One Pair', // 一对
3: 'Two Pair', // 两对
4: 'Three of a Kind', // 三条
5: 'Straight', // 顺子
6: 'Flush', // 同花
7: 'Fullhouse', // 葫芦
8: 'Four of a Kind', // 四条
9: 'Straight Flush', // 同花顺
10: 'Royal Flush' // 皇家同花顺
0: 'invalid', // 错误
1: 'high card', // 高牌
2: 'one pair', // 一对
3: 'two pair', // 两对
4: 'three of a kind', // 三条
5: 'straight', // 顺子
6: 'flush', // 同花
7: 'fullhouse', // 葫芦
8: 'four of a kind', // 四条
9: 'straight flush', // 同花顺
10: 'royal flush' // 皇家同花顺
};

var Holdem = {
Expand Down
2 changes: 1 addition & 1 deletion lib/jinhua_game.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ JinhuaGame.prototype.gameStart = function() {
seat = gamer.seat;
in_seats.push( seat );

gamer.is_ready = false;
room.ready_gamers --;

gamer.is_ready = false;
gamer.is_ingame = true;

gamer.profile.coins -= ante;
Expand Down
14 changes: 7 additions & 7 deletions lib/jinhua_poker.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ var HIGH_CARD = 1, // 单张
THREE = 6; // 豹子

var JINHUA_PATTERNS = {
0: '错误',
1: '单张',
2: '对子',
3: '顺子',
4: '同花',
5: '同花顺',
6: '豹子'
0: 'invalid',
1: 'danzhang',
2: 'duizi',
3: 'shunzi',
4: 'tonghua',
5: 'tonghuashun',
6: 'baozi'
};

var Jinhua = {
Expand Down
1 change: 1 addition & 0 deletions lib/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ Room.prototype.onGamer_enter = function(req, reply) {
if(! ret) { reply(404, 'user ' + uid + ' not found'); return; }

var gamer = new Gamer().setProfile(ret);
gamer.room = room;
gamer.seat = -1;

room.gamers[ uid ] = gamer;
Expand Down
6 changes: 4 additions & 2 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
<body>
<div id='env'>
<h3 id="roomname">not in room</h3>
<ul id="list"></ul>
<div id='roomdesc'></div>
<h3 id='sharedcards'></h3>
<h3 id='pot'></h3>
<h3 id='countdown'></h3>
<ul id="seats"></ul>
<h3 id='mycards'></h3>
</div>
<div id='logs'>
<ul id="messages" class="list"></ul>
Expand All @@ -28,6 +30,6 @@ <h3 id='countdown'></h3>
<button id='send'>Send</button>
</form>
-->
<div id='cmds'></div>
<div id='cmds' class='inactive'></div>
</body>
</html>
19 changes: 19 additions & 0 deletions www/js/en.lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ hotjs.i18n.put('en', {
'pot': 'Pot',
'shared cards': 'Shared cards',
'private cards': 'Private cards',
'my cards': 'My cards',
'bet': 'Bet',
'ready': 'Ready',
'seecard': 'See Card',
'showcard': 'Show Card',
'call': 'Call',
'raise': 'Raise',
'fold': 'Fold/Give Up',
'check': 'Check',
'pk': 'PK',
'result': 'Result',
'win': 'Win',
Expand All @@ -54,4 +56,21 @@ hotjs.i18n.put('en', {
'email': 'Email',
'phone': 'Phone',
'uuid': 'UUID',
'invalid' : 'Invalid',
'danzhang': 'High Card',
'duizi': 'Pair',
'shunzi': 'Straight',
'tonghua': 'Flush',
'tonghuashun': 'Straight Flush',
'baozi': 'Three of a Kind',
'high card': 'High Card',
'one pair': 'One Pair',
'two pair': 'Two Pair',
'three of a kind': 'Three of a Kind',
'straight': 'Straight',
'flush': 'Flush',
'fullhouse': 'Fullhouse',
'four of a kind': 'Four of a Kind',
'straight flush': 'Straight Flush',
'royal flush': 'Royal Flush',
});
21 changes: 20 additions & 1 deletion www/js/zh.lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ hotjs.i18n.put('zh', {
'seconds': '秒',
'pot': '彩池',
'shared cards': '公牌',
'private cards': '私牌',
'private cards': '手牌',
'my cards': '我的牌',
'bet': '下注',
'ready': '准备',
'seecard': '看牌',
'showcard': '亮牌',
'call': '跟注',
'raise': '加注',
'fold': '盖牌/弃牌',
'check': '看牌',
'pk': '比牌',
'result': '结果',
'win': '胜',
Expand All @@ -55,4 +57,21 @@ hotjs.i18n.put('zh', {
'email': 'Email',
'phone': '电话号码',
'uuid': 'UUID',
'invalid' : '错误',
'danzhang': '单张',
'duizi': '对子',
'shunzi': '顺子',
'tonghua': '同花',
'tonghuashun': '同花顺',
'baozi': '豹子',
'high card': '高牌',
'one pair': '一对',
'two pair': '两对',
'three of a kind': '三条',
'straight': '顺子',
'flush': '同花',
'fullhouse': '葫芦',
'four of a kind': '四条',
'straight flush': '同花顺',
'royal flush': '皇家同花顺',
});
16 changes: 14 additions & 2 deletions www/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ div#cmds {
width: 100%;
position: fixed;
bottom: 0;
background-color: gray;
}

form {
Expand Down Expand Up @@ -109,6 +108,19 @@ input.cmd {
background: #eee;
}

li.active {
li.active,
div.active {
background: yellow;
}

li.active,
div.active {
background: yellow;
border: 1px solid black;
}

li.inactive,
div.inactive {
background: gray;
border: 1px solid black;
}
Loading

0 comments on commit c3f850a

Please sign in to comment.