

var Desk=Desk||{};

Desk.PlayerList=[];//玩家列表 
Desk.roomcode = "";//房间号 
Desk.stage=0;//牌桌阶段 0->未开局 1->已开局 
Desk.state=0;//牌桌解散状态 0->正常 1->申请解散状态
Desk.applyresult=-1;//投票结果-1->无结果0->不通过1->通过 
Desk.AgreeList=[];//同意解散座位列表
Desk.agreefree=[]; 
Desk.roomtype = [];
Desk.warcnt=0;//开战条件
Desk.playercnt=0;//玩家总数
Desk.count=0;// 总局数 
Desk.deskfree=null; 
Desk.starCount = 0;//投降扣除星星数量
Desk.roomMode = 0;//0->普通场 1->星星场 
Desk.needprepare = 0;//是否需要准备 
Desk.myInfo = null;//自己的信息
Desk.infinite = 0;//无限局 
Desk.isSystem = 1;//是否为系统房间 
Desk.shortcode = null;//房间短号
Desk.videoConfig = null;//视频房选项 
Desk.ownerNotice = null;//短号房主留言 
Desk.videoDes = "";//视频房描述 
Desk.rebateNumber = 0;//房间抽成数量 
Desk.rebateMode = 0;//抽成类型 
Desk.rebateType = 0;//抽金币还是魅力值 
Desk.setMyInfo = function(_data){
	Desk.myInfo.seat = _data.seat;
	Desk.myInfo.playerid=_data.playerid;
	Desk.myInfo.nickname=_data.nickname;
	Desk.myInfo.avatar=_data.avatar;
	Desk.myInfo.sex=_data.sex;
	Desk.myInfo.ip=_data.ip;
	Desk.myInfo.onstate=_data.onstate;
	Desk.myInfo.bean = _data.bean;
	Desk.myInfo.initialBean = _data.bean;//玩家豆子初始值
	//Desk.myInfo.paycode = _data.paycode;
}
//设置vip房主公告 
Desk.setOwnerNotice = function(_value){
	if(_value){
		Desk.ownerNotice = _value;
	}
	
}
Desk.setRebateNumber = function(_value){
	if(_value){
		Desk.rebateNumber = _value;
	}

}
Desk.setRebateMode = function(_value){
	if(_value){
		Desk.rebateMode = _value;
	}
}
Desk.setRebateType = function(_value){
	if(_value){
		Desk.rebateType = _value;
	}
}
Desk.setStarCount = function(_value){
	Desk.starCount = _value;
} 
Desk.setInfinite = function(_value){
	Desk.infinite = _value;
	//Desk.infinite = 1;
}
Desk.setRoomMode = function(_value){
	Desk.roomMode = _value;
}
Desk.Create=function(roomtype){//创建牌桌
	this.PlayerList= [];
	if(typeof Game_Modify.getMaxPlayerCount !== 'undefined'){
		this.PlayerList.length = Game_Modify.getMaxPlayerCount(roomtype);
	}else{
		this.PlayerList.length = Game_Config.Max.PlayerCnt;
	}	
	
	for(var i=0;i<this.PlayerList.length;i++){
		this.PlayerList[i] = new Player(i);
	}
	//Desk.myInfo = new Player(-1);
}
Desk.setShortCode = function(_shortcode){
	if(typeof _shortcode != "undefined"){
		Desk.shortcode = _shortcode;
	}else{
		Desk.shortcode = null;
	}
	
}
Desk.getShortCode = function(){
	if(Desk.shortcode){
		return Desk.shortcode;
	}else{
		return null;
	}

}
Desk.setVideoConfig = function(config){
	if(config){
		Desk.videoConfig = config;
		var des = Logic.alyVideoConfig(config);
		Desk.videoDes = "【视频房】"
	}
}
Desk.SetStage=function(v){
	this.stage=v;
}
Desk.getPrepareCnt=function(){
	if(Desk.needprepare == 1){
		var rValue = 0;
		for(var i=0;i<Desk.PlayerList.length;i++){
			if(Desk.PlayerList[i].isprepare == 1){
				rValue++;
			}
		}
		if(C_Player.isprepare == 0){
			rValue++;
		}
		return rValue;
	}else{
		return Desk.playercnt;
	}
}
Desk.inDesk=function(_playerid){
	for(var i=0;i<Desk.PlayerList.length;i++){
		if(Desk.PlayerList[i].playerid == _playerid){
			return true;
		}
	}
	return false;
}
Desk.Init=function(){//牌桌信息初始化 
	for(var i=0;i<this.PlayerList.length;i++){
		var pobj=this.GetPlayerBySeat(i);
		pobj.Init(false);
		pobj = null;
	}
	Desk.count=0;// 总局数
	this.warcnt=0;//开战条件
	this.playercnt=0;//玩家总数
	this.applyresult=-1;//投票结果-1->无结果0->不通过1->通过
	this.roomcode = "";//房间号
	this.stage=0;//牌桌阶段 0->未开局 1->已开局
	this.state=0;//牌桌解散状态 0->正常 1->申请解散状态
	this.AgreeList=[];//同意解散座位列表
	Desk.deskfree=null;
	Desk.starCount = 0;//投降扣除星星数量
	Desk.roomMode = 0;//0->普通场 1->星星场
	Desk.needprepare = 0;//是否需要准备
	Desk.infinite = 0;//无限局
	Desk.shortcode = null;
	Desk.videoConfig = null;//视频房选项
	Desk.videoDes = "";//视频房描述
	Desk.ownerNotice = null;//短号房主留言
	Desk.rebateNumber = 0;//房间抽成数量
	Desk.rebateMode = 0;//抽成类型
	Desk.rebateType = 0;//抽金币还是魅力值
	//Desk.myInfo.Init();//自己的信息
}
Desk.setRoom=function(roomcode,asetcount,roomtype){//设置房间号 
	this.roomcode = roomcode;
	this.count = asetcount;
	this.roomtype = roomtype;
	//Game_Modify.setRoomDes(roomcode,asetcount,roomtype);
	//set_self(291,7,Game_Modify.roomDes,0,0);
	
	
}
Desk.GetPlayerBySeat=function(seat){
	return this.PlayerList[seat];
}
Desk.change_seat = function(_msg){
	var pobj1 = Desk.GetPlayerBySeat(_msg.data.seat1);
	var pobj2 = Desk.GetPlayerBySeat(_msg.data.seat2);
	var info1 = pobj1.getDeskInfo();
	var info2 = pobj2.getDeskInfo();
	pobj1.SetDeskInfo(info2,true);
	pobj2.SetDeskInfo(info1,true);
	if(C_Player.seat == _msg.data.seat1){
		C_Player.SetSeat(_msg.data.seat2);
	}else if(C_Player.seat == _msg.data.seat2){
		C_Player.SetSeat(_msg.data.seat1);
	}
	if(Game_Modify.changeSeat){
		Game_Modify.changeSeat(_msg.data.seat1,_msg.data.seat2);
	}
	if(Game_Config.sysConfig){
		if(!Game_Config.sysConfig.changeSeat){
			GameUI.updatePlayerInfoUI();	
		}
	}else{
		GameUI.updatePlayerInfoUI();
	}
	
}
Desk.getPlayerIndexByPlayerid=function(_playerid){
	_playerid = Number(_playerid);
	if(_playerid<0){return -1;}
	for(var i=0;i<Desk.PlayerList.length;i++){
		if(_playerid == Number(Desk.PlayerList[i].playerid)){
			return Logic.ChangeToStatus(C_Player.seat,i);
		}
	}
	return -1;
}
Desk.login=function(_msg){//登录 
	
	if(_msg.data.state==0){
		if(GameData.sysConfig.deviceLogin){
			Utl.SaveData(Utl.Config.dLogin,1);
			// GameData.loginPlayerid = false;
			
			var wxdata={};
			wxdata.openid = _msg.data.openid;
			wxdata.headimgurl = _msg.data.avatar;
			wxdata.nickname = _msg.data.nickname;
			wxdata.sex = _msg.data.sex;
			wxdata.city = _msg.data.city;
			wxdata.Province = _msg.data.province;
			wxdata.unionid = _msg.data.unionid;
			wxdata.telphone = _msg.data.tel;
			C_Player.setTel(_msg.data.tel);
			
			C_Player.SetWxInfo(wxdata.openid,wxdata.headimgurl,wxdata.nickname,wxdata.sex,wxdata.city,wxdata.Province,wxdata.unionid);
			wxdata=JSON.stringify(wxdata);
			
			Utl.setCookie(Utl.Config.devicePlayer,wxdata);	
			
		}
		//C_Player.Init();
		GameData.hallLogin = false;
		
		GameData.sendLoginTimes = 0;
		Logic.savePlayerId(_msg.data.playerid);
		GameData.isLogin=true;
		this.Init();
		if(!(_msg.data.score)){
			_msg.data.score = 0;
		}
		if(_msg.data.invitecode){
			C_Player.setInvitecod(_msg.data.invitecode);
		}else{
			if(window["app_invitationcode"]){
				var data = {};
				data.agentid = GameData.AgentId;
				data.playerid = C_Player.playerid;
				data.invitecode = app_invitationcode;
				Net.Send_binding_invitecode(data);
			}
		}
		if(_msg.data.initCard){
			GameData.initCard = Number(_msg.data.initCard);
		}else{
			GameData.initCard = 0;
		}
		
		if(_msg.data.initBean){
			GameData.initBean = Number(_msg.data.initBean);
		}else{
			GameData.initBean = 0;
		}
		C_Player.SetMyInfo(_msg.data);
		//C_Player.SetMyInfo(_msg.data.playerid,_msg.data.roomcard,_msg.data.taskstate,_msg.data.ip,_msg.data.score,_msg.data.bean);
		
		if(_msg.data.advanced){
			C_Player.advanced = _msg.data.advanced;
		}else{
			C_Player.advanced = 0;
		}
		GameData.AgentId=_msg.data.agentid;
		GameData.ChannelId=_msg.data.channelid;
		if(ConstVal.isGameHall){
			gameHallImport.setGameList();	
		}
		
		if(_msg.data.roomcode){//已在房间中
			Utl.SaveData("openminigamedata","");
			Logic.updateMainSceneData(_msg.data.roomtype);
			if(_msg.data.match){
				GameData.matchInfo = _msg.data.match;
			}else{
				GameData.matchInfo = null;
			}
			if(_msg.data.matchid){
				GameData.matchId = _msg.data.matchid;
			}else{
				GameData.matchId = null;
			}
			if(typeof _msg.data.roommode != "undefined"){
				Desk.setRoomMode(Number(_msg.data.roommode));
			}
			if(_msg.data.beanlimit){
				Desk.setStarCount(_msg.data.beanlimit);
			}
			if(typeof _msg.data.needprepare != "undefined"){
				Desk.needprepare = _msg.data.needprepare;
			}
			if(_msg.data.infinite){
				Desk.setInfinite(_msg.data.infinite);
			}
			Desk.setRebateNumber(_msg.data.rebateNumber);
			Desk.setRebateMode(_msg.data.rebateMode);
			Desk.setRebateType(_msg.data.rebateType);
			C_Player.setSign(_msg.data.sign);
			Desk.setOwnerNotice(_msg.data.ownerNotice);
			Desk.setVideoConfig(_msg.data.videoConfig);
			Desk.setShortCode(_msg.data.shortcode);
			if(_msg.data.shortcode){
				GameData.vipRoomJump = true;
				Logic.addVipRoom(_msg.data.shortcode);
			}else{
				GameData.vipRoomJump = false;
			}
			C_Player.SetSeat(_msg.data.seat);
			this.warcnt=_msg.data.makewar;
			
			Desk.count = _msg.data.asetcount;
			this.stage=_msg.data.isbattle;
			if(_msg.data.isowner==1){//房主设置
				C_Player.status=1;
			}else{
				C_Player.status=2;
			}
			if(_msg.data.seat==0){//房主设置
				C_Player.isStart=true;
			}else{
				C_Player.isStart=false;
			}
			var pobj=this.GetPlayerBySeat(_msg.data.seat);
			pobj.SetDeskInfo(C_Player);
			pobj = null;
			for(var i=0;i<_msg.data.players.length;i++){
				if(_msg.data.players[i]!=null){
					if(i == C_Player.seat){
						C_Player.isprepare = _msg.data.players[i].isprepare;
					}
					var pobj=this.GetPlayerBySeat(i);
					pobj.SetDeskInfo(_msg.data.players[i]);
					pobj = null;
					this.playercnt++;
					GameUI.SetOnState(i,_msg.data.players[i].onstate);
					GameUI.SetIsprepare(i,_msg.data.players[i].isprepare);
				}
			}
			//GameData.getbatteryPack = _msg;
			//GameData.getbattery = "MainScene.Desk.login";
			Desk.setRoom(_msg.data.roomcode,_msg.data.asetcount,_msg.data.roomtype);
			//if(get_self(149,37,0,0,0) == 0 && GameData.iscloseVideo){
			//	Func.createRoom();
			//}
			GameUI.MainScene(true);
			Game_Modify.setRoomDes(_msg.data.roomcode,_msg.data.asetcount,_msg.data.roomtype);
			set_self(291,7,Game_Modify.roomDes,0,0);
			//if(GameData.userAgent != ConstVal.userAgent.uAgent_3){
				if(Desk.infinite == 0){
					if(Desk.stage==0){
						GameUI.ShowStartScene();				
					}else{
						GameUI.hideOwnerNotice();
					}
					GameUI.showReady();
				}else{
					GameUI.ShowStartScene();
					//if(Desk.stage == 0){
						//if(C_Player.isprepare == 1){
							GameUI.showReady();
							
						//}
					//}
					
				}
					
				
				
				if(_msg.data.isbet == 0){
					C_Player.ChangeExit(1);
				}else{
					C_Player.ChangeExit(0);
				}
				if(Desk.infinite == 1){
					C_Player.ChangeExit(1);
				}
				if(_msg.data.agreefree){
					if(_msg.data.agreefree!=null){
						var bTemp=false;
						Desk.state=1;
						Desk.GetPlayerBySeat(_msg.data.seat).ApplyBreakRoom();
						Desk.agreefree=_msg.data.agreefree.state;
						for(var i=0;i<Desk.agreefree.length;i++){
							if(Desk.agreefree[i]==1){
								Desk.AgreeList.push(i);
								var pobj=Desk.GetPlayerBySeat(C_Player.seat,i);
								pobj.state=Desk.agreefree[i];
								if(i==C_Player.seat){
									C_Player.state = 1;
									bTemp=true;
								}
							}
							if(Desk.agreefree[i]==0){
								var pobj=Desk.GetPlayerBySeat(C_Player.seat,i);
								pobj.state=Desk.agreefree[i];
								if(i==C_Player.seat){
									C_Player.state = 0;
									bTemp=true;
								}
							}
						}
						GameUI.OpenApply(bTemp,_msg.data.agreefree.countdown);
					}
					
				}
				GameUI.mainSceneLoaded();
				if(_msg.data.deskinfo){
					if(get_self(149,37,0,0,0) == 0 && !GameData.iscloseVideo){
						Func.createRoom();
					}
					Game_Modify.Reconnect(_msg.data.deskinfo);
				}
			//}
		}else{			
			Game_Modify.closeGameScene();
			GameUI.JumpMenuScene();
			if(!GameData.isReconnect){
				if(Logic.JudgeShow()){
					GameUI.OpenBoard();
				}else{
					/*
					if(GameData.hallConfig.worldRoomList){
						var data={};
						data.agentid = GameData.AgentId;
						data.playerid = C_Player.playerid;
						data.gameid = GameData.GameId;
						Net.Send_get_share_room(data);
					}
					*/
				}
			}
			GameData.isReconnect = false;
			if(_msg.data.matchid){
				Logic.openMatchUrl();
			}	
		}
		
	}else{
		GameUI.OpenTips(_msg.data.msg || "登录失败",ConstVal.Tips.time);
	}
}
Desk.create_room=function(_msg){//创建房间 
	if(_msg.data.state==0){//成功 
			Utl.SaveData("openminigamedata","");
			Logic.updateMainSceneData(_msg.data.roomtype);
			Desk.Init();
			
			if(_msg.data.match){
				GameData.matchInfo = _msg.data.match;
			}else{
				GameData.matchInfo = null;
			}
			if(_msg.data.matchid){
				GameData.matchId = _msg.data.matchid;
			}else{
				GameData.matchId = null;
			}
			if(typeof _msg.data.roommode != "undefined"){
				Desk.setRoomMode(Number(_msg.data.roommode));
			}
			if(_msg.data.beanlimit){
				Desk.setStarCount(_msg.data.beanlimit);
			}
			if(_msg.data.infinite){
				Desk.setInfinite(_msg.data.infinite);
			}
			Desk.setRebateNumber(_msg.data.rebateNumber);
			Desk.setRebateMode(_msg.data.rebateMode);
			Desk.setRebateType(_msg.data.rebateType);
			Desk.setVideoConfig(_msg.data.videoConfig);
			if(typeof _msg.data.needprepare != "undefined"){
				Desk.needprepare = _msg.data.needprepare;
			}
			Desk.setShortCode(_msg.data.shortcode);
			if(_msg.data.shortcode){
				GameData.vipRoomJump = true;	
				Logic.addVipRoom(_msg.data.shortcode);
			}else{
				GameData.vipRoomJump = false;
			}
			Utl.saveRoomtype(_msg.data.roomtype);
			
			this.warcnt=_msg.data.makewar;
			C_Player.SetSeat(_msg.data.seat);
			C_Player.status=1;
			C_Player.isprepare = 0;
			C_Player.isStart = true;//能否点击按钮开始游戏
			this.playercnt=1;
			C_Player.ChangeExit(1);
			var pobj=this.GetPlayerBySeat(_msg.data.seat);
			pobj.SetDeskInfo(C_Player);
			//GameData.getbattery = "MainScene.Desk.create_room";
			//GameData.getbatteryPack = _msg;
			Desk.setRoom(_msg.data.roomcode,_msg.data.asetcount,_msg.data.roomtype);
			GameUI.MainScene(true);	
			Game_Modify.setRoomDes(_msg.data.roomcode,_msg.data.asetcount,_msg.data.roomtype);
			set_self(291,7,Game_Modify.roomDes,0,0);
			//if(GameData.userAgent != ConstVal.userAgent.uAgent_3){
				GameUI.ShowStartScene();
				GameUI.showReady();
				
				Desk.count = _msg.data.asetcount;
			//}
			
			if(GameData.h5Version == 1){
				GameData.isJoinRoomFromH5 = true;
			}
			Func.createRoom();
			GameUI.mainSceneLoaded();
	}else{//失败 
		
		if(_msg.data.showerror==1){
			GameUI.OpenTips(_msg.data.error,ConstVal.Tips.time);
		}
	}
}
Desk.self_join_room=function(_msg){//自己进入房间
	GameUI.hideMyRoomList();
	Utl.SaveData("openminigamedata","");
	switch(_msg.data.state){
		case 0://进入房间成功 
			
			Logic.updateMainSceneData(_msg.data.roomtype);
			Desk.Init();
			if(_msg.data.shortcode){
				Logic.saveShortCode(_msg.data.shortcode);
				Logic.addVipRoom(_msg.data.shortcode);
				GameData.shortCode = "";
				GameData.vipRoomJump = true;
			}else{
				GameData.vipRoomJump = false;
				//GameData.shortCode = "";
				//Logic.saveShortCode("");
			}
			if(_msg.data.infinite){
				Desk.setInfinite(_msg.data.infinite);
			}
			if(_msg.data.match){
				GameData.matchInfo = _msg.data.match;
			}else{
				GameData.matchInfo = null;
			}
			if(_msg.data.matchid){
				GameData.matchId = _msg.data.matchid;
			}else{
				GameData.matchId = null;
			}
			if(typeof _msg.data.roommode != "undefined"){
				Desk.setRoomMode(Number(_msg.data.roommode));
			}
			if(_msg.data.beanlimit){
				Desk.setStarCount(_msg.data.beanlimit);
			}
			if(typeof _msg.data.needprepare != "undefined"){
				Desk.needprepare = _msg.data.needprepare;
			}
			Desk.setRebateNumber(_msg.data.rebateNumber);
			Desk.setRebateMode(_msg.data.rebateMode);
			Desk.setRebateType(_msg.data.rebateType);
			Desk.setOwnerNotice(_msg.data.ownerNotice);
			Desk.setVideoConfig(_msg.data.videoConfig);
			Desk.setShortCode(_msg.data.shortcode);
			if(_msg.data.ownerNote){
				//GameData.ownerNote = _msg.data.ownerNote;
				Logic.setOwnerNote(_msg.data.ownerNote);
				Utl.SaveData(Utl.Config.ownerNote,_msg.data.ownerNote);
			}
			Desk.warcnt = _msg.data.makewar;
			
			C_Player.SetSeat(_msg.data.seat);
			//if(_msg.data.paycode){
				C_Player.setPayCode(_msg.data.paycode);
			//}else{
				//C_Player.setPayCode("");
			//}
			
			//C_Player.status=2;
			if(_msg.data.isowner==1){//房主设置
				C_Player.status=1;
				Logic.removeRoomFromList(Number(_msg.data.roomcode));
			}else{
				C_Player.status=2;
			}
			if(_msg.data.seat==0){//房主设置
				//C_Player.status=1;
				C_Player.isStart = true;//能否点击按钮开始游戏
			}else{
				//C_Player.status=2;
				C_Player.isStart = false;//能否点击按钮开始游戏
			}
			C_Player.ChangeExit(1);
			
			this.GetPlayerBySeat(_msg.data.seat).SetDeskInfo(C_Player);
			this.playercnt=0;
			for(var i=0;i<_msg.data.players.length;i++){
				//var pobj=this.GetPlayerBySeat(_msg.data.players[i].seat);
				if(_msg.data.players[i]!=null){
					if(i == C_Player.seat){
						C_Player.isprepare = _msg.data.players[i].isprepare;
					}
					var pobj=this.GetPlayerBySeat(i);
					pobj.SetDeskInfo(_msg.data.players[i]);
					this.playercnt++;
					//if(_msg.data.players[i].seat==0){//房主设置
						//pobj.status=1;
					//}else{
						//pobj.status=2;
					//}
					GameUI.SetOnState(i,_msg.data.players[i].onstate);
					GameUI.SetIsprepare(i,_msg.data.players[i].isprepare);
				}
			}
			//GameData.getbattery = "MainScene.Desk.self_join_room";
			//GameData.getbatteryPack = _msg;
			Desk.setRoom(_msg.data.roomcode,_msg.data.asetcount,_msg.data.roomtype);
			GameUI.MainScene(true);
			Game_Modify.setRoomDes(_msg.data.roomcode,_msg.data.asetcount,_msg.data.roomtype);
			set_self(291,7,Game_Modify.roomDes,0,0);
			//if(GameData.userAgent != ConstVal.userAgent.uAgent_3){
				Game_Modify.myJoinRoom(_msg);
				
				if(_msg.data.deskwar){
					Desk.stage=1;
					GameUI.hideOwnerNotice();
					C_Player.ChangeExit(0);
					if(Desk.infinite == 1){
						C_Player.ChangeExit(1);
					}
					//Desk.setRoom(_msg.data.roomcode,_msg.data.asetcount,_msg.data.roomtype);
					Game_Modify.StartWar(_msg);
				}else{
					//this.stage=0;
					//GameUI.ShowStartScene();
					//C_Player.ChangeExit(1);
					if(_msg.data.deskinfo){
						Desk.stage=1;
						//Game_Modify.DeskInfo(_msg.data.deskinfo);
						if(Desk.infinite == 1){
							GameUI.ShowStartScene();
						}
						Game_Modify.DeskInfo(_msg.data.deskinfo);
							//C_Player.ChangeExit(0);
					}else{
						Desk.stage=0;
						GameUI.ShowStartScene();
						C_Player.ChangeExit(1);
					}
					
					//Desk.setRoom(_msg.data.roomcode,_msg.data.asetcount,_msg.data.roomtype);
				}
				GameUI.showReady();
				if(Desk.infinite == 1 && Desk.stage==1){
					GameUI.hideReady();
				}
				////Desk.count/////////
				
				Desk.count = _msg.data.asetcount;
				//if(GameData.iscloseVideo){
					//Func.createRoom();
				//}
				if(GameData.iscloseVideo){
					if(!_msg.data.deskwar){//未自动开战 
						if(!_msg.data.deskinfo){//其他人未开战 							
							Func.createRoom();
							
						}	
					}
				}else{
					Func.createRoom();
				}
				GameUI.mainSceneLoaded();
			//}
			break;

		default:
			if(_msg.data.showerror==1){
				if(_msg.data.error.indexOf("\n")>-1){
						GameUI.openTips2(_msg.data.error);	
				}else{
					GameUI.OpenTips(_msg.data.error,ConstVal.Tips.time);
				}
			
			}
			if(_msg.data.state==99){
				Logic.removeRoomFromList(Number(_msg.data.roomcode));
				GameUI.updateNoticeBoard();	
			}
			break;
	}	
	if(GameData.h5Version == 1){
		GameUI.closeCheck();
		GameData.isJoinRoomFromH5 = true;
	}
}
Desk.self_break_room=function(_msg){//接收未开局之前房主自己解散房间
	GameData.shakeID = Game_Config.shakeList.nil;
	Func.stopshake();
	Func.exitRoom();
	this.Init();
	if(_msg.data.roomcode){
		Logic.removeRoomFromList(Number(_msg.data.roomcode));
		//GameUI.updateNoticeBoard();
	}
	C_Player.BreakRoom();
	GameUI.JumpMenuScene();
	Game_Modify.stopAllSounds();
	
}
Desk.other_break_room=function(_msg){//接收未开局之前他人房主解散房间
	Func.exitRoom();
	this.Init();
	C_Player.BreakRoom();
	Game_Modify.stopAllSounds();
	GameUI.JumpMenuScene();
	GameUI.OpenTips("房主已解散房间！",ConstVal.Tips.time);
}
Desk.other_join_room=function(_msg){//接收其他玩家加入房间
	var pobj=this.GetPlayerBySeat(_msg.data.seat);
	pobj.SetDeskInfo(_msg.data);
	if(typeof _msg.data.needprepare != "undefined"){
		this.needprepare = _msg.data.needprepare;
	}
	GameUI.PlayerJoinRoom(_msg.data.seat);
	Game_Modify.playerJoinRoom(_msg.data.seat);
	this.playercnt++;
	GameUI.showStartButton();
	if(C_Player.status == 1 && this.playercnt == 2 && this.roomMode == 1 && this.infinite == 0 && this.stage == 0){
		//GameUI.showEscape();//set_self(513,37,1,0,0);
	}else{
		//GameUI.hideEscape();//set_self(513,37,0,0,0);
		if(GameData.checkType==3){
			GameUI.closeCheck();
		}
	}
	if(_msg.data.deskwar){
		this.makewar(_msg);
	}else{
		
	}
}
Desk.self_exit_room=function(_msg){//接收未开局之前自己退出房间
	var tmp = this.infinite;
	if(this.stage==1){
		Game_Modify.breakRoom();
	}
	Func.exitRoom();
	if(typeof(_msg.data.isowner)!="undefined"){
		if(_msg.data.isowner == 1 && this.infinite == 0){
			Logic.addRoomToList(Number(_msg.data.roomcode));
			//GameUI.updateNoticeBoard();
		}
	}
	if(Game_Modify.myExitRoom){
		Game_Modify.myExitRoom(_msg.data.seat);
	}
	this.Init();
	
	C_Player.BreakRoom();
	GameUI.JumpMenuScene();
	Game_Modify.stopAllSounds();
	if(tmp && GameData.hallConfig.worldRoomList && !Game_Config.sysConfig.vipInfinite){
		if(GameData.worldRoomSys.length > 0){
			GameUI.openWorldRoom();
		}else{
			var data={};
			data.agentid = GameData.AgentId;
			data.playerid = C_Player.playerid;
			data.gameid = GameData.GameId;
			Net.Send_get_share_room(data);
		}
	}
}
Desk.other_exit_room=function(_msg){//接收未开局之前其他玩家退出房间
	var pobj=this.GetPlayerBySeat(_msg.data.seat);
	pobj.Init(false);
	this.playercnt--;
	GameUI.showStartButton();
	if(C_Player.status == 1 && this.playercnt == 2 && this.roomMode == 1 && this.infinite == 0 && this.stage == 0){
		//GameUI.showEscape();//set_self(513,37,1,0,0);
	}else{
		//GameUI.hideEscape();//set_self(513,37,0,0,0);
		if(GameData.checkType==3){
			GameUI.closeCheck();
		}
	}
	if(_msg.data.seat == 0 && this.infinite == 0){
		GameUI.OpenTips("房主已经离开，新进入房间的玩家成为新房主，您也可重进房间成为房主");
	}
	Game_Modify.playerLeaveRoom(_msg.data.seat);
	GameUI.PlayerLeaveRoom(_msg.data.seat);
}
Desk.self_apply_free_room=function(_msg){//接收开局之后自己申请解散房间
	C_Player.ApplyBreakRoom();
	this.state=1;
	this.GetPlayerBySeat(C_Player.seat).ApplyBreakRoom();
	this.agreefree=_msg.data.agreefree.state;
	for(var i=0;i<this.agreefree.length;i++){
		if(this.agreefree[i]==1){
			this.AgreeList.push(i);
		}
	}
	GameUI.OpenApply(true,_msg.data.agreefree.countdown);

}
Desk.other_apply_free_room=function(_msg){//接收开局之后其他玩家申请解散房间
	this.state=1;
	//this.AgreeList.push(_msg.data.seat);
	this.GetPlayerBySeat(_msg.data.seat).ApplyBreakRoom();
	this.agreefree=_msg.data.agreefree.state;
	for(var i=0;i<this.agreefree.length;i++){
		if(this.agreefree[i]==1){
			this.AgreeList.push(i);
		}
	}
	GameUI.OpenApply(false,_msg.data.agreefree.countdown);
}
Desk.self_agree_free_room=function(_msg){//接收自己同意解散房间
	C_Player.AgreeBreakRoom();
	this.state=1;
	this.AgreeList.push(C_Player.seat);
	this.GetPlayerBySeat(C_Player.seat).AgreeBreakRoom();	
	GameUI.SelfVote(1);
}
Desk.other_agree_free_room=function(_msg){//接收其他玩家同意解散房间
	this.state=1;
	this.AgreeList.push(_msg.data.seat);
	this.GetPlayerBySeat(_msg.data.seat).ApplyBreakRoom();
	GameUI.OtherVote(1,_msg);
}
Desk.self_refuse_free_room=function(_msg){//接收自己拒绝解散房间
	C_Player.RefuseBreakRoom();
	this.state=0;
	this.applyresult=0;
	this.AgreeList=[];
	for(var i=0;i<this.PlayerList.length;i++){
		var pobj=this.GetPlayerBySeat(i);
		pobj.state=0;
	}
	GameUI.OpenApplyResult(false,[C_Player.seat]);
}
Desk.other_refuse_free_room=function(_msg){//接收其他玩家拒绝解散房间
	C_Player.RefuseBreakRoom();
	this.state=0;
	this.applyresult=0;
	this.AgreeList=[];
	for(var i=0;i<this.PlayerList.length;i++){
		var pobj=this.GetPlayerBySeat(i);
		pobj.state=0;
	}
	GameUI.OpenApplyResult(false,[_msg.data.seat]);
}
Desk.free_room=function(_msg){//接收解散房间	
	
	if(_msg.data.freeNow){
		if(_msg.data.deskfree){
			Desk.deskfree=_msg.data.deskfree;
		}
		if(_msg.data.roomcard){
			C_Player.setRoomcard(_msg.data.roomcard);
		}
		Game_Modify.Free(Desk.deskfree);
		GameUI.OpenTips(_msg.data.tips,_msg.data.time);	
	}else{
		Func.exitRoom();
		this.applyresult=1;
		GameUI.OpenApplyResult(true,_msg.data.seats);
		if(_msg.data.deskfree){
			Desk.deskfree=_msg.data.deskfree;
		}
		if(_msg.data.roomcard){
			C_Player.setRoomcard(_msg.data.roomcard);
		}
	}
}
Desk.other_offline=function(_msg){//其他玩家离线 
	var pobj=this.GetPlayerBySeat(_msg.data.seat);
	pobj.onstate=1;
	GameUI.SetOnState(_msg.data.seat,1);
	Game_Modify.playerOffline(_msg.data.seat);
}
Desk.other_online=function(_msg){//其他玩家上线 
	var pobj=this.GetPlayerBySeat(_msg.data.seat);
	pobj.onstate=0;
	pobj.ip=_msg.data.ip;
	GameUI.SetOnState(_msg.data.seat,0);
	Game_Modify.playerOnline(_msg.data.seat);
}
Desk.send_text=function(_msg){//发送消息 
	//百人场只支持全服公告 
	if(Game_Config.sysConfig.vipInfinite && _msg.data.type == 1){
		GameUI.CloseChat();
		GameUI.addSysNotice(_msg.data.text);
		GameUI.updateSysNoticeCount();
		set_self(204,7,"",0,0);
		GameUI.updateSysNoticeBubble(_msg.data.text);		
		return;
		
	}
	if(!_msg.data.type){
		var pobj = Desk.GetPlayerBySeat(_msg.data.seat);
		GameUI.playTextVoice(_msg.data.text,pobj.sex);
		GameUI.ShowChat(Logic.ChangeToStatus(C_Player.seat,_msg.data.seat),_msg.data.text);
		GameUI.addCommunion(Logic.ChangeToStatus(C_Player.seat,_msg.data.seat),1,_msg.data.text,0,null,pobj.sex);
	}else if(_msg.data.type == 1){//全服公告 
		GameUI.CloseChat();
		GameUI.addSysNotice(_msg.data.text);
		GameUI.updateSysNoticeCount();
		set_self(204,7,"",0,0);
		GameUI.updateSysNoticeBubble(_msg.data.text);	
		
	}else if(_msg.data.type == 2){//机器人消息
		GameData.isService = true; 
		//GameUI.playTextVoice(_msg.data.text);
		//GameUI.ShowChat(Logic.ChangeToStatus(C_Player.seat,_msg.data.seat),_msg.data.text);
		GameUI.addCommunion(Logic.ChangeToStatus(C_Player.seat,_msg.data.seat),1,_msg.data.text,0,_msg.data.info);
	}else if(_msg.data.type == 3){
		var idx = Number(_msg.data.text);
		_msg.data.text = Game_Config.Info.TextContent[(idx - 1)%Game_Config.Info.TextContent.length];
		GameUI.playTextVoice(_msg.data.text);
		GameUI.ShowChat(Logic.ChangeToStatus(C_Player.seat,_msg.data.seat),_msg.data.text);
		GameUI.addCommunion(Logic.ChangeToStatus(C_Player.seat,_msg.data.seat),1,_msg.data.text,0);
	}
}

