Files
youle_cocos/projects/niuniu/js/niuniu/nn_test.js
T
joywayerandClaude Opus 4.8 7ab748919a chore: 纳入项目全部源码进根仓库统一管理
删除 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>
2026-06-28 11:55:13 +08:00

430 lines
9.4 KiB
JavaScript

/*
测试用
*/
//|| (Utl.getIsInfinite() == 1 && Utl.getPlayerReadyState(NN_Desk.myseat) != 1)
//测试
var Test = Test || {};
//测试数据
Test.data = {
roundResult: [],
roundScores: [],
totalScores: [],
};
Test.addScoreData = function(round, seat, score){
//添加回合分数
if(!this.data.roundScores[round]){
this.data.roundScores[round] = [];
}
this.data.roundScores[round][seat] = score;
//统计玩家总分数
if(!this.data.totalScores[seat]){
this.data.totalScores[seat] = 0;
}
this.data.totalScores[seat] += score;
};
//
Test.logDataString = function(){
for(var sx in this.data){
console.log( sx + " = " + JSON.stringify(this.data[sx]));
}
};
Test.AnalysisData = function(roundNum, roundNumMax, sysCutPercent){
//有效局数
var rCount = Math.floor(Test.data.roundScores.length / roundNum);
if(roundNumMax < rCount){
rCount = roundNumMax;
}
console.log("有效"+ roundNum +"局数:" + rCount);
//统计每局玩家最后输赢分数
var pScores = [];
var sysCutScore = 0;
var arr = [];
for(var i=0;i<rCount;i++){
pScores[i] = [0,0,0,0,0];
for(var j=0;j<roundNum;j++){
pScores[i][0] += Test.data.roundScores[i*roundNum + j][0];
pScores[i][1] += Test.data.roundScores[i*roundNum + j][1];
pScores[i][2] += Test.data.roundScores[i*roundNum + j][2];
pScores[i][3] += Test.data.roundScores[i*roundNum + j][3];
pScores[i][4] += Test.data.roundScores[i*roundNum + j][4];
}
arr = pScores[i].slice();
arr.sort(function(a,b){return a<b?1:0;});
sysCutScore += Math.floor(arr[0] * sysCutPercent);
}
console.log("局数对应每局玩家输赢分数:" + JSON.stringify(pScores));
//
console.log("抽成:" + sysCutScore);
};
Test.judge = {
triggerMode : [3,1,3], //触发自动出牌模式参数
times_click0 : 0,
times_click1 : 0,
times_click2 : 0,
};
//测试用-自动操作
Test.autoOpt = {
//是否开启
isOpen : false,
//自动模式:-1默认随机 1-托管 0-只自动搓摆牌
_mode : 0,
//开启
open: function(mode){
if(mode != null){
this._mode = mode;
}else {
this._mode = 0;
}
this.isOpen = true;
//自动操作
this.timeout_myOpt(1000);
},
//关闭测试
close: function(){
this.isOpen = false;
this._mode = 0;
this.clearTimeout();
},
//自动操作延迟时间配置
cfg_time: {
},
//玩家自动操作时参数配置
cfg_val: {
robZhuang: -1, //抢庄0-未操作,1-抢庄,-1-不抢
betScore: 5 //下注分数
},
//定时器id
_toId: {
timeout_myOpt: { t1: -1 },
myOpt: {
t1: -1,
t2: -1,
t3: -1,
t4: -1,
},
robZhuang: { t1: -1 },
betScore: { t1: -1 },
rubCard: { t1: -1 },
putCard: { t1: -1 }
},
//清除定时器
clearTimeout: function(){
for(var obj_sx in this._toId){
for(var sx in obj_sx){
if(obj_sx[sx] > -1){
clearTimeout(obj_sx[sx]);
obj_sx[sx] = -1;
}
}
}
},
//定时执行自动操作
timeout_myOpt : function(_time){
if(NN_Desk && this.isOpen){
if(_time == null){
this.myOpt();
}else {
this._toId.timeout_myOpt.t1 = setTimeout(function(){
this._toId.timeout_myOpt.t1 = -1;
this.myOpt();
}.bind(this),_time);
}
}
},
//自己自动操作
myOpt : function(){
if(this.isOpen && Utl.getInfMode() == 1){
//根据不同阶段操作
if(NN_Desk.state == NN_state.robZhuang){
//抢庄
if(NN_Desk.robList[NN_Desk.myseat] == 0){ //未操作
if(this._mode == 1){ //托管
if(this.cfg_val.robZhuang != 0){
this.robZhuang(this.cfg_val.robZhuang);
} else{
this.robZhuang(-1);
}
}else if(this._mode == -1){
//随机抢庄
if(parseInt(Math.random()*2) == 1){
//不抢
this.robZhuang(-1);
}else {
//抢
this.robZhuang(1);
};
}
}
}else if(NN_Desk.state == NN_state.bet){
//下注
if(NN_Desk.zhuang != NN_Desk.myseat && NN_Desk.pList[NN_Desk.myseat].betScore <= 0){ //未操作
if(this._mode == 1){ //托管
if(this.cfg_val.betScore > 0){
this.betScore(this.cfg_val.betScore);
}else {
var _score = 1;
switch (NN_Desk.model_bet){
case 10:
_score = 5;
break;
case 5:
_score = 3;
break;
case 3:
_score = 2;
break;
default:
break;
}
this.betScore(_score);
}
}else if(this._mode == -1){ //托管
var _score = 1;
switch (NN_Desk.model_bet){
case 10:
_score = parseInt(Math.random()*10 + 1, 10);
break;
case 5:
_score = parseInt(Math.random()*5 + 1, 10);
break;
case 3:
_score = parseInt(Math.random()*3 + 1, 10);
break;
default:
break;
}
this.betScore(_score);
}
}
}else if(NN_Desk.state == NN_state.rubCard){
//搓牌
if(NN_Desk.pList[NN_Desk.myseat].rubcard.length == 0){
//搓第一张牌
this.rubCard(3);
NN_UI.rubPutUI_anim();
set_self(750,37,0,0,0);
NN_Desk.pList[NN_Desk.myseat].rubcard[0] = 3;
//定时搓第二张
this.timeout_myOpt(1000);
}else if(NN_Desk.pList[NN_Desk.myseat].rubcard.length == 1){
//搓第二张
this.rubCard(4);
NN_UI.rubPutUI_anim();
set_self(751,37,0,0,0);
if(NN_Desk.pList[NN_Desk.myseat].rubcard[0] != 4){
NN_Desk.pList[NN_Desk.myseat].rubcard[1] = 4;
}
//搓牌完成-显示自动摆牌
NN_putCard_autoSelection(true);
NN_Desk.state = NN_state.putCard;
//定时摆牌
this.timeout_myOpt(1000);
}
}else if(NN_Desk.state == NN_state.putCard){
//摆牌
this.putCard();
}
}
},
robZhuang : function(isrob, _time){
//抢庄
var data = {
isrob:isrob
};
if(_time == null){
NN_Net.SendGameData("robZhuang",data);
}else {
this._toId.robZhuang.t1 = setTimeout(function(){
this._toId.robZhuang.t1 = -1;
NN_Net.SendGameData("robZhuang",data);
}.bind(this),_time);
}
//console.log("自动 抢庄:"+isrob);
},
betScore : function(_score, _time){
//下注
var data = {
score:_score
};
if(_time == null){
NN_Net.SendGameData("betScore",data);
}else {
this._toId.betScore.t1 = setTimeout(function(){
this._toId.betScore.t1 = -1;
NN_Net.SendGameData("betScore",data);
}.bind(this),_time);
}
//console.log("自动 下注:"+ _score);
},
rubCard : function(_cardloc, _time){
//搓牌
var data = {
cardloc:_cardloc
};
if(_time == null){
NN_Net.SendGameData("rubCard",data);
}else {
this._toId.rubCard.t1 = setTimeout(function(){
this._toId.rubCard.t1 = -1;
NN_Net.SendGameData("rubCard",data);
}.bind(this),_time);
}
//console.log("自动 搓牌:"+ _cardloc);
},
putCard : function(_time){
//摆牌确认
if(_time == null){
NN_Net.SendGameData("putCard");
}else{
this._toId.putCard.t1 = setTimeout(function(){
this._toId.putCard.t1 = -1;
NN_Net.SendGameData("putCard");
}.bind(this),_time);
}
//console.log("自动 摆牌确认");
},
};
//调试用
var Debug = Debug || {};
//循环定时id
Debug.ivId = {
ui_rubput: -1
};
//普通定时id
Debug.toId = {
};
//循环定时调试判断函数
Debug.intervalFunc = function(){
//搓摆牌界面
if(NN_Desk && NN_Desk.state != null){
if(NN_Desk.state == NN_state.rubput || NN_Desk.state == NN_state.rubCard || NN_Desk.state == NN_state.putCard){
//清除定时器
Debug.clear();
//开启
//console.log("开启 搓摆牌界面调试定时器");
this.ivId.ui_rubput = setInterval(function(){
if((NN_Desk.pList[NN_Desk.myseat].betScore > 0 || NN_Desk.myseat == NN_Desk.zhuang) && (NN_Desk.state == NN_state.rubput || NN_Desk.state == NN_state.rubCard || NN_Desk.state == NN_state.putCard)){
if(Debug.ui_rubput()){
//console.log("搓摆牌界面异常,提交错误信息");
//清除定时器
Debug.clear();
}
}else{
//清除定时器
Debug.clear();
}
}, 500);
}
}
};
//循环定时调试判断函数
Debug.clear = function(){
if(Debug.ivId.ui_rubput > -1){
//
//console.log("清除搓摆牌界面调试定时器");
clearInterval(Debug.ivId.ui_rubput);
Debug.ivId.ui_rubput = -1;
}
};
//搓摆牌界面异常判断
Debug.ui_rubput = function(){
var upNum = 0; //牌弹起数量
for(var i=0;i<5;i++){
if(get_self(725+i,19) < 522){
upNum ++;
}
}
//
var backNum = 0; //牌背
if(get_self(750,37) == 1){
backNum ++;
}
if(get_self(751,37) == 1){
backNum ++;
}
//
if(NN_Desk.state == NN_state.rubCard){
if(upNum > 0){
NN_Net.submit_error("搓摆牌显示异常,状态:" + NN_Desk.state," 牌弹起数:" + upNum + " #牌背数:" + backNum + " #搓牌:" + NN_Desk.pList[NN_Desk.myseat].rubcard + " #摆牌:" + NN_Desk.pList[NN_Desk.myseat].putcard);
return true;
}
} else if(NN_Desk.state == NN_state.putCard){
if(backNum > 0){
NN_Net.submit_error("搓摆牌显示异常,状态:" + NN_Desk.state," 牌弹起数:" + upNum + " #牌背数:" + backNum + " #搓牌:" + NN_Desk.pList[NN_Desk.myseat].rubcard + " #摆牌:" + NN_Desk.pList[NN_Desk.myseat].putcard);
return true;
}
}
if (upNum > 0 && backNum > 0){
NN_Net.submit_error("搓摆牌显示异常,状态:" + NN_Desk.state," 牌弹起数:" + upNum + " #牌背数:" + backNum + " #搓牌:" + NN_Desk.pList[NN_Desk.myseat].rubcard + " #摆牌:" + NN_Desk.pList[NN_Desk.myseat].putcard);
return true;
}
return false;
};