Files
2026-02-04 23:47:45 +08:00

71 lines
1.8 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
///////////////////////////////////////////////////
////////////////// cls_pai: 单张牌 ////////////////
///////////////////////////////////////////////////
var cls_pai = cls_pai || {
//创建单张牌实例
new: function(id, score, dealowner){
/*
参数说明:
id 牌的绝对id
score 牌在游戏中的分值
dealowner 发牌状态
扑克牌的统一编码规则:
1牌面花色的定义 5:王 4:黑桃 3:红心 2:梅花 1:方块
2牌面数值的定义 1:A 2:2 3:3 ... 9:9 10:10 11:J 12:Q 13:K 53:小王 54:大王
*/
var pai = {};
//属性
pai.id = id; //绝对id即数组下标从0开始计数
pai.score = score; //牌在游戏中的分值
pai.dealowner = dealowner; //发牌状态
//-1:规则去除的牌
// 0:未发的牌,即底牌
//>0:发牌发到谁手上从1开始计数即座位编号+1座位编号是从0开始计数的
pai.playround = -1; //出牌状态
//-1:未出的牌
// 0:埋牌
//>0:牌是第几轮出出去的从1开始计数
pai.playindex = -1; //本轮中的出牌顺序从1开始计数
pai.playowner = -1; //出牌后被谁得到,与座位编号对应
//方法
pai.method = {};
//牌面花色
pai.method.get_flower = function(){
return cls_pai.get_flower(pai);
}
//牌面数值
pai.method.get_number = function(){
return cls_pai.get_number(pai);
}
return pai;
},
//获取牌面花色
get_flower: function(o_pai) {
var yu = o_pai.id % 54;
if (yu == 52 || yu == 53){ //小王大王
return 5;
}
return parseInt(yu / 13) + 1;
},
//获取牌面数值
get_number: function(o_pai) {
var yu = o_pai.id % 54;
if (yu == 52){ //小王
return 53;
}
if (yu == 53){ //大王
return 54;
}
return yu % 13 + 1;
}
}