Desk.Start=function(){//开始按钮
	
}
Desk.get_player_task=function(_msg){//接收任务列表 
	TaskInfo=_msg.data.tasks;
	GameUI.OpenTask();
}

Desk.kick_offline=function(_msg){//玩家踢出 
	var s_data={};
	s_data.data = "";
	var flag = 0;
	if(_msg.data){
		if(_msg.data.fromOther){
			flag = 1;
			if(_msg.data.gameid == "G2hw0ubng0zcoI0r4mx3H2yr4GejidwO"){
				flag = 2;
			}
		}
		s_data.data = _msg.data;
	}
	
	s_data.loginList = GameData.loginList;
	s_data.tcpId = GameData.TcpID;
	s_data.tcpState = GameData.isConnected;
	
	Net.submit_error(JSON.stringify(s_data),"收到踢下线包");
	
	GameUI.OpenKick(ConstVal.Kick.text+flag+"#"+ConstVal.Kick.tip);
}
Desk.call_phone=function(_msg){//拨打电话 
	if(C_Player.seat==_msg.data.seat){
		C_Player.onstate=2;
	}
	var pobj=this.GetPlayerBySeat(_msg.data.seat);
	pobj.onstate=2;
	GameUI.SetOnState(_msg.data.seat,2);
	Game_Modify.playerphonestate(_msg.data.seat,1);
}

