Files
youle_cocos/projects/niuniu/js/01_SubGame/02_SubGame_Input.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

630 lines
17 KiB
JavaScript

//注:ConsttVal中的ChatLoc与isLeft的数组长度一定要与ConstVal.Max.PlayerCnt保持一致否则会导致报错或者聊天气泡位置不对
Game_Modify.StartWar=function(_msg){//开战
if(_msg.data && NN_RevData.firstStartWar){
NN_RevData.firstStartWar(_msg.data);
}
};
Game_Modify._ReceiveData=function(_msg){//接收数据包
if(NN_Net.DoPack){
NN_Net.DoPack(_msg);
}
};
//无限局创建新桌时返回游戏数据
Game_Modify.onCreateRoom = function(data){
NN_RevData.firstStartWar(data);
};
Game_Modify.createRoom=function(_roomtype, _infinite){//创建房间
if(_infinite != null){
NN_config.isInfinite = _infinite;
}else {
NN_config.isInfinite = 0;
}
};
Game_Modify.myJoinRoom=function(_msg){//自己进入房间
};
Game_Modify.Reconnect=function(_deskinfo){//重连
NN_Desk = new NN_deskInfo();
NN_Desk.initData_net(_deskinfo);
if(NN_Desk.model_fast >= 1 || NN_Desk.model == 4 || NN_Desk.model == 5){
if(NN_Desk.personMax == 10){
NN_UIP.update.game();
}else {
NN_UIF.update.game();
}
}else{
NN_UI.game(true, true);
}
//判断准备、换房、退出按钮显示
//if(Utl.getPlayerReadyState(NN_Desk.myseat)){
//Utl.closeMainSceneButton();
//this.pList[seat].isJoin = 1;
//}
//测试定时刷新游戏界面
//setInterval(function(){
//Game_Modify.updateScene();
//},2000);
};
Game_Modify.stopAllSounds=function(){//关闭所有声音 (游戏声音)
if(NN_playSound){
NN_playSound();
}
};
Game_Modify.Free=function(_msg){//投票解散结果为同意时,点击结果界面确认的按钮时触发
if(NN_RevData.disbandGame){
NN_RevData.disbandGame(_msg);
}
};
Game_Modify.DeskInfo=function(_msg){//开战状态下自己加入是牌桌数据
NN_Desk = new NN_deskInfo();
NN_Desk.initData_net(_msg);
if(NN_Desk.model_fast >= 1 || NN_Desk.model == 4 || NN_Desk.model == 5){
if(NN_Desk.personMax == 10){
NN_UIP.update.game();
}else {
NN_UIF.update.game();
}
}else{
NN_UI.game(true, true);
}
};
Game_Modify.breakRoom=function(){//游戏已开局情况下自己退出房间触发
//if(NN_UI.exit_clearDesk){
//NN_UI.exit_clearDesk();
//}
//先清除牛牛游戏界面
//NN_Exit_clearUI();
//清除牛牛游戏桌数据
//NN_Exit_clearData();
};
Game_Modify.playerJoinRoom=function(seat){//其他玩家加入房间
if(NN_Desk.isAddPlayer){
NN_Desk.isAddPlayer(seat);
}
//无限局显示玩家星星数
if(Utl.getIsInfinite() == 1){
NN_UIF.update.setGrade(seat, Utl.getBeanBySeat(seat), 1);
}
};
Game_Modify.playerLeaveRoom=function(seat){//其他玩家离开房间
if(NN_UI.isAddPlayer){
NN_UI.playerState_leave(seat,false);
NN_Desk.delPlayer(seat);
}
};
Game_Modify.updateScene = function(){//更新游戏界面
//根据本地数据重新显示界面
setTimeout(function(){
if(typeof(NN_Desk.state) != "undefined" && NN_Desk.pList){//
var temp_NN_Desk = JSON.stringify(NN_Desk);
if(NN_Desk.stageTime_loc > 0){
NN_Desk.stageTime = (new Date()).getTime() - NN_Desk.stageTime_loc;
}
NN_RevDataRecord.over = -1;
try{
if(NN_Desk.model_fast >= 1 || NN_Desk.model == 4 || NN_Desk.model == 5){
if(NN_Desk.personMax == 10){
NN_UIP.update.game();
}else {
NN_UIF.update.game();
}
}else{
NN_UI.game(true);
}
//普通房间准备按钮刷新显示
if(Utl.getIsInfinite() != 1){
GameUI.showReady();
}
}catch(e){
//alert("重画错误:"+e.message+" \n桌数据:"+JSON.stringify(NN_Desk));
NN_Net.submit_error("切回重画界面",e.stack+"出错时:"+JSON.stringify(NN_Desk)+" 未错时:"+temp_NN_Desk);
}
}
},200);
};
Game_Modify.closeGameScene=function(){//关闭游戏界面
//if(NN_UI.exit_clearDesk){
//NN_UI.exit_clearDesk();
//}
//先清除牛牛游戏界面
NN_Exit_clearUI();
//清除牛牛游戏桌数据
NN_Exit_clearData();
};
Game_Modify.playerOffline = function(seat){//玩家离线
if(NN_UI.playerState_leave){
NN_UI.playerState_leave(seat,false);
}
};
Game_Modify.playerOnline = function(seat){//玩家上线
if(NN_UI.playerState_leave){
NN_UI.playerState_leave(seat,true);
}
};
Game_Modify.playerphonestate = function(seat,type){//玩家电话状态type->挂断1->接打电话、有电话进来的状态
if(NN_UI.playerState_leave){
NN_UI.playerState_leave(seat,false);
}
};
Game_Modify.shakeEvent = function(){
switch(GameData.shakeID){
case Game_Config.shakeList.startwar://摇一摇开战(如果有主动开战)
var data={};
data.agentid=GameData.AgentId;
data.gameid=GameData.GameId;
data.playerid=C_Player.playerid;
data.roomcode=Desk.roomcode;
Net.Send_self_makewar(data);
Func.stopshake();
GameData.shakeID=Game_Config.shakeList.nil;
break;
}
};
Game_Modify.calResult = function(inputArr){
//console.log("计算结果:"+inputArr);
if(NN_Desk && NN_Desk.personMax == 10){
NN_UIP.gameOver.multResult(true, inputArr);
}else {
NN_UI.gameOver_multResult(inputArr);
}
};
Game_Modify.onEnterMainScene = function(roomtype){//进入游戏主场景
//玩家头像位置调整
if(roomtype[5] && roomtype[5][5] == 1){ //10人局
//框架相关显示
if(roomtype[5][1] == 1){
NN_Sprite.mainScence.init(10, 1);
}else{
NN_Sprite.mainScence.init(10);
}
}else{ //5人
//框架相关显示
NN_Sprite.mainScence.init(5);
}
//NN_UIP.deskInfo.update();
//游戏开始相关按钮调整
//Game_Modify.gameFunc.updateMainSceneBtn();
//无限局显示玩家星星数
if(Utl.getIsInfinite() == 1){
for(var i=0; i<5; i++){
NN_UIF.update.setGrade(i, Utl.getBeanBySeat(i));
}
}
};
Game_Modify.onExitMainScene = function(){//退出游戏主场景
//隐藏模式图标(比赛、星星)
set_self(976,37,0,0,0);
//先清除牛牛游戏界面
NN_Exit_clearUI();
//清除牛牛游戏桌数据
NN_Exit_clearData();
};
Game_Modify.onGameConfig = function(_gameConfig){//获取到游戏配置时调用(只在game_config有数据时才调用)
//alert("配置文件:"+JSON.stringify(_gameConfig));
NN_config.data = _gameConfig;
//局数及房卡消耗 格式:[[[6,4],[12,8]],[[6,1],[12,2]]];
if(_gameConfig.room_card && _gameConfig.room_card.length > 0){
NN_config.room_card = _gameConfig.room_card;
Game_Modify.gameFunc.roomCardUpdate();
}
/*
if(_gameConfig.room_card && _gameConfig.room_card.length > 0){
NN_config.room_card = _gameConfig.room_card;
for(var i=0;i<_gameConfig.room_card[0].length;i++){
if(_gameConfig.room_card[i].length == 2){
//局数
Game_Modify.Type_2[0].roomcount[i] = _gameConfig.room_card[i][0][0];
Game_Modify.Type_2[1].roomcount[i] = _gameConfig.room_card[i][1][0];
//房卡消耗数量
Game_Modify.Type_2[0].roomcard[i] = _gameConfig.room_card[i][0][1];
Game_Modify.Type_2[1].roomcard[i] = _gameConfig.room_card[i][1][1];
}
}
}
*/
// _gameConfig.card_mult = [[9,2],[1,1,1,1,1,1,1,1,1,2,3,4,4,6]];
//牛八2倍类型牌型倍数
if(_gameConfig.card_mult){
NN_config.card_mult = _gameConfig.card_mult;
//显示
var cap = ["一","二","三","四","五","六","七","八","九","双十"];
if(NN_config.card_mult[0][0] < 11){
Game_Modify.Type_3[0].des = "十带" + cap[NN_config.card_mult[0][0] - 1] + NN_config.card_mult[0][1] + "倍";
} else {
Game_Modify.Type_3[0].des = cap[NN_config.card_mult[0][0] - 1] + NN_config.card_mult[0][1] + "倍";
}
}
//是否强制下注配置
//if(_gameConfig.force_bet && _gameConfig.force_bet.length >= 3){
//NN_config.force_bet = _gameConfig.force_bet;
//}
//NN_config.force_bet = [1,-1,2];
//if(_gameConfig.model_bean){
//NN_config.model_bean = gameConfig.model_bean;
//}
//
//_gameConfig.cfg_bean[2] = [1,[111,222],1,[333,444]];
//服务费
if(_gameConfig.cfg_bean){
if(_gameConfig.cfg_bean[0] != null){
NN_config.cfg_bean[0] = _gameConfig.cfg_bean[0];
}
if(_gameConfig.cfg_bean[1] != null){
NN_config.cfg_bean[1] = _gameConfig.cfg_bean[1];
}
if(_gameConfig.cfg_bean[2] != null && _gameConfig.cfg_bean[2].length == 4){
NN_config.teaCost = NN_config.teaCost.slice(0,2).concat(_gameConfig.cfg_bean[2]);
if(NN_config.teaCost[2] == 2 && NN_config.teaCost[3] >= 0){ //固定值时赋值
NN_config.teaCost[1] = NN_config.teaCost[3];
}
}
//离场相关
if(_gameConfig.cfg_bean[3] != null){
NN_config.bean_leaveMin[1] = _gameConfig.cfg_bean[3][0];
NN_config.bean_leaveMin[2] = _gameConfig.cfg_bean[3][1];
}
}
//游戏相关设置
if(_gameConfig.cfg_game){
//无限局
if(_gameConfig.cfg_game[0] != null){
NN_config.isOwnerInfinite = _gameConfig.cfg_bean[0];
}
}
if(_gameConfig.ui){
if(_gameConfig.ui[0] != null){
NN_config.ui.sysRoomDes = _gameConfig.ui[0];
}
if(_gameConfig.ui[1] != null){
NN_config.creatRoomMode[0] = _gameConfig.ui[1];
}
}
//桌相关设置
if(_gameConfig.desk){
if(_gameConfig.desk[0] != null){ //强制下注,最低下注
NN_config.forceBetType = _gameConfig.desk[0];
}
}
//进入游戏后游戏初始化些数据
Game_Modify.gameFunc.initData();
//测试数据模拟
//NN_config.isOwnerInfinite = 1; //无限局
};
Game_Modify.onEnterVideo = function(){//进入牌局回放触发
};
Game_Modify.onSurrender = function(_msg){//收到投降回包
NN_RevData.surrender(_msg.data);
};
Game_Modify.onReady = function(seat){//玩家准备触发
if(NN_Desk && NN_Desk.model_fast != null && NN_Desk.model != null){
if(NN_Desk.personMax == 10){
NN_UIP.net.ready(seat);
}else {
NN_UIF.net.ready(seat);
}
//if(NN_Desk.model_fast < 1 && NN_Desk.model != 4 && NN_Desk.model != 5){
//NN_UI.playerReady(seat);
//}else { //快版
//NN_UIF.net.ready(seat);
//}
}
};
Game_Modify.getRoomInfo = function(roomtype, isInfinite ,tea, isAll){//通过roomtype获取房间描述每行最多18个字符超过需要自己换行
if(!roomtype || (roomtype && roomtype.length == 0)){ return; }
var _roomDes = "";
var personType = 0;
if(roomtype[5][5] == 1){
personType = 1;
}
//局数
if(isInfinite == 1){
//_roomDes += " 无限局";
_roomDes += " ";
} else if(NN_config.room_card[personType] && NN_config.room_card[personType].length == 2){
if(NN_config.room_card[personType][roomtype[4] - 1].length > 0 && NN_config.room_card[personType][roomtype[4] - 1][roomtype[0] - 1][0] > 0){ //房主扣卡
if(NN_config.room_card[personType][roomtype[4] - 1][roomtype[0] - 1][0] >= 10){
_roomDes += " " + NN_config.room_card[personType][roomtype[4] - 1][roomtype[0] - 1][0] + "局";
}else {
_roomDes += " " + NN_config.room_card[personType][roomtype[4] - 1][roomtype[0] - 1][0] + "局";
}
}
}
//扣卡张数
if(Utl.getVersionState() != 1){
if(isInfinite != 1 && roomtype[4] > 0){
if(NN_config.creatRoomMode[0] != 1 || (NN_config.creatRoomMode[0] == 1 && roomtype[5][1] != 1)){ //真人竞技房不显示扣卡
_roomDes += " " + (Game_Modify.Type_1[roomtype[4]-1].des + Game_Modify.Type_2[roomtype[0]-1].roomcard[roomtype[4]-1]);
if(NN_config.roomCardDes.slice(1,2) == "卡"){
_roomDes += "张";
}
}
if(_roomDes != ""){
_roomDes += "\n";
}
}else {
if(_roomDes != ""){
_roomDes += "\n";
}
}
}
//上庄
_roomDes += " " + Game_Modify.Type_4[roomtype[1]-1].des;
//几副牌
var _pairs = 0;
if(roomtype[2] == 1){
_pairs = 1;
}else if(roomtype[2] == 2){
_pairs = 2;
}
if(isAll){
_roomDes += " " + _pairs + "副牌 ";
}
//倍数
_roomDes += " " + Game_Modify.Type_3[roomtype[3]-1].des;
//快版
if(isInfinite != 1 && roomtype[5][0] != null && roomtype[5][0] == 1){
_roomDes += "\n 快版";
//if(roomtype[3] == 3){
//_roomDes += " 快版";
//}else {
//_roomDes += " 快版";
//}
}
//强制下注
if(isAll){
if(isInfinite != 1 && roomtype[6] && roomtype[6][0] != null && roomtype[6][0] == 1 && roomtype[6][2] > 0){
_roomDes += " 强制下注:" + roomtype[6][2];
//10人局
if(roomtype[5][5] == 1){
_roomDes += " " + Game_Modify.Type_6[4].des;
}
}else {
//10人局
if(roomtype[5][5] == 1){
_roomDes += " \n " + Game_Modify.Type_6[4].des;
}
}
}
//服务费
//if(isInfinite != 1 && !isAll && roomtype[5][3] != null && roomtype[5][3][0] == 1 && roomtype[5][3][1] > 0){
//if(tea != null){
//_roomDes += " \n 房间费:" + tea;
//}else {
//_roomDes += " \n 房间费:" + roomtype[5][3][1];
//}
//}
//星星数
if(isAll && roomtype[5][2] != null){
if(roomtype[5][1] == 1){
_roomDes += " \n " + NN_config.beanDes + "场(" + roomtype[5][2][2] + "倍)";
_roomDes += " " + NN_config.beanDes + "数限:" + roomtype[5][2][1] + "\n";
}else if(roomtype[5][2][0] == 1){
_roomDes += " \n "+ NN_config.beanDes +"数限:"+ roomtype[5][2][1]+"\n";
}
}
if(!isAll){
_roomDes = _roomDes.replace(/[\r\n]/g, ""); //去除换行
_roomDes = _roomDes.replace(/\s+/g, ' '); //多个空格替换一个空格
if(_roomDes.substring(0,1) == " "){
_roomDes = _roomDes.slice(1); //去除换行
}
}
return _roomDes;
};
Game_Modify.getStarLimit = function(roomtype){//通过roomtype获取房间星星场下限数量
//星星数限制
if(roomtype && roomtype[5][2] != null && roomtype[5][2][0] == 1){
return roomtype[5][2][1];
}
return 0;
};
Game_Modify.getMult = function(roomtype, isInfinite){//通过roomtype获取房间星星场倍数
//星星场倍数
if(roomtype && roomtype[5][2] != null && roomtype[5][2][0] == 1){
if(roomtype[5][2][2] > 0){
return roomtype[5][2][2];
} else {
return 1;
}
}
return 1;
};
Game_Modify.getFullRoomInfo = function(roomtype){//通过roomtype获取房间全部信息描述 返回的字符串最多两行,一行最多38字符
return Game_Modify.getRoomInfo(roomtype, 2 , null, 1);
};
Game_Modify.onOpenHelp = function(spid){//打开帮助页面触发spid为帮助内容图片精灵
};
Game_Modify.onMainMenuScene = function(){//显示大厅界面触发
//NN_config.beanDes = Utl.getstarName(); //星星文字显示
//NN_config.roomCardDes = Utl.getRoomCardName(); //房卡显示
//Game_Modify.Type_6[1].des = NN_config.beanDes +"场";
//Game_Modify.Type_6[2].des = NN_config.beanDes +"数";
};
Game_Modify.onCheckInput = function(_result){ //数字输入
};
//获取离场限制
Game_Modify.getLeaveLimit = function(roomtype){
return 0;
};
//成功获取定位信息触发
Game_Config.onLocationInfo = function(_locationInfo){
};
//成功获取定位信息触发
Game_Modify.onLocationInfo = function(_locationInfo){
};
//进入游戏界面创建牌桌之前调用
Game_Modify.onCreateDesk = function(roomtype){
NN_Sprite.init_OnCreateDesk(roomtype);
//console.log("onCreateDesk:"+roomtype);
};
Game_Modify.getVideoByRoomType = function(roomtype){
return 0;
};
//返回值为字符数组数组每项为房间一项描述信息
Game_Modify.getRoomTopDescAry = function(roomtype){
var _roomDes = [];
//局数
var personType = 0;
if(roomtype[5][5] == 1){
personType = 1;
}
if(Utl.getIsInfinite() != 1 && NN_config.room_card[personType] && NN_config.room_card[personType].length >= 2){
if(NN_config.room_card[personType][roomtype[4] - 1].length > 0 && NN_config.room_card[personType][roomtype[4] - 1][roomtype[0] - 1][0] > 0){ //房主扣卡
_roomDes.push(NN_config.room_card[personType][roomtype[4] - 1][roomtype[0] - 1][0] + "局");
}
}
//扣卡张数
if(Utl.getVersionState() != 1 && roomtype[4] > 0){
if(NN_config.creatRoomMode[0] != 1 || (NN_config.creatRoomMode[0] == 1 && roomtype[5][1] != 1)){ //真人竞技房不显示扣卡
_roomDes.push(Game_Modify.Type_1[roomtype[4]-1].des + Game_Modify.Type_2[roomtype[0]-1].roomcard[roomtype[4]-1]);
if(NN_config.roomCardDes.slice(1,2) == "卡"){
_roomDes[_roomDes.length -1] += "张";
}
}
}
//上庄
_roomDes.push(Game_Modify.Type_4[roomtype[1]-1].des);
//几副牌
_roomDes.push(roomtype[2] + "副牌");
//倍数
_roomDes.push(Game_Modify.Type_3[roomtype[3]-1].des);
//强制下注
if(Utl.getIsInfinite() != 1 && roomtype[6] && roomtype[6][0] != null && roomtype[6][0] == 1 && roomtype[6][2] > 0){
_roomDes.push("强制下注:" + roomtype[6][2]);
//10人局
if(roomtype[5][5] == 1){
_roomDes.push(Game_Modify.Type_6[4].des);
}
}else {
//10人局
if(roomtype[5][5] == 1){
_roomDes.push(Game_Modify.Type_6[4].des);
}
}
//快版
if(Utl.getIsInfinite() != 1 && roomtype[5][0] != null && roomtype[5][0] == 1){
_roomDes.push("快版");
}
//服务费
//if(isInfinite != 1 && !isAll && roomtype[5][3] != null && roomtype[5][3][0] == 1 && roomtype[5][3][1] > 0){
//if(tea != null){
//_roomDes += " \n 房间费:" + tea;
//}else {
//_roomDes += " \n 房间费:" + roomtype[5][3][1];
//}
//}
//星星数
//if(isAll && roomtype[5][2] != null){
//if(roomtype[5][1] == 1){
//_roomDes += " \n\n " + NN_config.beanDes + "场(" + roomtype[5][2][2] + "倍)";
//_roomDes += " \n " + NN_config.beanDes + "数限:" + roomtype[5][2][1] + "\n";
//}else if(roomtype[5][2][0] == 1){
//_roomDes += " \n\n "+ NN_config.beanDes +"数限:"+ roomtype[5][2][1]+"\n";
//}
//}
//if(!isAll){
//_roomDes = _roomDes.replace(/[\r\n]/g, ""); //去除换行
//_roomDes = _roomDes.replace(/\s+/g, ' '); //多个空格替换一个空格
//if(_roomDes.substring(0,1) == " "){
//_roomDes = _roomDes.slice(1); //去除换行
//}
//}
return _roomDes;
};
//星星场房间列表
Game_Modify.getShareRoom = function(_msg){
}
//玩家自己退出房间
Game_Modify.myExitRoom = function(seat){
}
//接收到换座包触发
Game_Modify.changeSeat = function(seat1,seat2){
}
//判断房间是否为金币场(是金币场返回1否则返回0)
Game_Modify.getRoomMode = function(roomtype){
if(roomtype[5] != null ){
if(roomtype[5][1] != null){
if(roomtype[5][1] == 1){
return 1;
}
}
}
return 0;
}