删除 YouleNexus 内嵌 .git,统一由根仓库唯一管理。提交: - projects/ 旧 H5 模板 Game_Surface_3 与各子游戏源码 - cocoscreator_projects/YouleNexus 工程 + cocos-creator-mcp 扩展源码 - CLAUDE.md、.mcp.json 等配置 library/temp/node_modules/dist 等缓存由 .gitignore 排除。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
924 lines
27 KiB
JavaScript
924 lines
27 KiB
JavaScript
/*data*/
|
|
var NN_GameModel = 1; //游戏网络0-单机,1网络
|
|
var NN_GameState = -1; //游戏状态
|
|
var NN_FS = []; //方位转座位
|
|
var NN_SF = []; //座位转方位
|
|
var NN_nowTimeout = 0; //当前倒计时时间-秒
|
|
var NN_nowTimeoutId = -1;//当前倒计时id
|
|
var NN_soundState = -1; //音效开关
|
|
var NN_timeout = 1; //定时器执开关
|
|
|
|
//牛牛配置参数
|
|
var NN_config = {
|
|
beanDes: "星星", //星星文字显示
|
|
roomCardDes: "房卡", //房卡显示
|
|
data : null, //配置文件数据
|
|
creatRoomMode : [-1, 1], //创建房间类型 [是否区分,当前创建房间模式]
|
|
room_card : [[[6,1],[12,2]],[[6,1],[12,2]]], //房卡类型
|
|
mult_bet : [3,3,3], //倍数类型对应下注模式
|
|
model_bet : 3, //下注模式
|
|
betRange : [], //下注范围
|
|
card_mult : [[8,2],[[-1],[1,1,1,1,1,1,1,1,2,3,4,-5,-6,-7,6,5,7,-11,-12],[1,1,2,3,4,5,6,7,8,9,10,-15,-16,-17,12,11,13,-25,-40]]], //牛八2倍类型牌型倍数
|
|
isOwnerInfinite : -1, //是否有房主无限局
|
|
isInfinite : 0, //是否无限局
|
|
force_bet: [-1, -1, -1, -1], //强制操作[是否开启, 是否抢庄,下注分数, 最小下注值]
|
|
model_bean: [-1,0,1000,10000,0.01], //星星分数显示 [1是否为星星场,星星数限制,星星数最小值,星星数最大值]
|
|
bean_mult: [1,1,50,0.02], //星星倍数相关[星星倍数,最小倍数,最大倍数,滑动间隔]
|
|
cfg_bean: [0, 0], //[抢庄限制,下注限制]
|
|
teaCost: [-1, 0, -1, [0,0], 0, [0,0]], //[是否服务费,服务费值,是否房主服务费(-1、0:无,1:可变动,2:固定服务费值), 服务费值[6局,12局], 服务费最大值模式(1:可变动,2:固定值),服务费最大值[6局,12局]];
|
|
teaCostRange: [0, 0], //茶水费范围
|
|
bean_leaveMin: [0.5, 1, [0.5, 1]], //星星场离场星星数 [离场星星,离场设置模式,[相对入场最小值百分比,相对入场最大值百分比]]
|
|
forceBetType: 2, //强制下注值:1-强制下注,2-最低下注
|
|
//托管参数
|
|
auto: {
|
|
mode: [1,1,1], //托管模式[抢庄,下注,搓摆牌]
|
|
toTime: 800, //定时延迟操作时间
|
|
fast_toTime : 700, //快版定时延迟操作时间
|
|
robZhuang: -1, //抢庄0-未操作,1-抢庄,-1-不抢
|
|
betScore: -1, //下注分数
|
|
recode: [-1,-1], //玩家操作记录
|
|
},
|
|
//托管提示框描述
|
|
des_trusteeship: "提示:托管时与最近一局的操作相同,若\n无操作时默认不抢庄,下注分数为最大值。",
|
|
ui:{
|
|
sysRoomDes: -1, //系统房间房间类型是否显示,-1为显示
|
|
}
|
|
};
|
|
|
|
var NN_errorMsg = ""; //最近一次错误信息
|
|
|
|
var NN_RevDataRecord = {
|
|
over:0, //0-断线重连时,-1-本地后台切回,1本地切回画完动画
|
|
dealCards:null, //发牌数据包记录
|
|
settlement:null,//结算数据包记录
|
|
gameover:null //总结算数据包记录
|
|
};
|
|
|
|
var NN_Judge = { //判断时用
|
|
isRub:-1, //是否搓牌成功
|
|
putLoc:[], //摆牌选中的位置
|
|
putPosY:[], //摆牌选中的位置移动Y轴坐标
|
|
boveCardaSpid:-1, //手是否移动到牌上,上次移动到哪张牌
|
|
isVibrator:-1, //是否震动
|
|
isDisband:-1, //是否解散房间
|
|
isStartWar:-1, //是否开始动画中
|
|
isOkZhuang:-1, //是否确定抢庄动画中
|
|
isDealCards:-1, //是否发牌动画中
|
|
|
|
headViewList: [], //玩家头像精灵有显示的列表
|
|
};
|
|
|
|
|
|
var NN_Desk = {};
|
|
function NN_createDesk(){
|
|
//创建游戏桌
|
|
NN_Desk = new NN_deskInfo(room_obj);
|
|
//NN_Desk.addPlayer();
|
|
//console.log("桌创建成功");
|
|
};
|
|
|
|
var NN_State = { //游戏各阶段状态
|
|
inHall:0,
|
|
inGame:1
|
|
};
|
|
|
|
var NN_state = { //游戏各阶段状态
|
|
ready:10, //准备
|
|
robZhuang:1, //抢庄
|
|
bet:2, //下注状态
|
|
betAgain:2, //下注状态
|
|
dealCard:3, //发牌
|
|
rubput:4, //搓牌和摆牌
|
|
settlement:5, //结算
|
|
over:6,
|
|
|
|
rubCard:7, //搓牌
|
|
putCard:8 //摆牌
|
|
};
|
|
|
|
//玩家游戏信息
|
|
var NN_playerInfo = function(_seat){
|
|
this.seat = _seat; //座位
|
|
this.cards = new NN_cardsInfo([]); //玩家手牌
|
|
this.isRob = 0; //-1不抢庄 1-抢
|
|
this.rubcard = []; //搓牌0-开始搓牌,1搓第一张牌,2搓牌完成
|
|
this.putcard = -1; //摆牌0-开始摆牌,1摆牌完成
|
|
this.scores = 0; //玩家赢取的分数
|
|
this.betScore = 0; //玩家下注
|
|
this.betScoreAgain = -1; //玩家加注
|
|
this.winScore = 0; //玩家赢取的分数
|
|
this.isJoin = -1; //玩家是否下注参与游戏
|
|
this.state = 1;
|
|
this.isBet = -1; //是否未下注
|
|
this.isReady = 0; //是否准备
|
|
this.isAuto = -1; //是否托管
|
|
this.betRange = [];//下注范围值
|
|
};
|
|
|
|
//游戏中桌信息
|
|
var NN_deskInfo = function(){
|
|
this.personMax = 5; //桌上最大玩家人数
|
|
this.roomtype = []; //roomtype:总局数+下注上限
|
|
this.owner = { //房主信息
|
|
seat: -1,
|
|
name: "",
|
|
id: -1
|
|
};
|
|
this.nowCount = 0; //当前游戏局数
|
|
this.records = []; //历史对战记录
|
|
this.state = -1; //状态
|
|
this.model = 1; //模式0-无牛下庄,1-每局抢庄
|
|
this.model_bet = 3; //下注模式:1-下注值为1~10,2-下注值为1-3
|
|
this.betRange = []; //下注范围
|
|
this.pairs = 0; //几副牌
|
|
this.model_mult = 1; //牌型倍数类型
|
|
this.model_fast = -1; //1-快速模式,其他值-正常模式
|
|
this.model_bean = [-1,0,1,0,0]; //星星模式
|
|
this.cardMaxMult= [7,13]; //牌型最大倍数值[牛八两倍,牛几几倍]
|
|
this.isTrusteeship = true; //是否开启托管功能
|
|
|
|
this.myseat = -1; //玩家座位
|
|
this.pList = []; //玩家列表
|
|
this.betList = []; //下注玩家列表
|
|
this.betAgainList = []; //再次下注玩家列表
|
|
this.robList = [0,0,0,0,0]; //抢庄列表
|
|
this.diceList = []; //色子点数列表
|
|
this.playercount = 0; //玩家人数
|
|
this.zhuang = -1; //庄
|
|
|
|
this.isDisorderDeal = 0; //是否显示无序发牌
|
|
this.disorderDealCards = []; //无序的发牌
|
|
|
|
this.stageTime = 0;
|
|
this.stageTime_loc = 0;
|
|
|
|
this.gameoverScores = [];
|
|
};
|
|
|
|
//各阶段时间上限
|
|
NN_deskInfo.prototype.timeout_m = {
|
|
ready: 5, //准备时间
|
|
shuffle:5, //洗牌时间
|
|
robzhuang:12, //抢庄
|
|
bet:12, //下注
|
|
betAgain:6, //再次下注
|
|
throwdice:5, //丢色子
|
|
dealcards:5, //发牌
|
|
rubput:12, //搓牌和摆牌
|
|
result:10 //显示结果
|
|
|
|
};
|
|
//各阶段时间上限
|
|
NN_deskInfo.prototype.timeout_count = {
|
|
bet:0
|
|
};
|
|
//计时器
|
|
NN_deskInfo.prototype.timeout = {
|
|
ready:0, //准备时间
|
|
shuffle:0, //洗牌时间
|
|
robzhuang:0, //抢庄
|
|
bet:0, //下注
|
|
betAgain:0, //再次下注
|
|
throwdice:0, //丢色子
|
|
dealcards:0, //发牌
|
|
rubput:0, //搓牌和摆牌
|
|
result:0 //显示结果
|
|
};
|
|
|
|
//牌信息
|
|
NN_deskInfo.prototype.cardList = nn_newCards();
|
|
|
|
//常量设置
|
|
NN_deskInfo.prototype.constant = {
|
|
cardTypeReward : [1,2,3] //特殊牌型奖励张数[五花牛,五小牛,炸弹]
|
|
};
|
|
|
|
NN_deskInfo.prototype.initData_net = function(data){
|
|
//初始化房间桌游戏数据
|
|
this.myseat = Utl.getMySeat();
|
|
//桌数据
|
|
var desk = data;
|
|
this.roomtype = desk.desk[0];
|
|
this.nowCount = desk.desk[1];
|
|
this.state = desk.desk[2];
|
|
this.model = data.desk[3]; //模式0-无牛下庄,1-每局抢庄
|
|
this.zhuang = data.desk[4];
|
|
this.robList = data.desk[5];
|
|
this.betList = data.desk[6];
|
|
if(desk.desk[7] > 0){
|
|
this.stageTime = desk.desk[7];
|
|
if(this.state == NN_state.bet){
|
|
if(data.desk[10] <= 0){
|
|
this.stageTime_loc = (new Date()).getTime() - desk.desk[7];
|
|
}
|
|
}
|
|
}
|
|
this.playercount = data.desk[8]; //玩家人数
|
|
this.constant.cardTypeReward = data.desk[9]; //特殊牌型奖励张数[五花牛,五小牛,炸弹]
|
|
this.timeout_count.bet = data.desk[10];
|
|
if(data.desk[11] != null){
|
|
this.owner.seat = data.desk[11]; //房主
|
|
}
|
|
this.model_fast = data.desk[12]; //快版
|
|
this.model_bean = data.desk[13];
|
|
this.model_bet = data.desk[14];
|
|
this.betRange = data.desk[15]; //下注范围
|
|
this.cardMaxMult = data.desk[16]; //
|
|
this.isTrusteeship = data.desk[17];
|
|
this.personMax = data.desk[18];
|
|
this.isDisorderDeal = data.desk[19];
|
|
if(this.isDisorderDeal){
|
|
this.disorderDealCards = data.desk[20];
|
|
}
|
|
|
|
this.pairs = data.desk[0][2];
|
|
this.model_mult = data.desk[0][3];
|
|
//玩家游戏信息
|
|
for(var i=0;i<desk.players.length;i++){
|
|
if(desk.players[i].length > 0){
|
|
this.pList[i] = new NN_playerInfo(i);
|
|
this.pList[i].seat = desk.players[i][0];
|
|
this.pList[i].betScore = desk.players[i][1];
|
|
this.pList[i].rubcard = desk.players[i][2];
|
|
this.pList[i].putcard = desk.players[i][3];
|
|
this.pList[i].scores = desk.players[i][4];
|
|
this.pList[i].winScore = desk.players[i][5];
|
|
this.pList[i].cards.cards = [];
|
|
if(desk.players[i][6].length > 0){
|
|
this.pList[i].cards.cards = desk.players[i][6][0];
|
|
if(desk.players[i][6][0].length > 0){
|
|
for(var j=3;j<5;j++){
|
|
if(this.pList[i].cards.cards[j] < 0){
|
|
this.pList[i].cards.cards[j] = 54;
|
|
}
|
|
}
|
|
if(desk.players[i][6].length > 1){
|
|
this.pList[i].cards.type = desk.players[i][6][1];
|
|
this.pList[i].cards.Multiple = desk.players[i][6][2];
|
|
this.pList[i].cards.niu = desk.players[i][6][3];
|
|
}
|
|
}
|
|
}
|
|
this.pList[i].isJoin = desk.players[i][7];
|
|
this.pList[i].isBet = desk.players[i][8];
|
|
|
|
this.pList[i].isAuto = desk.players[i][9];
|
|
//托管数据
|
|
if(desk.players[i][10].length > 0){
|
|
NN_config.auto.mode = data.players[i][10][0]; //托管模式[抢庄,下注,搓摆牌]
|
|
NN_config.auto.toTime = data.players[i][10][1]; //定时延迟操作时间
|
|
NN_config.auto.robZhuang = data.players[i][10][2]; //抢庄0-未操作,1-抢庄,-1-不抢
|
|
NN_config.auto.betScore = data.players[i][10][3]; //下注分数
|
|
NN_config.auto.recode = data.players[i][10][4]; //玩家操作记录
|
|
}
|
|
this.pList[i].isReady = desk.players[i][11];
|
|
this.pList[i].betScoreAgain = desk.players[i][12];
|
|
this.pList[i].betRange = desk.players[i][13];
|
|
}
|
|
}
|
|
//各阶段时间上限
|
|
if(data.to_m){
|
|
this.timeout_m.ready = data.to_m[0]; //准备时间
|
|
this.timeout_m.robzhuang = data.to_m[1];//抢庄
|
|
this.timeout_m.bet = data.to_m[2]; //下注
|
|
this.timeout_m.betAgain = data.to_m[3]; //再次下注
|
|
this.timeout_m.rubput = data.to_m[4]; //搓牌和摆牌
|
|
}
|
|
|
|
//设置方位
|
|
NN_setPositionSeat(this.myseat);
|
|
NN_GameState = NN_State.inGame;
|
|
NN_soundState = 1; //音效开关
|
|
NN_timeout = 1; //定时器执开关
|
|
NN_Judge.isDisband = -1;
|
|
NN_RevDataRecord.over = 0;
|
|
NN_RevDataRecord.dealCards = null;
|
|
NN_RevDataRecord.settlement = null;
|
|
NN_RevDataRecord.gameover = null;
|
|
//
|
|
NN_Sprite.person = this.personMax;
|
|
//通知框架游戏状态
|
|
if(Utl.getIsInfinite() == 1){
|
|
if(this.state == NN_state.ready){
|
|
Utl.setDeskStage(0);
|
|
} else {
|
|
Utl.setDeskStage(1);
|
|
}
|
|
}
|
|
};
|
|
|
|
//初始化玩家下注范围值
|
|
NN_deskInfo.prototype.initPlayerBetRange = function(arr_range){
|
|
if(arr_range){
|
|
for (var i=0; i<arr_range.length; i++){
|
|
if(this.pList[arr_range[i][0]]){
|
|
for (var j=0; j<arr_range[i][1].length; j++){
|
|
this.pList[arr_range[i][0]].betRange = arr_range[i][1].slice();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
NN_deskInfo.prototype.isAddPlayer = function(seat){
|
|
//添加玩家信息,返回座位
|
|
if(!this.pList[seat]){
|
|
this.pList[seat] = new NN_playerInfo(seat);
|
|
this.playercount ++;
|
|
//console.log("添加玩家到座位:"+seat);
|
|
}
|
|
};
|
|
|
|
NN_deskInfo.prototype.delPlayer = function(seat){
|
|
//删除玩家信息
|
|
if(!this.pList[seat]){
|
|
this.pList[seat] = null;
|
|
this.playercount --;
|
|
//console.log("删除 "+i+"号座位的玩家 ");
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
//判断玩家星星数是否够
|
|
NN_deskInfo.prototype.isBeanEnough = function(seat,step){
|
|
if(seat == null){
|
|
seat = this.myseat;
|
|
}
|
|
if(this.model_bean[0] == 1 && this.pList[seat]){
|
|
var _bean = null;
|
|
if(Desk.GetPlayerBySeat(seat) && Desk.GetPlayerBySeat(seat).bean != null){
|
|
_bean = Desk.GetPlayerBySeat(seat).bean;
|
|
}else{
|
|
return false;
|
|
}
|
|
if(step == "rob"){
|
|
if(this.model_bean[3] > 0){
|
|
if(_bean >= this.model_bean[3] * this.model_bean[2]){
|
|
return true;
|
|
}
|
|
}else {
|
|
return true;
|
|
}
|
|
}else if(step == "bet" || !step){
|
|
if(this.model_bean[4] > 0){
|
|
if(_bean >= this.model_bean[4] * this.model_bean[2]){
|
|
return true;
|
|
}
|
|
}else {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}else {
|
|
return true;
|
|
}
|
|
};
|
|
//小局开始前数据初始化
|
|
NN_deskInfo.prototype.initRoundData = function(){
|
|
//桌数据
|
|
this.zhuang = -1;
|
|
this.betList = []; //下注玩家列表
|
|
this.diceList = [[],[],[],[],[]]; //色子点数列表
|
|
//抢庄列表
|
|
if(this.personMax == 10){
|
|
this.robList = [0,0,0,0,0,0,0,0,0,0];
|
|
}else {
|
|
this.robList = [0,0,0,0,0];
|
|
}
|
|
this.disorderDealCards = [];
|
|
//玩家游戏数据
|
|
for(var i=0;i<this.pList.length;i++){
|
|
if(this.pList[i]){
|
|
this.pList[i].cards = new NN_cardsInfo([]); //玩家手牌
|
|
this.pList[i].rubcard = []; //搓牌0-开始搓牌,1搓第一张牌,2搓牌完成
|
|
this.pList[i].putcard = -1; //摆牌0-开始摆牌,1摆牌完成
|
|
this.pList[i].betScore = 0; //玩家下注
|
|
this.pList[i].betScoreAgain = -1; //玩家加注注
|
|
this.pList[i].winScore = 0; //玩家赢取的分数
|
|
this.pList[i].isRob = 0; //玩家赢取的分数
|
|
this.pList[i].betRange = [];
|
|
this.pList[i].bean = null;
|
|
}
|
|
}
|
|
};
|
|
|
|
NN_deskInfo.prototype.readyStage = function(data){
|
|
//小局开始前数据初始化
|
|
this.initRoundData();
|
|
//准备阶段
|
|
for(var i=0;i<this.pList.length;i++){
|
|
if(this.pList[i]){
|
|
Utl.setPlayerPrepare(i, 0); //设置玩家未准备状态
|
|
this.pList[i].isReady = 0; //玩家准备状态
|
|
}
|
|
}
|
|
NN_Desk.state = NN_state.ready;
|
|
//通知框架进入准备阶段
|
|
Utl.setDeskStage(0);
|
|
};
|
|
|
|
NN_deskInfo.prototype.startWar = function(data){
|
|
//小局开始前数据初始化
|
|
this.initRoundData();
|
|
//通知框架已开始游戏
|
|
if(Utl.getIsInfinite() == 1){
|
|
Utl.setDeskStage(1);
|
|
}
|
|
//开始游戏
|
|
if(data.startType == 0){//抢庄
|
|
this.zhuang = -1;
|
|
}else if(data.startType >= 1){//庄不变 //倒桩
|
|
this.zhuang = data.zhuang;
|
|
}
|
|
this.state = data.state;
|
|
this.nowCount = data.nowCount;
|
|
//牌数据赋值
|
|
if(data.cards){
|
|
for(var i=0;i<data.cards.length;i++){
|
|
if(this.pList[i] && data.cards[i].length > 0){
|
|
//if(data.cards[i].length > 0){
|
|
this.pList[i].cards.cards = [54,54,54,54,54];//54-牌背
|
|
for(var j=0;j<data.cards[i][0].length;j++){
|
|
this.pList[i].cards.cards[j] = data.cards[i][0][j];
|
|
}
|
|
if(data.cards[i].length > 1){
|
|
this.pList[i].cards.type = data.cards[i][1];
|
|
this.pList[i].cards.Multiple = data.cards[i][2];
|
|
this.pList[i].cards.niu = data.cards[i][3];
|
|
}
|
|
//看牌抢庄
|
|
if(this.model == 4){
|
|
this.pList[i].rubcard[0] = 3;
|
|
}
|
|
}
|
|
}
|
|
if(this.pList[NN_Desk.myseat].cards.cards.length > 0){
|
|
Utl.changePlayerState(0);
|
|
}
|
|
//
|
|
if(data.disorderCards){
|
|
this.disorderDealCards = data.disorderCards;
|
|
}
|
|
}
|
|
if(this.zhuang >= 0){
|
|
this.pList[this.zhuang].isBet = -1;
|
|
}
|
|
//初始化玩家下注范围
|
|
if(data.pBetRange){
|
|
this.initPlayerBetRange(data.pBetRange);
|
|
}
|
|
|
|
//下注抢庄
|
|
if(this.model == 5 && this.pList[NN_Desk.myseat].isReady){
|
|
Utl.changePlayerState(0);
|
|
}
|
|
NN_Desk.stageTime_loc = (new Date()).getTime();
|
|
};
|
|
|
|
NN_deskInfo.prototype.robZhuang = function(data){
|
|
//抢庄-不抢
|
|
this.isAddPlayer(data.seat);
|
|
this.robList[data.seat] = data.isrob;
|
|
this.pList[data.seat].isRob = data.isrob;
|
|
this.pList[data.seat].isBet = -1;
|
|
if(data.seat == NN_Desk.myseat){
|
|
Utl.changePlayerState(0);
|
|
//记录玩家是否抢庄
|
|
NN_config.auto.recode[0] = data.isrob;
|
|
NN_config.auto.robZhuang = data.isrob;
|
|
}
|
|
};
|
|
|
|
NN_deskInfo.prototype.okZhuang = function(data){
|
|
//抢庄-确定庄
|
|
this.zhuang = data.zhuang;
|
|
this.robList = data.robList;
|
|
this.diceList = data.diceList;
|
|
this.state = NN_state.bet;
|
|
if(this.zhuang == NN_Desk.myseat){
|
|
Utl.changePlayerState(0);
|
|
}
|
|
this.pList[this.zhuang].isBet = -1;
|
|
if(this.model == 5 && data.cards){
|
|
for(var i=0;i<data.cards.length;i++){
|
|
if(this.pList[i] && data.cards[i].length > 0){
|
|
//if(data.cards[i].length > 0){
|
|
this.pList[i].cards.cards = [54,54,54,54,54];//54-牌背
|
|
for(var j=0;j<data.cards[i][0].length;j++){
|
|
this.pList[i].cards.cards[j] = data.cards[i][0][j];
|
|
}
|
|
if(data.cards[i].length > 1){
|
|
this.pList[i].cards.type = data.cards[i][1];
|
|
this.pList[i].cards.Multiple = data.cards[i][2];
|
|
this.pList[i].cards.niu = data.cards[i][3];
|
|
}
|
|
}
|
|
}
|
|
//this.state = NN_state.rubCard;//搓牌状态
|
|
//去除庄下注分数
|
|
this.pList[this.zhuang].betScore = 0;
|
|
}else if(this.model == 5){
|
|
//去除庄下注分数
|
|
this.pList[this.zhuang].betScore = 0;
|
|
}
|
|
//初始化玩家下注范围
|
|
if(data.pBetRange){
|
|
this.initPlayerBetRange(data.pBetRange);
|
|
}
|
|
|
|
NN_Desk.stageTime_loc = (new Date()).getTime();
|
|
};
|
|
|
|
NN_deskInfo.prototype.betScore = function(data){
|
|
//玩家下注
|
|
this.isAddPlayer(data.seat);
|
|
var seat = data.seat;
|
|
var _score = data.score; //下注分数
|
|
if(10 >= _score && _score > 0){
|
|
this.pList[seat].betScore = _score;
|
|
this.betList.push(seat);
|
|
this.pList[seat].isJoin = 1;
|
|
this.pList[data.seat].isBet = -1;
|
|
if(seat == NN_Desk.myseat){
|
|
Utl.changePlayerState(0);
|
|
//记录玩家下注分数
|
|
NN_config.auto.betScore = _score;
|
|
NN_config.auto.recode[1] = _score;
|
|
}
|
|
}
|
|
};
|
|
|
|
NN_deskInfo.prototype.dealCards = function(data){
|
|
//发牌
|
|
NN_RevDataRecord.dealCards = data;
|
|
|
|
this.state = NN_state.dealCard;//状态
|
|
if(NN_Desk.model == 5){
|
|
this.state = NN_state.robZhuang;
|
|
}
|
|
|
|
for(var i=0;i<data.cards.length;i++){
|
|
if(this.pList[i] && data.cards[i].length > 0){
|
|
//if(data.cards[i].length > 0){
|
|
this.pList[i].cards.cards = [54,54,54,54,54];//54-牌背
|
|
for(var j=0;j<data.cards[i][0].length;j++){
|
|
this.pList[i].cards.cards[j] = data.cards[i][0][j];
|
|
}
|
|
if(data.cards[i].length > 1){
|
|
this.pList[i].cards.type = data.cards[i][1];
|
|
this.pList[i].cards.Multiple = data.cards[i][2];
|
|
this.pList[i].cards.niu = data.cards[i][3];
|
|
}
|
|
//看牌抢庄
|
|
if(this.model == 4 || this.model == 5){
|
|
this.pList[i].rubcard[0] = 3;
|
|
}
|
|
}
|
|
}
|
|
if(data.disorderCards){
|
|
this.disorderDealCards = data.disorderCards;
|
|
}
|
|
|
|
if(this.model != 4 && this.model != 5){
|
|
//未下注
|
|
if(data.noBets && data.noBets.length > 0){
|
|
for(var i=0;i<data.noBets.length;i++){
|
|
this.pList[data.noBets[i]].isBet = 1;
|
|
}
|
|
}else {
|
|
for(var i=0;i<this.pList.length;i++){
|
|
if(this.pList[i] && this.pList[i].isReady && this.pList[i].cards.cards.length == 0){
|
|
if(this.model_bean[0] != 1 || (this.model_bean[0] == 1 && this.isBeanEnough(i,"bet"))){
|
|
this.pList[i].isBet = 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
NN_Desk.stageTime_loc = (new Date()).getTime();
|
|
};
|
|
|
|
NN_deskInfo.prototype.betScoreAgain = function(data){
|
|
//下注抢庄玩家第二次下注
|
|
var seat = data.seat;
|
|
this.pList[seat].betScoreAgain = data.score2;
|
|
this.pList[seat].betScore = data.score;
|
|
this.betAgainList.push(seat);
|
|
this.pList[seat].isBet = -1;
|
|
};
|
|
|
|
NN_deskInfo.prototype.dealCardsAgain = function(data){
|
|
this.state = NN_state.dealCard;//状态
|
|
if(data.cards){
|
|
for(var i=0;i<data.cards.length;i++){
|
|
if(this.pList[i] && data.cards[i].length > 0){
|
|
this.pList[i].cards.cards = [54,54,54,54,54];//54-牌背
|
|
for(var j=0;j<data.cards[i][0].length;j++){
|
|
this.pList[i].cards.cards[j] = data.cards[i][0][j];
|
|
}
|
|
if(data.cards[i].length > 1){
|
|
this.pList[i].cards.type = data.cards[i][1];
|
|
this.pList[i].cards.Multiple = data.cards[i][2];
|
|
this.pList[i].cards.niu = data.cards[i][3];
|
|
}
|
|
}
|
|
}
|
|
//this.state = NN_state.rubCard;//搓牌状态
|
|
}
|
|
NN_Desk.stageTime_loc = (new Date()).getTime();
|
|
};
|
|
|
|
NN_deskInfo.prototype.rubCard = function(data){
|
|
//搓牌
|
|
var seat = data.seat;
|
|
var loc = data.cardloc; //第几张牌
|
|
if(this.pList[seat].rubcard.length == 0){
|
|
this.pList[seat].rubcard[0] = loc;
|
|
this.pList[seat].cards.cards[loc] = data.card;
|
|
}else if(this.pList[seat].rubcard.length == 1){
|
|
if(this.pList[seat].rubcard[0] != loc){
|
|
this.pList[seat].rubcard[1] = loc;
|
|
this.pList[seat].cards.cards[loc] = data.card;
|
|
|
|
if(data.cards){
|
|
this.pList[seat].cards.cards = data.cards[0];
|
|
this.pList[seat].cards.type = data.cards[1];
|
|
this.pList[seat].cards.Multiple = data.cards[2];
|
|
this.pList[seat].cards.niu = data.cards[3];
|
|
}
|
|
}
|
|
}
|
|
if(data.putcard != null){
|
|
this.pList[seat].putcard = data.putcard;
|
|
}
|
|
};
|
|
|
|
NN_deskInfo.prototype.putCard = function(data){
|
|
//摆牌
|
|
var seat = data.seat;
|
|
if(this.pList[seat].rubcard.length != 2){
|
|
this.pList[seat].rubcard = [3,4];
|
|
}
|
|
if(this.pList[seat].rubcard.length == 2 && this.pList[seat].putcard <= 0){
|
|
this.pList[seat].putcard = 1;//摆牌
|
|
}
|
|
|
|
if(seat != NN_Desk.myseat && data.cards){
|
|
this.pList[seat].cards.cards = data.cards[0];
|
|
this.pList[seat].cards.type = data.cards[1];
|
|
this.pList[seat].cards.Multiple = data.cards[2];
|
|
this.pList[seat].cards.niu = data.cards[3];
|
|
}
|
|
};
|
|
|
|
NN_deskInfo.prototype.putAllCard = function(data){
|
|
//摆牌超时所有玩家的牌
|
|
for(var i=0;i<data.cards.length;i++){
|
|
if(data.cards[i] && data.cards[i].length > 0){
|
|
//if(data.cards[i].length > 0){
|
|
//this.pList[i].rubcard = [3,4];
|
|
this.pList[i].cards.cards = data.cards[i][0];
|
|
this.pList[i].cards.type = data.cards[i][1];
|
|
this.pList[i].cards.Multiple = data.cards[i][2];
|
|
this.pList[i].cards.niu = data.cards[i][3];
|
|
//完成搓摆牌
|
|
this.pList[i].rubcard = [3,4];
|
|
//this.pList[i].putcard = 1;
|
|
}
|
|
}
|
|
};
|
|
|
|
NN_deskInfo.prototype.settlement = function(data){
|
|
//结算
|
|
NN_RevDataRecord.settlement = data;
|
|
this.state = NN_state.settlement;
|
|
for(var i=0;i<data.result.length;i++){
|
|
if(this.pList[i] && data.result[i].length > 0){
|
|
//if(data.result[i].length > 0){
|
|
this.pList[i].winScore = data.result[i][0];
|
|
this.pList[i].scores = data.result[i][1];
|
|
this.pList[i].bean = data.result[i][2];
|
|
}
|
|
}
|
|
NN_Desk.stageTime_loc = (new Date()).getTime();
|
|
};
|
|
|
|
NN_deskInfo.prototype.gameOver = function(data){
|
|
//游戏全部结束
|
|
this.gameoverScores = data.scores;
|
|
NN_RevDataRecord.gameover = data;
|
|
this.state = NN_state.over;
|
|
for(var i=0;i<data.scores.length;i++){
|
|
this.pList[data.scores[i][0]].scores = data.scores[i][1];
|
|
}
|
|
this.records = data.rounds;
|
|
|
|
//房主信息
|
|
if(data.owner){
|
|
this.owner.seat = data.owner[0];
|
|
this.owner.name = data.owner[1];
|
|
this.owner.id = data.owner[2];
|
|
}
|
|
//战绩保存本地
|
|
if(data.gamesRecord && data.gamesRecord.gameinfo1){
|
|
data.gamesRecord.gameinfo1.round = data.rounds;
|
|
this.saveLocRecord(data.gamesRecord);
|
|
}
|
|
};
|
|
|
|
//保存本地战绩
|
|
NN_deskInfo.prototype.saveLocRecord = function(data){
|
|
//
|
|
try{
|
|
if(data){
|
|
var _record = {};
|
|
var temp = [];
|
|
if(data.createtime && data.createtime.length >= 16){
|
|
temp = data.createtime.slice(11,data.createtime.length);
|
|
temp = temp.split(":");
|
|
_record.createtime = data.createtime.slice(5,10) + " " + temp[0] + ":" + temp[1];
|
|
}
|
|
if(data.makewartime && data.makewartime.length >= 16){
|
|
temp = data.makewartime.slice(11,data.makewartime.length);
|
|
temp = temp.split(":");
|
|
_record.makewartime = data.makewartime.slice(5,10) + " " + temp[0] + ":" + temp[1];
|
|
}
|
|
//当前时间
|
|
var _time = new Date();
|
|
_record.overtime = (_time.getMonth() + 1) + "-" + _time.getDate() + " " + _time.getHours() + ":" + _time.getMinutes();
|
|
_record.roomcode = data.gameinfo1.roomcode;
|
|
_record.roomtype = data.roomtype;
|
|
_record.gameinfo1 = JSON.stringify(data.gameinfo1);
|
|
//战绩保存本地
|
|
Utl.saveGradeInfo(_record);
|
|
}
|
|
}catch(e){
|
|
NN_Net.submit_error("保存本地战绩", e.stack + " 数据:" + JSON.stringify(data));
|
|
}
|
|
};
|
|
|
|
NN_deskInfo.prototype.disbandGame = function(data){
|
|
//解散房间-游戏结束
|
|
if(data.isSett == 1){
|
|
if(typeof(data.putAllCard) != "undefined"){
|
|
NN_Desk.putAllCard(data.putAllCard);
|
|
}
|
|
|
|
if(typeof(data.settlement) != "undefined"){
|
|
NN_Desk.settlement(data.settlement);
|
|
}
|
|
|
|
if(typeof(data.gameOver) != "undefined"){
|
|
NN_Desk.gameOver(data.gameOver);
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
NN_deskInfo.prototype.surrender = function(data){
|
|
//投降
|
|
//星星场
|
|
NN_Desk.model_bean[0] = 1;
|
|
|
|
NN_setPositionSeat(this.myseat);
|
|
NN_GameState = NN_State.inGame;
|
|
NN_soundState = 1; //音效开关
|
|
NN_Judge.isDisband = -1;
|
|
NN_RevDataRecord.over = 0;
|
|
NN_RevDataRecord.dealCards = null;
|
|
NN_RevDataRecord.settlement = null;
|
|
NN_RevDataRecord.gameover = null;
|
|
|
|
//房主信息
|
|
if(data.ownerseat != null){
|
|
this.owner.seat = data.ownerseat;
|
|
this.owner.name = Utl.getNicknameBySeat(data.ownerseat);
|
|
this.owner.id = Utl.getPlayeridBySeat(data.ownerseat);
|
|
}
|
|
|
|
//模拟总结算包数据 {"scores":[[0,-4],[1,4]],"rounds":[[[0,-4,0,0,0,0,0,"",1],[1,4,0,0,0,0,0,"",1],[],[],[]]],"owner":[0,"测试15576",100312]}
|
|
var _data = {
|
|
scores:[],
|
|
rounds:[],
|
|
owner :[]
|
|
};
|
|
|
|
for(var i=0; i<data.players.length; i++){
|
|
if(data.players[i] != null){
|
|
this.pList[i] = new NN_playerInfo(i);
|
|
this.pList[i].scores = data.players[i];
|
|
_data.scores.push([i, data.players[i]]);
|
|
}
|
|
}
|
|
|
|
_data.rounds = [_data.scores];
|
|
_data.owner = [this.owner.seat, this.owner.name, this.owner.id];
|
|
return _data;
|
|
};
|
|
|
|
NN_deskInfo.prototype.copyGameoverData = function(){
|
|
//复制总结算数据
|
|
var str = "";
|
|
if(NN_Desk.model_bean[0] == 1){
|
|
str += ("房号:" + Utl.getRoomcode() + "(" + NN_config.beanDes + "场)\n");
|
|
} else {
|
|
str += ("房号:" + Utl.getRoomcode() + "\n");
|
|
}
|
|
str += ("房主:" + Utl.getNicknameBySeat(this.owner.seat) + "(ID:" + Utl.getPlayeridBySeat(this.owner.seat) + ")\n");
|
|
str += "战绩:\n";
|
|
for(var i=0;i<this.pList.length;i++){
|
|
if(this.pList[i]){
|
|
str += (" " + this.pList[i].scores + " " + Utl.getNicknameBySeat(i) + "(ID:" + Utl.getPlayeridBySeat(i) + ")\n");
|
|
}
|
|
}
|
|
//调用复制接口
|
|
Func.gameCopytext(str);
|
|
//
|
|
Utl.openTips("复制成功",1000);
|
|
};
|
|
|
|
NN_deskInfo.prototype.trusteeship = function(data){
|
|
//托管
|
|
NN_Desk.pList[data.seat].isAuto = data.isAuto;
|
|
};
|
|
|
|
//游戏中桌信息
|
|
NN_deskInfo.prototype.clearData = function(){
|
|
//手动清除对象数据
|
|
this.roomtype = null; //roomtype:总局数+下注上限
|
|
this.owner = null; //房主信息
|
|
this.records = null; //历史对战记录
|
|
this.model_bean = null; //星星模式
|
|
this.pList = null; //玩家列表
|
|
this.betList = null; //下注玩家列表
|
|
this.robList = null; //抢庄列表
|
|
this.diceList = null; //色子点数列表
|
|
this.gameoverScores = null;
|
|
};
|
|
|
|
//清除牛牛游戏桌数据
|
|
NN_Exit_clearData = function(){
|
|
NN_GameState = NN_State.inHall; //游戏状态
|
|
|
|
//清除牛牛游戏相关数据
|
|
NN_FS = [];
|
|
NN_SF = [];
|
|
NN_timeout = -1;
|
|
NN_RevDataRecord.dealCards = null;
|
|
NN_RevDataRecord.settlement = null;
|
|
NN_RevDataRecord.gameover = null;
|
|
//桌数据
|
|
if(NN_Desk.clearData){
|
|
NN_Desk.clearData();
|
|
}
|
|
NN_Desk = null;
|
|
NN_Desk = {};
|
|
};
|
|
|
|
//清除牛牛游戏界面
|
|
NN_Exit_clearUI = function(){
|
|
NN_GameState = NN_State.inHall; //游戏状态
|
|
//清除桌界面
|
|
if(NN_Desk.model_fast >= 1 || NN_Desk.model == 4 || NN_Desk.model == 5){
|
|
NN_UIF.hide(); //快版
|
|
}else{
|
|
NN_UI.hide(true); //正常
|
|
}
|
|
|
|
//隐藏计算器按钮
|
|
GameUI.hideCalBtn();
|
|
//停止结算绘画Draw
|
|
NN_Draw.settlement = -1;
|
|
//清除定时器
|
|
NN_UI.ClearTimeout();
|
|
NN_UI.setCountDown();
|
|
//清除游戏音效
|
|
Func.play_wav("00101.mp3",-1);
|
|
NN_playSound();
|
|
};
|
|
|
|
//清除桌数据并返回大厅
|
|
NN_Exit_intoHall = function(){
|
|
//先清除牛牛游戏界面
|
|
//NN_Exit_clearUI();
|
|
//清除牛牛游戏桌数据
|
|
//NN_Exit_clearData();
|
|
//返回到大厅
|
|
Utl.Exit();
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|