Desk.hangup_phone=function(_msg){//挂断电话 
	if(C_Player.seat==_msg.data.seat){
		C_Player.onstate=0;
	}
	var pobj=this.GetPlayerBySeat(_msg.data.seat);
	pobj.onstate=0;
	GameUI.SetOnState(_msg.data.seat,0);
	Game_Modify.playerphonestate(_msg.data.seat,0);
}

Desk.self_makewar=function(_msg){//主动开战 
	
	Func.stopshake();
	GameData.ShakeID = Game_Config.shakeList.nil;
	if(get_self(218,7,0,0,0)=="房主已经离开，新进入房间的玩家成为新房主，您也可重进房间成为房主"){
		GameUI.CloseTips();
	}
	this.stage=1;
	
	var pobj = Desk.GetPlayerBySeat(0);
	pobj.isprepare = 1;
	pobj = null;
	GameUI.SetIsprepare(0,1);
	GameUI.hideReady();
	C_Player.isprepare = 1;
	if(Desk.needprepare == 1){
		if(C_Player.isprepare == 1){
			C_Player.ChangeExit(0);

		}
	}else{
		C_Player.ChangeExit(0);
	}
	if(Desk.infinite == 1){
		C_Player.ChangeExit(1);
	}
	GameUI.HideStartScene();
	GameUI.hideOwnerNotice();
	if(GameData.iscloseVideo){
		Func.exitRoom();
	}
	Game_Modify.StartWar(_msg); 
}
Desk.makewar=function(_msg){//自动或者他人开战 
	Func.stopshake();
	GameData.ShakeID = Game_Config.shakeList.nil;
	if(get_self(218,7,0,0,0)=="房主已经离开，新进入房间的玩家成为新房主，您也可重进房间成为房主"){
		GameUI.CloseTips();
	}
	this.stage=1;
	
	var pobj = Desk.GetPlayerBySeat(0);
	pobj.isprepare = 1;
	pobj = null;
	GameUI.SetIsprepare(0,1);
	if(0 == C_Player.seat){
		GameUI.hideReady();
		C_Player.isprepare = 1;
	}
	if(Desk.needprepare == 1 && Desk.infinite == 1){
		if(C_Player.isprepare == 1){
			GameUI.hideChangeRoom();
			GameUI.hideReady();
			
		}
	}
	if(Desk.needprepare == 1){
		if(C_Player.isprepare == 1){
			C_Player.ChangeExit(0);
		}
	}else{
		C_Player.ChangeExit(0);
	}
	if(Desk.infinite == 1){
		C_Player.ChangeExit(1);
	}
	if(GameData.iscloseVideo){
		Func.exitRoom();
	}
	GameUI.HideStartScene();
	Game_Modify.StartWar(_msg);

}
Desk.send_gift=function(_msg){//互动动画
	if(!_msg.data.type){ 
		_msg.data.giftid = Number(_msg.data.giftid);
		_msg.data.giftid = (_msg.data.giftid - 1)%4+1;
		GameUI.PlayEffect(_msg.data.sendseat,_msg.data.receiveseat,_msg.data.giftid);
	}else if(_msg.data.type==2){
		GameData.isService = true;
		_msg.data.giftid = Number(_msg.data.giftid);
		_msg.data.giftid = (_msg.data.giftid - 1)%4+1;
		GameUI.addCommunion(Logic.ChangeToStatus(C_Player.seat,_msg.data.sendseat),1,"互动动画"+_msg.data.giftid,0,_msg.data.info);
	}
}

Desk.send_voice=function(_msg){//语音 
	// if(Logic.ChangeToStatus(C_Player.seat,_msg.data.seat)!=0){
		
	// }
	if(!_msg.data.type){
		GameUI.play_voice(_msg.data.voiceurl,1,Logic.ChangeToStatus(C_Player.seat,_msg.data.seat));
		GameUI.addCommunion(Logic.ChangeToStatus(C_Player.seat,_msg.data.seat),2,_msg.data.voiceurl,Number(_msg.data.time).toFixed(1));
	}else if(_msg.data.type == 2){
		GameData.isService = true;
		GameUI.addCommunion(Logic.ChangeToStatus(C_Player.seat,_msg.data.seat),2,_msg.data.voiceurl,Number(_msg.data.time).toFixed(1),_msg.data.info);
	}
	
}
Desk.send_phiz = function(_msg){//表情 
	if(!_msg.data.type){
		_msg.data.text = Number(_msg.data.text);
		_msg.data.text = (_msg.data.text - 1)%ConstVal.Emotion.src_list.length+1;
		GameUI.ShowEmotion(Logic.ChangeToStatus(C_Player.seat,_msg.data.seat),_msg.data.text);
	}else if(_msg.data.type == 2){
		GameData.isService = true;
		_msg.data.text = Number(_msg.data.text);
		_msg.data.text = (_msg.data.text - 1)%ConstVal.Emotion.src_list.length+1;
		//GameUI.ShowEmotion(Logic.ChangeToStatus(C_Player.seat,_msg.data.seat),_msg.data.text);
		GameUI.addCommunion(Logic.ChangeToStatus(C_Player.seat,_msg.data.seat),1,"表情"+_msg.data.text,0,_msg.data.info);	
	}
	
}
Desk.submit_opinion = function(_msg){
	if(_msg.data.state==0){//反馈成功 
		set_self(551,7,"",0,0);
		GameUI.OpenTips("已收到您的宝贵意见，我们将尽快处理",ConstVal.Tips.time);
	}else{
		GameUI.OpenTips("啊哦~网络有点小状况，您的反馈意见没能收到",ConstVal.Tips.time);
	}
}
Desk.kick_server = function(_msg){
	GameData.isKick = true;	
	GameUI.OpenKick(_msg.data.msg);
}
Desk.broadcast = function(_msg){
	var type=0;
	if(typeof(_msg.data.msgtype) != "undefined"){
		type = _msg.data.msgtype;
	}
	switch(type){
		case 0:
			GameUI.ShowiMessage(_msg.data.msgcontent);
			break;
		case 1:
			GameUI.addBroadcast(_msg.data.msgcontent);
			break;
	}
}
Desk.player_prepare = function(_msg){
	var pobj = Desk.GetPlayerBySeat(_msg.data.seat);
	pobj.isprepare = 1;
	pobj = null;
	GameUI.SetIsprepare(_msg.data.seat,1);
	if(_msg.data.seat == C_Player.seat){
		GameUI.hideReady();
		C_Player.isprepare = 1;
	}
	GameUI.showStartButton();
	Game_Modify.onReady(_msg.data.seat); 
	if(_msg.data.deskwar){
		GameUI.HideStartScene();
		Desk.stage=1;	
		C_Player.ChangeExit(0);
		Game_Modify.StartWar(_msg);
	}else{

	}
	if(Desk.infinite == 1){
		C_Player.ChangeExit(1);
	}
	if(Desk.stage == 1 && Desk.GetPlayerBySeat(C_Player.seat).isprepare){
		Utl.closeMainSceneButton();
	}	
}
Desk.share_room = function(_msg){
	GameUI.OpenTips("已成功分享至平台！如服务器维护，请重新分享",ConstVal.Tips.time);
}

Desk.get_share_room = function(_msg){
	if(Game_Config.sysConfig){
		if(Game_Config.sysConfig.shareRoom){
			if(Game_Modify.getShareRoom){
				Game_Modify.getShareRoom(_msg);
				return;
			}
		}
	}
	GameData.isShowWorldRoomList = false;
	GameUI.CloseBoard();
	//GameUI.closeWorldRoom();
	GameUI.removeWorldRoom1();
	GameUI.removeWorldRoom2();
	GameUI.setWorldRoom(_msg.data);
	GameUI.openWorldRoom();
}
Desk.show_message = function(_msg){
	GameUI.OpenTips(_msg.data.msg,Number(_msg.data.time));
}
Desk.advanced_roomlist = function(_msg){
	GameData.snrRoomList = _msg.data;
	GameUI.openSeniorOptions(GameData.snrOptionMode,GameData.snrOptionRoomtype,GameData.snrOptionDes,GameData.snrOptionProfit);
}
Desk.advanced_createroom = function(_msg){
	var s_code = GameData.snrRoomList.shortcode;
	GameData.snrRoomList = _msg.data;
	GameData.snrRoomList.shortcode = s_code;
	Logic.addVipRoom(s_code,true);
	GameUI.closeSeniorOptions();
	Game_Modify.CloseCreateRoom();
	//GameUI.OpenTips("创建成功!当前有玩家进入的房间需解散后生效!",ConstVal.Tips.time);
	GameData.snrOptionProfit = _msg.data.tea
	var data = {}
	data.agentid = GameData.AgentId;
	data.gameid = GameData.GameId;
	data.playerid = C_Player.playerid;
	Net.Send_advanced_roomlist(data);
	if(GameData.snrRoomList.rebateLimit){
		Utl.SaveData(Utl.Config.rebateLimit,GameData.snrRoomList.rebateLimit);
	}else{
		Utl.SaveData(Utl.Config.rebateLimit,0);
	}
	//GameUI.openSeniorOptions(GameData.snrOptionMode,GameData.snrOptionRoomtype,GameData.snrOptionDes,GameData.snrOptionProfit);
}
Desk.update_bean = function(_msg){
	if(typeof _msg.data.change == "undefined"){
		if(typeof _msg.data.seat == "undefined"){//自己充值包括大厅 
			C_Player.update_bean(_msg);
		}else{//房间内他人充值 
			var pobj = Desk.GetPlayerBySeat(_msg.data.seat);
			pobj.bean = _msg.data.bean;
			pobj = null;
			if(_msg.data.seat == GameData.infoSeat){
				set_self(511,7,GameData.starName+"："+_msg.data.bean,0,0);
			}
		}
		if(_msg.data.type == 6){
			Logic.playCoinMp3();
		}
		
	}else{
		if(GameData.hallConfig.androidPay){
			GameUI.openUpdateBean("成功购买"+GameData.starName+":"+_msg.data.change);
		}
	}
}
Desk.get_treasurelist = function(_msg){
	//console.log(_msg);
	GameData.rankList = _msg.data.list;
	GameUI.openRankList();
}
Desk.set_bankpwd = function(_msg){
	if(_msg.data.state == 0){
		C_Player.setBankPwd(1);
		//GameUI.OpenTips("密码为:"+_msg.data.password+" 请您牢记",ConstVal.Tips.time);
		GameUI.closeWareHouse();
	}
	if(_msg.data.showerror==1){
		GameUI.OpenTips(_msg.data.error,ConstVal.Tips.time);
	}
}
Desk.change_star = function(_msg){
	if(_msg.data.state==0){
		//var tText = "成功！数量:"+_msg.data.count;
		//if(_msg.data.mode == 0){
			//tText = "存入"+tText;	
		//}else if(_msg.data.mode == 1){
			//tText = "取出"+tText;
		//}
		//GameUI.OpenTips(tText,ConstVal.Tips.time);
		C_Player.update_bean2(_msg.data.star1); 
		C_Player.setWareHouseStarCOunt(_msg.data.star2);
		if(_msg.data.msg){
			GameUI.OpenTips(_msg.data.msg,ConstVal.Tips.time);
			GameData.wareHouse.safeInputCount = _msg.data.count;
			GameUI.updateWareHouseInput();
		}
	}
	if(_msg.data.showerror==1){
		GameUI.OpenTips(_msg.data.error,ConstVal.Tips.time);
	}
	
}
Desk.update_charm = function(_msg){
	for(var i=0;i<_msg.data.seatlist.length;i++){
		var obj = Desk.GetPlayerBySeat(_msg.data.seatlist[i].seat);
		obj.setCharm(_msg.data.seatlist[i].charm);
		obj=null;
	}
}
Desk.switchRoomList = function(msg){
	if(!msg.data.state){
		GameData.snrRoomList.isClose = msg.data.isClose;
		switch(msg.data.isClose){
			case 1:
				GameUI.OpenTips("房间已被关闭！",ConstVal.Tips.time);
				break;
			case 0:
				GameUI.OpenTips("房间已被打开！",ConstVal.Tips.time);
				break;
		}
		GameUI.updateCloseState();
	}else{
		GameUI.OpenTips(msg.data.error,ConstVal.Tips.time);
	}
	GameUI.updateCloseState();
}
Desk.getInfoByShortCode = function(_msg){
	//console.log(_msg);
	GameUI.setVipRoomListData(_msg.data.roomInfo);
	GameUI.updateVipRoomList();
}
Desk.optBanList = function(msg){
	//console.log(msg);
	if(msg.data.message){
		GameUI.OpenTips(msg.data.message,ConstVal.Tips.time);
	}
	GameUI.closeCheck();
	switch(msg.data.type){
		case 1:
		case 3:
		case 4:
		case 5:
		case 6:
			if(msg.data.banList){
				GameData.blackList.data = msg.data.banList;
				
			}else{
				GameData.blackList.data = [];
			}
			GameUI.openBlackList();
			break;
	}
}
Desk.getShortCodeRankList = function(msg){
	//console.log(msg.data);
	if(!msg.data.error){
		GameData.vipRank.data = msg.data;
		GameUI.openVipRank();
	}else{
		GameUI.OpenTips(msg.data.message,ConstVal.Tips.time);
	}
}

Desk.setAllCharm = function(msg){
	//console.log(msg);
	GameUI.closeCheck();
	Utl.SaveData(Utl.Config.vipCharm,GameData.allCharm);
	GameUI.OpenTips("设置成功！",ConstVal.Tips.time);
}

Desk.getVipRankList = function(msg){
	if(msg.data.list){
		GameData.rankList = msg.data.list;
		GameUI.openRankList(true);
	}
}
Desk.playerBehavior = function(msg){
	console.log(msg);
} 
Desk.binding_phone = function(msg){
	//console.log(msg);
	GameUI.closePhoneBind();
	C_Player.setTel(msg.data.phonenum);
}
Desk.send_phone_checkcode = function(msg){
//	console.log(msg);
}
Desk.send_phone_code_wechat = function(msg){
//	console.log(msg);
}
Desk.setVipForbidSelect = function(msg){
	if(!msg.data.state){
		GameData.snrRoomList.forbidSelect = msg.data.forbidSelect;
		switch(msg.data.forbidSelect){
			case 1:
				GameUI.OpenTips("已开启禁止玩家选桌功能！",ConstVal.Tips.time);
				break;
			case 0:
				GameUI.OpenTips("已关闭禁止玩家选桌功能！",ConstVal.Tips.time);
				break;
		}
		
	}else{
		GameUI.OpenTips(msg.data.error,ConstVal.Tips.time);
	}
	GameUI.updateFobidSelect();
}
Desk.topup_card = function(_msg){
	
}
Desk.query_player2 = function(_msg){
	var avatar = _msg.data.avatar;
	var nickname = _msg.data.nickname;
	var pid = _msg.data.playerid;
	GameData.wareHouse.pImg = avatar;
	GameData.wareHouse.pNickName = nickname;
	GameData.wareHouse.pId = pid;
	if(nickname || avatar){
		GameUI.updateWareHousePlayerInfo();
	}else{
		GameUI.OpenTips("未找到对应玩家！",ConstVal.Tips.time);
	}
}
Desk.giveCoin = function(_msg){
	console.log(_msg);
	if(_msg.data.state==0){
		//C_Player.update_bean2(_msg.data.star1);
		//C_Player.setWareHouseStarCOunt(_msg.data.star2);
		//if(_msg.data.msg){
			//GameUI.OpenTips(_msg.data.msg,ConstVal.Tips.time);
			//GameData.wareHouse.safeInputCount = _msg.data.count;
			//GameUI.updateWareHouseInput();
		//}
		C_Player.setWareHouseStarCOunt(_msg.data.star2);
		GameUI.closeWareHouse();
	}
	if(_msg.data.showerror==1){
		GameUI.OpenTips(_msg.data.error,ConstVal.Tips.time);
	}
}
Desk.optWhiteList = function(msg){
	GameData.whiteList.data = msg.data.whiteList;
	GameUI.openWhiteList();
	
	if(msg.data.message){
		GameUI.OpenTips(msg.data.message,ConstVal.Tips.time);
	}else{
		if(msg.data.mode == 1){
			GameUI.OpenTips("添加/修改成功！",ConstVal.Tips.time);
		}else{
			GameUI.OpenTips("删除成功！",ConstVal.Tips.time);
		}
	}
}
Desk.getPlayerWhiteList = function(msg){
	GameData.whiteList.data = msg.data.whiteList;
	GameUI.openWhiteList();
	
}









