local HjDaer_Base   ={}
local DEF_POKER_SCALE = 0.8
local config = baseLoadLua('LzDaer/LzDaer_Public/LzDaer_Public_Scripts/Lzde_Config')
function HjDaer_M_CreScene(  )	
	Pt_EventMgr:clean()
	-- 创建场景
	HjDaer_Base:CreScene()
end

function HjDaer_Base:CreScene(  )
	self.m_Scene = sys.runScene()
	tips.ClearAllLayer()
	-- 获取自己的信息
	self.m_MyInfo = Pt_GetPlayerInfo()
	self.m_isVideoState=Pt_M_GetIsVideoFun()
	local voice = Pt_GetSoundInfo()
	CCLOG("voice ==",voice)
	sys.playMusic(LzDaer_publicaudioRes.music.game_bg)
	-- if voice == 0 then
	-- 	CCLOG("voice 没有")
	-- 	sys.setMusicVolume(0)
	-- end
	local function onEnter( )
		tips.ClearAllLayer()
		SetIsCanMaxWin(true)
		sys.SetWinToCurrPos()
		Pt_loadGame_PublicRes()
		self:Init()
		self:CreateUI()
		xui.FadeIn(self.m_Scene)
		if self.m_isVideoState  ==false then
		   self:RegisterEventListen() -- 注册监听
		   CCLOG("register is over")
		end
		self:GoOnInfo()  -- 取消消息阻塞
	end
	local function onExit( )
		-- 卸载自己的资源
		HjDaer_unload_M_Res()
		LzDaer_unloadPublicRes()
		Pt_unloadGame_PublicRes()
		self:CallBackFun()
		self:Init()
		LzDaer_EventMgr:clean()
		self:UnRegisterEventListen()
	end
	local function onResize( )
		if sys.platform == "windows" then
			sys.ReSize()
			ReSizeUI()
		end
	end
	local function onNodeEvent(event)
		if "enter" == event then
			onEnter()
		elseif "exit" == event then
			onExit()
		elseif "resize" == event then
			onResize()
		end
	end
	self.m_Scene:registerScriptHandler(onNodeEvent)
end

-- 消息阻塞
function HjDaer_Base:StopInfo()
	CCLOG("消息阻塞")
	if self.m_isVideoState ==false then
	   sys.LockMsg()
	end
end

-- 消息继续
function HjDaer_Base:GoOnInfo()
	CCLOG("消息继续")
	sys.UnlockMsg()
end
---初始化
function HjDaer_Base:Init(  )
	self.DEF_M_POKER_X= 96
	self.DEF_M_POKER_Y = 100
	self.DEF_POKER_COUNT  =19
	self.DEF_POKER_START_Y =376
    self.DEF_POKER_BEGIN_Y =30
	self.DEF_FAPAI_POS    ={
							[1] = {x = sys.center.x,y = 10},
							[2] = {x = sys.width - 10,y = sys.center.y},
							[3] = {x =  10,y = sys.center.y},
						}
	self.DEF_ANI_POS    ={
							[1] = {x = sys.center.x,y = 200},
							[2] = {x = sys.width - 300,y = sys.center.y+140},
							[3] = {x =  300,y = sys.center.y+140},
						}
    self.DEF_CHUPAI_POS={
							[1]={x=sys.center.x-50,y=sys.center.y-20},
							[2]={x=sys.center.x+350,y=sys.center.y-20},
							[3]={x=sys.center.x-430,y=sys.center.y-20},
						}
	self.m_ResiduePaiNum  =0
	self.m_Events_Key         = "LzDaer_Game"             -- 注册事件key
	self.m_BaseNode           = nil                       -- 基础节点
	self.m_PokerNode          = nil                       -- 牌节点
	self.da_pokerNode         = nil
	self.shou_pokernode       = nil
	self.mopai_node           = nil
	self.m_PublicNode         = nil                        --公用节点
	self.m_gameNode           = nil                        -- 游戏节点
	self.m_otherPaiNode       = nil
   
	self.head_node             = nil                         --头像节点
	self.act_node              = nil
	self.m_ResiduePaiSp        = nil
	self.m_juCountLable        = nil
	self.m_huValuebg           =nil
    self.m_tuoshuLabel         =nil
    self.m_chuPaitips          =nil
	self.m_RoomInfo     = {}
	self.m_ShouPaiClassTb = {}
	self.m_PaiDuiTB     = {}
	self.m_MyShouPaiTB  = {}
	self.m_MyShowTB     = {}
	self.m_fanPaiClass  = {}
	self.m_KanShowSpTB    = {}
	self.m_KanTB             = {{},{},{}}
	self.m_KanNodeTB    = {}
    self.m_PutoutShowSpTB    = {}
	self.m_PutoutTB          = {{},{},{}}
	self.m_PutoutNodeTB    = {}
	self.m_RoomState    =0
	self.m_MySeat       =1
	self.m_ZhuangZuoWei =1

	self.m_GameState    =0
	self.m_canClick     =false
	self.m_isCanChuPai  =false

	self.m_BaoJiaoTb    ={0,0,0}
	self.m_CanMovePai   =false
    ----video
	self.m_VideoTimeNode  =nil
	self.hf_node          =nil

end
function HjDaer_Base:CallBackFun(  )
	
	if self.m_isVideoState  then
        self:DelTimeHunFang()
        self:VideoInit()
	end
	M_public_CleanUpAllDATA()
	LzDaer_M_CleanUpBigBalanceUi()
	LzDaer_M_CallOPerateClean()
	LzDaer_M_CleanAllResultData()
	LzDaer_M_CleanAllTouxiangData()
end
--清除数据
function HjDaer_Base:cleanGameData(  )
	CCLOG("cleanGameData   1")
	for k,v in pairs(self.m_PaiDuiTB ) do
		if v~=nil then 
			v:removeFromParent(true)
		end
	end
	self.da_pokerNode:removeAllChildren(true)
	self.shou_pokernode:removeAllChildren(true)
	self.mopai_node:removeAllChildren(true)
	--self.da_pokerNode:removeAllChildren(true)
	--self.da_pokerNode:removeAllChildren(true)
    self.m_ShouPaiClassTb = {}
	self.m_PaiDuiTB     = {}
	self.m_MyShouPaiTB  = {}
	self.m_MyShowTB     = {}
	self.m_fanPaiClass  = {}
	self.m_KanShowSpTB       = {}
	self.m_KanTB             = {{},{},{}}
	self.m_KanNodeTB         = {}
    self.m_PutoutShowSpTB    = {}
	self.m_PutoutTB          = {{},{},{}}
	self.m_PutoutNodeTB      = {}
	self.m_BaoJiaoTb         ={0,0,0}

	self.m_ZhuangZuoWei =1
	--self.m_GameState    =emDaEr_GameState_FaPai
	self.m_canClick     =false
	self.m_isCanChuPai  =false
	self.m_CanMovePai   =false
	CCLOG("cleanGameData2")
	self.m_ResiduePaiNum  =0
	self:UpdateResiduePai()


end
function Daer_ChangeDesk()
    local deskRes = string.format('LzDaer/LzDaer_Res/LzDaer_MobileRes/PicRes/SingleRes/lzde_bj_%d.jpg',config:loadDesk())
    UIHelper:loadTexture(HjDaer_Base.deskSkin,deskRes,UIHelper.TextureType._Local)
    local screenSize = CCDirector:getInstance():getWinSize()
    if(screenSize.width / screenSize.height > 1334 / 750)then
        HjDaer_Base.deskSkin:setScaleX((screenSize.width / screenSize.height) / (1334 / 750))
    end
end
--创建ui
function HjDaer_Base:CreateUI( )
	self.m_BaseNode=xui.addNode( self.m_Scene )

	self.m_PublicNode=xui.addNode(self.m_Scene)
	self.m_PublicNode:setLocalZOrder(20)
	-- 公告
	if  self.m_isVideoState ==false then 
		 CreWorldGonggaoUI( self.m_Scene )
	end
	-- 公共按钮
	local M_GameBtn = M_public_CreMenu( self.m_Scene,
		function()
			self:UnRegisterEventListen()
	end,emGame_HeJiangDaEr,self.m_PublicNode )
    if self.M_GameBtn.setbtn then
        self.M_GameBtn.setbtn.SetMyBtnVisible(false)
    end
    Daer_P_CreSetUI( self.m_Scene,self.M_GameBtn)
	CCLOG("CreateUI")
	--创建背景
	local deskRes = string.format('LzDaer/LzDaer_Res/LzDaer_MobileRes/PicRes/SingleRes/lzde_bj_%d.jpg',config:loadDesk())
    self.deskSkin = UIHelper:createImageView(self.m_BaseNode,deskRes,cc.p(sys.center.x,sys.center.y - 30),nil,nil,UIHelper.TextureType._Local)

    local screenSize = CCDirector:getInstance():getWinSize()
    if(screenSize.width / screenSize.height > 1334 / 750)then
        self.deskSkin:setScaleX((screenSize.width / screenSize.height) / (1334 / 750))
    end

	--分数Bg
	local   m_BeiShuBg = xui.addSprite(self.m_BaseNode,"lzde_fanshu_bg",sys.center.x,sys.height,sys.ap.centerTop)
	local sizelable = 24
	local add_x =0
	local miaoshuStr="剩余局数："
	-- if self.m_isVideoState==true then 
	-- 	miaoshuStr="第    局"
	-- 	add_x=-80
	-- end
	local shengLabel =  xui.addLabel(m_BeiShuBg,miaoshuStr , sys.creColor3( 219, 179, 83 ), sizelable,40, m_BeiShuBg:getContentSize().height/2, sys.ap.leftCenter, nil, nil , nil)
	xui.addLabel(m_BeiShuBg, "剩余牌数：", sys.creColor3( 219, 179, 83 ), sizelable,250, m_BeiShuBg:getContentSize().height/2, sys.ap.leftCenter, nil, nil , nil)
	self.m_ResiduePaiSp  =xui.addLabel(m_BeiShuBg,self.m_ResiduePaiNum, sys.creColor3( 219, 179, 83 ),sizelable,370 ,m_BeiShuBg:getContentSize().height/2, sys.ap.leftCenter, nil, nil , nil)
	self.m_juCountLable =xui.addLabel(m_BeiShuBg,0, sys.creColor3( 219, 179, 83 ),sizelable,160+add_x,m_BeiShuBg:getContentSize().height/2, sys.ap.leftCenter, nil, nil , nil)
	self.m_gameNode =xui.addNode( self.m_BaseNode )
	--手牌
	self.da_pokerNode  =xui.addNode( self.m_BaseNode )
	self.shou_pokernode =xui.addNode( self.m_BaseNode )
	self.mopai_node=xui.addNode( self.m_BaseNode )
    self.head_node =xui.addNode( self.m_BaseNode )
    self.act_node =xui.addNode(self.m_BaseNode)
    self.m_otherPaiNode =xui.addNode( self.m_BaseNode )


	self:CreReadyMean()
	self:SetReadyMeanVisible(false,false)
	self:CrehuShu()

    self.m_moveLingSp =xui.addSprite(self.m_BaseNode ,"lzde_mj_cccx",sys.center.x,DEF_MOVE_Y)
    LzDaer_M_moveSpTipsFun(false)

    self.hf_node=xui.addNode( self.m_Scene )
    self.hf_node:setLocalZOrder(100)
    self.m_VideoTimeNode=xui.addNode(self.m_Scene)

    if self.m_isVideoState ==true then
       self:VideoInit()
       self.m_VideoInfo=sys.copyTab(Pt_M_GetVideoInfoFun())
       self:SetReadyMeanVisible( false, false )
       self:cleanGameData()
       
       --回放按钮
       self:CreHuiFangUIfun()
       --回放头像
        local code = Pt_M_GetCodeDate()
        if M_GameBtn.koulingName and M_GameBtn.koulingName:getChildByTag(11) then

            M_GameBtn.koulingName:getChildByTag(11):setString(code.playerdata.deskcode)
        end
        self.m_juCountLable:setVisible(false)
        if self.m_VideoInfo.t then
            shengLabel:setString("第 "..self.m_VideoInfo.t.." 局")
            --self:UpdateJushuFun(self.m_VideoInfo.t)
        end
        if code.playerdata.datetime then
            local TimeSp = xui.addSpr9(self.m_PublicNode,"lzde_sj",300,35,sys.center.x, sys.height-80)
            local TimeLabel = xui.addLabel(self.m_PublicNode, code.playerdata.datetime, sys.colors.white,26, sys.center.x, sys.height-80)
        end
    end
    if 1  then return end
	local  WeiXinYaoQingBtn=MyBtnClass:new("lzde_btn_yqhy_zc","lzde_btn_yqhy_dj","lzde_btn_yqhy_zc",function ( )
		--  self:Test_YbYdr1()
         --self:SC_DAER_BAOJIAO()
         LzDaer_Public_PlaySound("poker",0,12)
	end)
	WeiXinYaoQingBtn.btnLy:setPosition(-100,sys.center.y-100)
	self.m_BaseNode:addChild(WeiXinYaoQingBtn.btnLy,10)


    local  WeiXinYaoQingBtn=MyBtnClass:new("lzde_btn_yqhy_zc","lzde_btn_yqhy_dj","lzde_btn_yqhy_zc",function ( )
 	    self:FanYiPai(3,nil,"mopai")
	end)
	WeiXinYaoQingBtn.btnLy:setPosition(-100,sys.center.y)
	self.m_BaseNode:addChild(WeiXinYaoQingBtn.btnLy,10)

   local  WeiXinYaoQingBtn=MyBtnClass:new("lzde_btn_yqhy_zc","lzde_btn_yqhy_dj","lzde_btn_yqhy_zc",function ( )
		self:testjues()
		--self:SC_DAER_MOPAI()
	end)
	WeiXinYaoQingBtn.btnLy:setPosition(-100,sys.center.y+100)
	self.m_BaseNode:addChild(WeiXinYaoQingBtn.btnLy,10)

end
--移动出牌提示
function LzDaer_M_moveSpTipsFun(isShow )
    if HjDaer_Base.m_moveLingSp  then
       HjDaer_Base.m_moveLingSp:setVisible(isShow)
    end
end


--跟新局数
function HjDaer_Base:UpdateJushuFun( jushValue )
	if self.m_juCountLable  then 
		self.m_juCountLable:setString(jushValue)
	end
end
--跟新牌数
function HjDaer_Base:UpdateResiduePai( jushValue )
	if self.m_ResiduePaiSp  then 
		self.m_ResiduePaiSp:setString(self.m_ResiduePaiNum)
	end
end
--更新hu数
function HjDaer_Base:CrehuShu(  )
	self.m_huValuebg = xui.addSprite(self.m_gameNode,"ydr_tuo_bg",0,0)
	self.m_huValuebg:setPosition(sys.width-self.m_huValuebg:getContentSize().width/2,self.m_huValuebg:getContentSize().height/2)
    self.m_tuoshuLabel = xui.addLabel(self.m_huValuebg,"总胡数：".."0".."  胡",sys.colors.white,24,10, self.m_huValuebg:getContentSize().height/2,sys.ap.leftCenter,nil,nil,true)
end
function  HjDaer_Base:UpdateHuValue( huValue)
	if self.m_tuoshuLabel then
       self.m_tuoshuLabel:setString("总胡数："..huValue.."  胡")
	end
end
--设置发牌的第一人
function HjDaer_Base:SetToFirst( firstzuowei )
	local zj_zw = {}
	local tb = {1,2,3}
	local m
	for k,v in pairs(tb) do
		if v == firstzuowei then
			m = k
			break
		end     
	end
	for i=m,sys.getTBCount( tb ) do
		table.insert(zj_zw,tb[i])
	end
	for i=1,m-1 do
		table.insert(zj_zw,tb[i])
	end
	return zj_zw
end
--监听
function HjDaer_Base:RegisterEventListen(  )
	-- 新加入玩家 通知在座的人
	Pt_EventMgr:register( Pt_Events.SC_ROOM_PLAYER_ENTER, self.m_Events_Key, function( key, s )
		self:SC_ROOM_PLAYER_ENTER( key, s )
	end )
	-- 通知刚加入的人 房间信息
	Pt_EventMgr:register( Pt_Events.SC_ROOM_INFO, self.m_Events_Key, function( key, s )
		self:SC_ROOM_INFO( key, s )
	end )
	-- 设置房间状态
	Pt_EventMgr:register( Pt_Events.SC_ROOM_SET_STATE, self.m_Events_Key, function( key, s )
		self:SC_ROOM_SET_STATE( key, s )
	end )
	-- 设置玩家状态
	Pt_EventMgr:register( Pt_Events.XSC_SET_PREPARE, self.m_Events_Key, function( key, s )
		self:XSC_SET_PREPARE( key, s )
	end )
	-- 设置玩家状态
	Pt_EventMgr:register( Pt_Events.SC_ROOM_SET_PLAYER_STATE, self.m_Events_Key, function( key, s )
		self:SC_ROOM_SET_PLAYER_STATE( key, s )
	end )
	-- 玩家离开房间,广播
	Pt_EventMgr:register( Pt_Events.SC_ROOM_PLAYER_QUIT, self.m_Events_Key, function( key, s )
		self:SC_ROOM_PLAYER_QUIT( key, s )
	end )
	-- 房间数据 重连
	Pt_EventMgr:register( Pt_Events.XC_ROOM_INFO, self.m_Events_Key, function( key, s )
		self:XC_ROOM_INFO( key, s )
	end )
	-- 聊天
	Pt_EventMgr:register( Pt_Events.SC_ROOM_CHAT, self.m_Events_Key, function( key, s )
		self:SC_ROOM_CHAT( key, s )
	end )
	-- 游戏中断线重连
	Pt_EventMgr:register( Pt_Events.RECONNECT_INFO, self.m_Events_Key, function( key, s )
		self:RECONNECT_INFO( key, s )
	end )
	-- 重新请求房间数据
	Pt_EventMgr:register( Pt_Events.SC_REQUEST_ROOM, self.m_Events_Key, function( key, s )
		self:SC_REQUEST_ROOM( key, s )
	end )
	-- 广播剩余局数
	Pt_EventMgr:register( Pt_Events.XC_BROADCAST_LAST_TURN, self.m_Events_Key, function( key, s )
		self:XC_BROADCAST_LAST_TURN( key, s )
	end )
    -- 单局结算
    Pt_EventMgr:register( Pt_Events.XC_JIESUAN, self.m_Events_Key, function( key, s )
        self:XC_JIESUAN( key, s )
    end )
    -- 大结算
    Pt_EventMgr:register( Pt_Events.XC_JIESUAN_ALL, self.m_Events_Key, function( key, s )
        self:XC_JIESUAN_ALL( key, s )
    end )
	--------------------------------------------game xc----------------------------------------
	--进入房间
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_ENTER,self.m_Events_Key,function ( key,s )
		self:SC_DAER_ENTER(key,s)
	end)
	--发牌
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_FAPAI,self.m_Events_Key,function ( key,s )
		self:SC_DAER_FAPAI(key,s)
	end)
	--游戏状态改变
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_GAME_STATE,self.m_Events_Key,function ( key,s )
		self:SC_DAER_GAME_STATE(key,s)
	end)
	--翻一张牌
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_FANPAI,self.m_Events_Key,function ( key,s )
		self:SC_DAER_FANPAI(key,s)
	end)
	--摸一张牌
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_MOPAI,self.m_Events_Key,function ( key,s )
		self:SC_DAER_MOPAI(key,s)
	end)
	--当前操作位置
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_NOW_OP_SEAT,self.m_Events_Key,function ( key,s )
		self:SC_DAER_NOW_OP_SEAT(key,s)
	end)
   --通知玩家进行的操作
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_CAN_OPERATE,self.m_Events_Key,function ( key,s )
		self:SC_DAER_CAN_OPERATE(key,s)
	end)
	--通知玩家可以进行保叫
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_CAN_BAOJIAO,self.m_Events_Key,function ( key,s )
		self:SC_DAER_CAN_BAOJIAO(key,s)
	end)
	--保叫结果
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_BAOJIAO,self.m_Events_Key,function ( key,s )
		self:SC_DAER_BAOJIAO(key,s)
	end)
	--通知客户端可以进行拢牌
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_CAN_LONG,self.m_Events_Key,function ( key,s )
		self:SC_DAER_CAN_LONG(key,s)
	end)
	--通知拢牌消息
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_LONG,self.m_Events_Key,function ( key,s )
		self:SC_DAER_LONG(key,s)
	end)
	--吃的结果
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_CHI,self.m_Events_Key,function ( key,s )
		self:SC_DAER_CHI(key,s)
	end)
		--招的结果
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_ZHAO,self.m_Events_Key,function ( key,s )
		self:SC_DAER_ZHAO(key,s)
	end)
		--碰的结果
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_PENG,self.m_Events_Key,function ( key,s )
		self:SC_DAER_PENG(key,s)
	end)
		--胡的结果
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_HU,self.m_Events_Key,function ( key,s )
		self:SC_DAER_HU(key,s)
	end)
    --优先级相关
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_CANCEL_OP,self.m_Events_Key,function ( key,s )
		self:SC_DAER_CANCEL_OP(key,s)
	end)
	--通知客户端出牌
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_NOTICE_CHUPAI,self.m_Events_Key,function ( key,s )
		self:SC_DAER_NOTICE_CHUPAI(key,s)
	end)
    --出
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_CHUPAI,self.m_Events_Key,function ( key,s )
		self:SC_DAER_CHUPAI(key,s)
	end)

	--手牌进入弃牌堆
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_PAIDUI,self.m_Events_Key,function ( key,s )
		self:SC_DAER_PAIDUI(key,s)
	end)

	--是否有操作
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_HAVE_OP,self.m_Events_Key,function ( key,s )
		self:SC_DAER_HAVE_OP(key,s)
	end)

	--胡数
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_HU_NUM,self.m_Events_Key,function ( key,s )
		self:SC_DAER_HU_NUM(key,s)
	end)

	--某人放弃操作
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_QI,self.m_Events_Key,function ( key,s )
		self:SC_DAER_QI(key,s)
	end)
	--某人放弃操作
	LzDaer_EventMgr:register(LzDaer_Events.SC_DAER_SYNC_SP,self.m_Events_Key,function ( key,s )
		self:SC_DAER_SYNC_SP(key,s)
	end)
end
--取消监听
function HjDaer_Base:UnRegisterEventListen(  )
	Pt_EventMgr:unregisterByKey( self.m_Events_Key )
	LzDaer_EventMgr:unregisterByKey( self.m_Events_Key )
end
-- 新加入玩家 通知在座的人
function HjDaer_Base:SC_ROOM_PLAYER_ENTER( key, s )
	LzDaer_M_AddTouXiang(s) --添加麻将玩家头像UI
end
-- 通知刚加入的人 房间信息
function HjDaer_Base:SC_ROOM_INFO( key, s )
	SHOW(s)
	CCLOG("SC_ROOM_INFO----1")
	Pt_EventMgr:fire(Pt_Events.CC_ROOM_SET_STATE,{["roomstate"] = s.roomstate}) --设置公共区房间状态
	tips.removeMaskTips()
	self:UpdateJushuFun(s.deskparam.turn)
	self.m_RoomInfo =s
	for k,v in pairs(s["playerlist"]) do
		if v[Def_Player_PlayerId] == self.m_MyInfo[Def_Player_PlayerId] then
			self.m_MySeat = v["seat"]
			CCLOG("self.MyZuoWeiPos: ",self.m_MySeat)
		end
	end
	self.m_RoomState = s["roomstate"]
	--清除所有头像
	LzDaer_M_CloseTouXiang()
	-- 创建玩家头像
	LzDaer_M_CreTouXiang( self.head_node, s )
	self:SetReadyMeanVisible(false,false)
	CCLOG("SC_ROOM_INFO----2---0")
	for k,v in pairs(s["playerlist"]) do
	    if v["playerstate"] == emPlayerState_Prepare then
			LzDaer_M_UpdateReadyState(v["seat"], 1)
		elseif v["playerstate"]== emPlayerState_UnPrepare then
			LzDaer_M_UpdateReadyState(v["seat"], 2)
		elseif  v["playerstate"]== emPlayerState_Leave then
			LzDaer_M_LeaveLine(v["seat"], true)
		end
	end
	 CCLOG("SC_ROOM_INFO----2")
	if self.m_RoomState == emRoomState_Game then    --游戏中
		 self:SetReadyMeanVisible(false,false)
	elseif self.m_RoomState == emRoomState_Wait or  self.m_RoomState == emRoomState_JSWait then    --创建准备按钮
		CCLOG("SC_ROOM_INFO----3")
		self:SetReadyMeanVisible(true,true)
	else
		self:SetReadyMeanVisible(false,false)
	end
	Pt_M_CreJisTips(s)
	CCLOG("SC_ROOM_INFO----4")
end

-- 设置房间状态
function HjDaer_Base:SC_ROOM_SET_STATE( key, s )
   CCLOG("设置房间状态----1")
   self.m_RoomState=s.roomstate
   if self.m_RoomState == emRoomState_Wait then
		Pt_M_SetGoOutCondition( false )
		self:SetReadyMeanVisible(true,true)
		CCLOG("设置房间状态----2")
	elseif self.m_RoomState == emRoomState_Game then
		 self:SetReadyMeanVisible(false,false)
		 CCLOG("设置房间状态----3")
	elseif self.m_RoomState == emRoomState_JSWait then
		local isJiesuan = LzDaer_M_IsCreUI()
		CCLOG("设置房间状态----3",isJiesuan)
		if isJiesuan==false then
			self:SetReadyMeanVisible(true,true)
		end
	elseif self.m_RoomState == emRoomState_Creating then
		CCLOG("设置房间状态----4")
		self:SetReadyMeanVisible(false,false)
	else
		self:SetReadyMeanVisible(false,false)
	end
	Pt_EventMgr:fire(Pt_Events.CC_ROOM_SET_STATE,{["roomstate"] = s.roomstate}) --设置公共区房间状态
end

---小局中间的准备
function HjDaer_Base:XSC_SET_PREPARE( key,s )
	CCLOG("小局中间的准备")
	local m_TouXiangLayerTB = LzDaer_M_GetTouXiangLayer()
	for k,v in pairs(m_TouXiangLayerTB) do
		if v.playerinfo[Def_Player_PlayerId] == s[Def_Player_PlayerId] then
			if s["prepare"] == emPlayerState_Prepare then
				LzDaer_M_UpdateReadyState(s.seat, 1, self.My_ZuoWei_TB)
			end
		end
	end
	if self.m_MyInfo[Def_Player_PlayerId]== s[Def_Player_PlayerId] then
		self:cleanGameData()
	end
end
-- 设置玩家状态
function HjDaer_Base:SC_ROOM_SET_PLAYER_STATE( key, s )
	CCLOG("设置玩家状态----1")
	local playerseat = 0
	local m_TouXiangLayerTB = LzDaer_M_GetTouXiangLayer()
	for k,v in pairs(m_TouXiangLayerTB  ) do
		if  v.playerinfo and v.playerinfo[Def_Player_PlayerId] == s[Def_Player_PlayerId] then
			playerseat = v.zuowei
			break
		end
	end
	if s["playerstate"] == emPlayerState_Prepare then
		LzDaer_M_UpdateReadyState(playerseat, 1)
		if self.m_MySeat == playerseat then
			self:cleanGameData()
		end
		CCLOG("设置玩家状态----2")
		LzDaer_M_LeaveLine(playerseat, false)
	elseif s["playerstate"] == emPlayerState_UnPrepare then
		LzDaer_M_UpdateReadyState(playerseat, 2)
		CCLOG("设置玩家状态----3")
		LzDaer_M_LeaveLine(playerseat, false)
	elseif s["playerstate"] == emPlayerState_Leave then
	   LzDaer_M_LeaveLine(playerseat, true)
	   CCLOG("设置玩家状态----4")
	elseif s["playerstate"] == emPlayerState_ZanLi then
		LzDaer_M_LeaveLine(playerseat, true)
	else
		LzDaer_M_LeaveLine(playerseat, false)
	end
end

-- 玩家离开房间,广播
function HjDaer_Base:SC_ROOM_PLAYER_QUIT( key, s )
	-- 处理玩家座位头像
	local playerseat = 0
	local m_TouXiangLayerTB = LzDaer_M_GetTouXiangLayer()
	for k,v in pairs(m_TouXiangLayerTB) do
		if v.playerinfo[Def_Player_PlayerId] == s[Def_Player_PlayerId] then
			playerseat = v.zuowei
			break
		end
	end
	CCLOG("SC_ROOM_PLAYER_QUIT---1")
	LzDaer_M_SubTouXiang(playerseat)
end
-- 判断是否是观看者 然后做相应重连
function HjDaer_Base:XC_ROOM_INFO( key, s )
	CCLOG("重连-----1")
	--self:StopInfo()
	self.m_GameState=s.state
	if s.emTurnState  then
	   self.m_emTurnState=s.emTurnState
	end
	local ishaveReady = false
	if s.tablePlayerPrepare  then
		if self.m_emTurnState ==emTurnState_Wait  then
			CCLOG("在游戏准备")
			for k,v in pairs(s.tablePlayerPrepare ) do
				if v.seat  then
					if v.prepare  ==0 then

					else
						LzDaer_M_UpdateReadyState(v["seat"], 1)
						if v["seat"]  ==self.m_MySeat then
							 ishaveReady=true
						 end
					end
				end
			end
		else
			CCLOG("在游戏中")
		end
	end
	self:cleanGameData()
	 CCLOG("重连-----11")
	if  s.nLastTurnNum  then
		-- self.juCount=s.nLastTurnNum
		 CCLOG("xc 剩余局数",s.nLastTurnNum)
		self:UpdateJushuFun(s.nLastTurnNum)
	end
    CCLOG("重连-----111")
	if ishaveReady  then CCLOG("ishaveReady is true") self:GoOnInfo() return end
	CCLOG("重连-----2")
    self.m_ResiduePaiNum=s.leftpai
    self:UpdateResiduePai()
    CCLOG("重连-----3")
    for i=1,self.m_ResiduePaiNum do
    	self.m_PaiDuiTB[i] =  xui.addSprite(self.m_gameNode,"lzde_zjpd",sys.center.x,sys.center.y+140+i*2,5)
    end
    CCLOG("重连-----4")
	CCLOG("self.m_GameState",self.m_GameState)
	local daseat = LzDaer_M_GetPointZuoWei(s.seat)+1
	for k,v in pairs(s.playerdata) do
		CCLOG("重连-----5--",k)
		local temp_zw =LzDaer_M_GetPointZuoWei(k)+1
		if temp_zw ==1 then 
		   self.m_MyShouPaiTB=v.shoupai
		   CCLOG("发自己的牌1",self.m_MyShouPaiTB)
           
           CCLOG("发自己的牌1")
           if v.hu_num  and v.hu_num>0 then
           	 self:UpdateHuValue(v.hu_num)
           end
        else
        	for i=1,#v.shoupai do
        		LzDaer_M_CreateOneSp(k)
        	end	
		end
	    if v.peng  then 
	    	for k1,v1 in pairs(v.peng) do
	    		table.insert(self.m_KanTB[k],{v1,v1,v1,["ty"]="peng"})
	    	end
	    end
	    if v.long  then 
	    	for k1,v1 in pairs(v.long) do
	    		table.insert(self.m_KanTB[k],{v1,v1,v1,["ty"]="long"})
	    	end
	    end
	    if v.zhao  then 
	    	for k1,v1 in pairs(v.zhao) do
	    		table.insert(self.m_KanTB[k],{v1,v1,v1,["ty"]="zhao"})
	    	end
	    end
	    if v.chi  then 
	    	for k1,v1 in pairs(v.chi) do 
	    		--v1.ty="chi"
	    		--SHOW(v1)
	    		--table.insert(v1,["ty"]="chi")
	    		CCLOG("断线吃--")
	    		table.insert(self.m_KanTB[k],{v1.o1,v1.o2,v1.pai,["ty"]="chi"})
	    	end
	    end
	    if v.fei  then 
           self.m_PutoutTB[k]=v.fei
	    end
        if v.baohu  and v.baohu==1 then
            LzDaer_M_CreBaojiaoSp(k,1)
            self.m_BaoJiaoTb[k]=1
        end
	end
	CCLOG("self.m_KanTB")
    SHOW(self.m_KanTB)
    for i=1,3 do
    	self:UpdateKan(i,"duanxian")
    	self:UpdatePutount(i,"duanxian")	
    end
	self:ZhanKaiMyShouPai()


	if s.currpai  and s.currpai>0 then
		-- local offx,offy = sys.center.x,sys.center.y
		-- if daseat  ==1  then
  --          offx= sys.center.x-50
  --          offy= sys.center.y -40
		-- end
		-- if daseat == 2 then
  --           offx= sys.center.x+350
  --           offy= sys.center.y -40
		-- end
		-- if daseat== 3 then
  --           offx= sys.center.x-430
  --           offy= sys.center.y -40
		-- end
       	self.m_fanPaiClass = DaerPokerClass:Create(self.mopai_node,s.currpai,"bottom","shou")
		self.m_fanPaiClass.m_player:setScale(DEF_POKER_SCALE)
		self.m_fanPaiClass.m_player:setPosition(self.DEF_CHUPAI_POS[daseat].x,self.DEF_CHUPAI_POS[daseat].y)
	end
    if s.zhuang  then
    	self.m_ZhuangZuoWei =s.zhuang
		local m_TouXiangLayerTB = LzDaer_M_GetTouXiangLayer()
	    if m_TouXiangLayerTB[self.m_ZhuangZuoWei].ZhuangSp then 
	       m_TouXiangLayerTB[self.m_ZhuangZuoWei].ZhuangSp:setVisible(true)
	    end
    end
	self:GoOnInfo()
end

-- 聊天
function HjDaer_Base:SC_ROOM_CHAT( key, s )
	CCLOG("SC_ROOM_CHAT")
	if self.m_isVideoState then return end
	local m_TouXiangLayerTB = LzDaer_M_GetTouXiangLayer()
	for k,v in pairs(m_TouXiangLayerTB) do
		if v.playerinfo[Def_Player_PlayerId] == s[Def_Player_PlayerId] then
			local temp_zw =LzDaer_M_GetPointZuoWei(k)+1
			local off_y = 0
			if s["str"] then
				v:ShowTalkPop(s["str"],nil,nil,nil,nil,nil,-90)
				PT_AddOneMsgex(v.playerinfo[Def_Player_NickName],nil,s["str"])
			end 
			if s["kuaijieID"] then
				local label = Pt_PlayKuaiJieLaioTianSound(s["kuaijieID"],v.xingbie)
				v:ShowTalkPop(label,nil,nil,nil,nil,nil,-90)
				PT_AddOneMsgex(v.playerinfo[Def_Player_NickName],nil,label)
			end 
			if s["resID"] then
				if temp_zw==2 then 
				   off_y=-20
				end
				local resname,rescount = PT_PublicGetBiaoQingRes(s["resID"])
				v:ShowTalkPop("",nil,nil,resname,rescount,nil,-145+off_y)
				PT_AddOneMsgex(v.playerinfo[Def_Player_NickName],s["resID"],nil)
			end 
			if s["headBiaoQing"]  then
				CCLOG("头像表情",k)
				if s["sendseat"] then
					local sendTosea=s["sendseat"]
					if m_TouXiangLayerTB[sendTosea]  then
						CCLOG("头像表情",sendTosea)
						local sendPos={}
						sendPos.x,sendPos.y =m_TouXiangLayerTB[sendTosea]:getPosition()
						--SHOW(sendPos)
						v:PlayHeadBiaoQing(s["headBiaoQing"],sendPos)
					end
				end
			end
		end
	end
end
-- 游戏中断线重连
function HjDaer_Base:RECONNECT_INFO( key, s )
	self:StopInfo()
	self:cleanGameData()
	CreMidScene(SCENE_GAME, emGame_HeJiangDaEr, true)
end
--重新请求房间数据
function HjDaer_Base:SC_REQUEST_ROOM( key, s )
	-- self:StopInfo()
	-- self:cleanGameData()
	-- CreMidScene(SCENE_GAME, emGame_HeJiangDaEr, true)
end

--局数
function HjDaer_Base:XC_BROADCAST_LAST_TURN( key,s )
	SHOW(s)
	if  s.lastturn  then
		--self.m_juCount=s.lastturn
		--CCLOG("xc 剩余局数",self.m_juCount)
		self:UpdateJushuFun(s.lastturn)
	end
end
--创建准备按钮
function HjDaer_Base:CreReadyMean()
	self.m_WeiXinYaoQingBtn=MyBtnClass:new("lzde_btn_yqhy_zc","lzde_btn_yqhy_dj","lzde_btn_yqhy_zc",function ( )
		self:WeiXinYaoQingFriend()
	end)
	self.m_WeiXinYaoQingBtn.btnLy:setPosition(sys.center.x-267-35,sys.center.y-100)
	self.m_BaseNode:addChild(self.m_WeiXinYaoQingBtn.btnLy,10)

	self.m_JieSuanRoomBtn=MyBtnClass:new("lzde_btn_jsfj_zc","lzde_btn_jsfj_dj","lzde_btn_jsfj_zc",function (  )
		Pt_M_PushbackFun()
	end)
	self.m_JieSuanRoomBtn.btnLy:setPosition(sys.center.x+65 ,sys.center.y-100)
	self.m_BaseNode:addChild(self.m_JieSuanRoomBtn.btnLy,10)
end
--邀请好友
function HjDaer_Base:WeiXinYaoQingFriend(  )
	CCLOG("Push 邀请好友--1")
	local url =GM_YAOQING_lINK_URL
	local title =GM_YAOQING_lINK_NAME
	local content =self:GetTitleStr()
	local flag = 0
	CCLOG(url,title,content,flag)
	sys.setInvateFlag(1)
	sys.sendUrlToWX(url,title,content,flag)
	CCLOG("Push 邀请好友--2")
end
--得到title
function HjDaer_Base:GetTitleStr(  )
	local titlestr =""
	local fangjianHao ="口令:"..self.m_RoomInfo.deskcode..","
	local gameName   = ""
	if self.m_RoomInfo.deskparam.cname then
       gameName=self.m_RoomInfo.deskparam.cname.."," 
	end
	local jushu      =self.m_RoomInfo.deskparam.turn.."局,"
	local guize      =""
	if self.m_RoomInfo.deskparam.type then
       guize=self.m_RoomInfo.deskparam.type.name..","
	end
	if self.m_RoomInfo.deskparam.rule  then
		for k,v in pairs(self.m_RoomInfo.deskparam.rule) do
			if v.name then
				guize=guize..v.name..","
			end
		end
	end
	if  self.m_RoomInfo.deskparam.multi ~=0 then
		guize=guize.."最大"..self.m_RoomInfo.deskparam.multi.."颗,"
	else
		guize=guize.."不限颗,"
	end
	if self.m_RoomInfo.costtype ==emRoomCostType_Win then
		guize=guize.."大赢家付,"
	else
		guize=guize.."房主付,"
	end
	local houzhuiStr ="速度加入【合江大贰】"
	titlestr=fangjianHao..gameName..guize..jushu..houzhuiStr
	CCLOG("titlestr",titlestr)
	return titlestr
end

function HjDaer_Base:SetReadyMeanVisible( zb_visible,qxzb_visible )
	CCLOG("准备按钮状态",zb_visible,"取消准备状态",qxzb_visible)
	--审核 iOS
	if CHECK_VER_FLAG_CONTROL ~=nil then 
		CCLOG("CHECK_VER_FLAG_CONTROL ~=nil")   
		if self.m_WeiXinYaoQingBtn  then
			self.m_WeiXinYaoQingBtn.SetMyBtnVisible(false)
		end
		if self.m_JieSuanRoomBtn then
			self.m_JieSuanRoomBtn.SetMyBtnVisible(false)
		end
		return 
	end
	if self.m_WeiXinYaoQingBtn  then
		self.m_WeiXinYaoQingBtn.SetMyBtnVisible(zb_visible)
	end
	if self.m_JieSuanRoomBtn then
		self.m_JieSuanRoomBtn.SetMyBtnVisible(qxzb_visible)
	end
	if Pt_M_GetMyselfIsFangZhu() then
		if self.m_WeiXinYaoQingBtn  then
			 self.m_WeiXinYaoQingBtn.btnLy:setPosition(sys.center.x-267-35,sys.center.y-100)
		end
		if self.m_JieSuanRoomBtn  then
			self.m_JieSuanRoomBtn.btnLy:setPosition(sys.center.x+65 ,sys.center.y-100)
		end
	else
		if self.m_WeiXinYaoQingBtn  then
			self.m_WeiXinYaoQingBtn.btnLy:setPosition(sys.center.x-120,sys.center.y-100)
		end
		if self.m_JieSuanRoomBtn  then
			self.m_JieSuanRoomBtn.SetMyBtnVisible(false)
		end
	end
	CCLOG("SetReadyMeanVisible")
end
--小结算
function HjDaer_Base:XC_JIESUAN(key,s)
	SHOW(s)
	CCLOG("XC_JIESUAN-----1")
	self:StopInfo()
	LzDaer_M_DelAllTime()
    LzDaer_M_DelOperateUI()
    local ishu =false 
    local zuowei = 1
    local time = 2
    local hutype = 0
    local m_TouXiangLayerTB = LzDaer_M_GetTouXiangLayer()
    for k,v in pairs(s.jiesuan.plr_data) do
    	if v~=nil then 
            if v.ishu and v.ishu ==1 then
                zuowei=k
                ishu=true
                hutype=v.hu_type or 0
            end
    	end
    end
    if ishu  then
    	CCLOG("XC_JIESUAN-----2",hutype)
    	if hutype==1 then
           LzDaer_Public_PlaySound("zimo",m_TouXiangLayerTB[zuowei].xingbie)
        elseif hutype ==2 then
            LzDaer_Public_PlaySound("hu",m_TouXiangLayerTB[zuowei].xingbie)
        elseif hutype ==3 then
            LzDaer_Public_PlaySound("baile",m_TouXiangLayerTB[zuowei].xingbie)
        end
	   	local operate = LzDaer_M_GetPointZuoWei(zuowei)+1
	    LzDaerAniamtions.HuAni(self.act_node,self.DEF_ANI_POS[operate].x,self.DEF_ANI_POS[operate].y,function (  )
	    	-- LzDaer_M_HuSp(zuowei)
	     --   	LzDaer_M_CreResultUI(self.m_BaseNode,self.m_Scene,s)
	     --   	self:GoOnInfo()
	    end)
	    time=1.2
	else
		CCLOG("XC_JIESUAN-----3")
        LzDaerAniamtions.LiuJuAni(self.act_node,"mj_liuju",sys.center.x,sys.center.y)
        time = 1.2
	end
	local array={}
	array[1]=cc.DelayTime:create(time)
	array[2]=cc.CallFunc:create(function ( ... )
		LzDaer_M_HuSp(zuowei)
       	LzDaer_M_CreResultUI(self.m_BaseNode,self.m_Scene,s)
       	self:GoOnInfo()
	end)
	self.m_BaseNode:runAction(cc.Sequence:create(array))
    
end
--进入房间
function HjDaer_Base:XC_JIESUAN_ALL(key,s)
	SHOW(s)
	CCLOG("XC_JIESUAN_ALL")
    self:SetReadyMeanVisible( true, true )
    Pt_M_GameJieSanTips()
    Pt_M_ShowBackBtn(true)
    LzDaer_M_DelAllTime()
    LzDaer_M_DelOperateUI()
	LzDaer_M_CreateBigBlanceUI(self.m_Scene,s)
end
--进入房间
function HjDaer_Base:SC_DAER_ENTER(key,s)
	SHOW(s)
	CCLOG("SC_DAER_ENTER")
end
--发牌
function HjDaer_Base:SC_DAER_FAPAI(key,s)
	SHOW(s)
	CCLOG("SC_DAER_FAPAI")
	self:StopInfo()
	self.m_canClick=false
	self.m_ZhuangZuoWei =s.zhuang
	local m_TouXiangLayerTB = LzDaer_M_GetTouXiangLayer()
    if m_TouXiangLayerTB[self.m_ZhuangZuoWei].ZhuangSp then 
       m_TouXiangLayerTB[self.m_ZhuangZuoWei].ZhuangSp:setVisible(true)
    end
    CCLOG("庄家----",self.m_ZhuangZuoWei)
    LzDaer_Public_ActionSound("xipai")
	local xipai = xui.playAniTime( self.mopai_node,"ydr_xp", 12, 0.15,sys.center.x+70,sys.center.y+110,2)
	local arr = {}
	arr[1]=cc.DelayTime:create(12*0.15)
	arr[2]=cc.CallFunc:create(function (  )
		 LzDaer_Public_ActionSound("xipai")
	end)
	self.m_BaseNode:runAction(cc.Sequence:create(arr))
	for i=1,self.DEF_POKER_COUNT do
		local array = {}
		array[1] = cc.DelayTime:create(1.8*2)
		array[2] = cc.CallFunc:create(function (  )
			self.m_PaiDuiTB[i] =  xui.addSprite(self.m_gameNode,"lzde_zjpd",sys.center.x,sys.center.y+140+i*2,5)       
		end)
		if i == self.DEF_POKER_COUNT then
			array[3] = cc.CallFunc:create(function (  )
				self.m_ResiduePaiNum= 80
				self:UpdateResiduePai()
               -- if self.m_isVideoState ==false then
				   self:BeginFaPaiFun(s)
				--else
                    --self:Video_BeFaPai()
				--end
			end)
		end 
		self.m_BaseNode:runAction(cc.Sequence:create(array))
	end
end

--开始发牌
function HjDaer_Base:BeginFaPaiFun( s)
	CCLOG("开始发牌")
	local firstTB = self:SetToFirst( self.m_ZhuangZuoWei)
	self.m_MyShouPaiTB=s.shoupai
	local PaiCount = sys.getTBCount(self.m_MyShouPaiTB)
	local tim = 0.1
	for i=1,20 do
		for j=1,3 do
			tim = tim + 0.05
			local array = {}
			array[1] = cc.DelayTime:create(tim)
			array[2] = cc.CallFunc:create(function (  )
			    if self.m_isVideoState ==false then     
				    self:FaOnePai(firstTB[j],s.shoupai[i],i)
				else
					local zuowei=firstTB[j]
					self:FaOnePai(zuowei,self.m_videoShoPaiTb[zuowei][i],i)
				end
				self.m_ResiduePaiNum = self.m_ResiduePaiNum - 1 
				if self.m_ResiduePaiNum < 0 then
					self.m_ResiduePaiNum = 0
				end 
				self:UpdateResiduePai()
			end)
			if i == 20 and j == 3 then
			 --    if self.m_ZhuangZuoWei ==self.m_MySeat then
			 --        CCLOG("发21张牌自己庄家")
				--  	array[3]=cc.DelayTime:create(0.05)
	   --              array[4] = cc.CallFunc:create(function (  )	  
	   --                  if self.m_isVideoState ==false then    
				-- 		    self:FaOnePai(self.m_ZhuangZuoWei,s.shoupai[21],21)	
				-- 	    else
    --                          local zuowei=self.m_ZhuangZuoWei
				-- 	         self:FaOnePai(zuowei,self.m_videoShoPaiTb[zuowei][21],21)
				-- 	    end	
				-- 		self.m_ResiduePaiNum = self.m_ResiduePaiNum - 1 
				-- 		if self.m_ResiduePaiNum < 0 then
				-- 			self.m_ResiduePaiNum = 0
				-- 		end 
				-- 		self:UpdateResiduePai()
				-- 	end)
				-- 	array[5] = cc.CallFunc:create(function (  )
				-- 		self:FaPaiEnd()
				-- 	end)
				-- else
				-- 	CCLOG("发21张牌其他庄家")
    --                 array[3]=cc.DelayTime:create(0.05)
    --                 array[4] = cc.CallFunc:create(function (  )	
    --                     if self.m_isVideoState ==false then      
				-- 		   self:FaOnePai(self.m_ZhuangZuoWei,nil,21)
				-- 		else
				-- 			local zuowei=self.m_ZhuangZuoWei
				-- 	        self:FaOnePai(zuowei,self.m_videoShoPaiTb[zuowei][21],21)
				-- 		end	
				-- 		self.m_ResiduePaiNum = self.m_ResiduePaiNum - 1 
				-- 		if self.m_ResiduePaiNum < 0 then
				-- 			self.m_ResiduePaiNum = 0
				-- 		end 
				-- 		self:UpdateResiduePai()
				-- 	end)
				-- 	array[5] = cc.CallFunc:create(function (  )
				-- 		if self.m_isVideoState ==false then 
				-- 		    self:FaPaiEnd()
				-- 		else
				-- 			--self.m_MyShouPaiTB={}
				-- 			--self.m_MyShouPaiTB=self.m_videoShoPaiTb[self.m_MySeat]
				-- 			self:FaPaiEnd()
				-- 		end
				-- 	end)
				-- end
				    array[3] = cc.DelayTime:create(0.05)
					array[4] = cc.CallFunc:create(function (  )
						self:FaPaiEnd()
					end)
			end
			self.m_BaseNode:runAction(cc.Sequence:create(array))
		end
	end
end
--发一张牌
function HjDaer_Base:FaOnePai( zuowei,value,count)    
    local time = 0.1
    CCLOG("发一张牌",zuowei,value,count)
    local  mycPos=LzDaer_M_GetPointZuoWei(zuowei)+1
    LzDaer_Public_ActionSound("fapai")
	local changpaiSp = xui.addSprite(self.m_BaseNode,"lzde_zjpd",sys.center.x,sys.center.y+110+sys.getTBCount( self.m_PaiDuiTB )*2)
	changpaiSp:setScale(1.1)
	local array ={}
	array[1] = cc.Spawn:create(cc.MoveTo:create(time,{x=self.DEF_FAPAI_POS[mycPos].x,y=self.DEF_FAPAI_POS[mycPos].y}),cc.FadeOut:create(time),cc.ScaleTo:create(time,0.01))
	array[2] = cc.CallFunc:create(function (  )
		changpaiSp:removeFromParent()
	end)
	changpaiSp:runAction(cc.Sequence:create(array))
	if zuowei == self.m_MySeat then
		if count/3 > sys.getTBCount(self.m_MyShowTB) then
			self.m_MyShowTB[sys.getTBCount(self.m_MyShowTB)+1] = {}
		end 
		CCLOG("m_MyShowTB---------",sys.getTBCount(self.m_MyShowTB))
		table.insert(self.m_MyShowTB[sys.getTBCount(self.m_MyShowTB)],{["daer_value"]=value,["m_used"]=false})
		self:TrimGangfapai()
		--SHOW(self.m_MyShowTB)
	else
		if self.m_isVideoState ==false then      
			if count==21 then 
			   CCLOG("自己的角度讲") 
			   if zuowei==self.m_ZhuangZuoWei then 
				   LzDaer_M_CreateOneSp(zuowei)
				   return 
				end
			end
			LzDaer_M_CreateOneSp(zuowei)
		else
             self:CreOtherPoker(zuowei,count)
		end
	end 
	CCLOG("发一张牌------2") 
end
--组合发牌
function HjDaer_Base:TrimGangfapai( )
	if self.shou_pokernode then 
	   self.shou_pokernode:removeAllChildren(true)
	end
	--CCLOG("TrimGangfapai")
	self.m_ShouPaiClassTb={}
	local paitbCount = #self.m_MyShowTB
	for k1,v1 in pairs(self.m_MyShowTB) do
		self.m_ShouPaiClassTb[k1]={}
		for k2,v2 in pairs(v1) do
			CCLOG("TrimGangfapai",v2.daer_value)
			local off_x = self:getPoker(paitbCount,k1)
			--CCLOG("off_x",off_x)
			local off_y = k2*self.DEF_M_POKER_Y-self.DEF_POKER_START_Y+self.DEF_POKER_BEGIN_Y
			local  pokerClass=DaerPokerClass:Create(self.shou_pokernode,v2.daer_value,"bottom","shou",nil,self.m_canClick)
			pokerClass.m_player:setPosition(off_x,off_y)
			pokerClass.m_player:setLocalZOrder(20-k2)
			pokerClass.m_offx=off_x
			pokerClass.m_offy=off_y
			pokerClass.m_zoerod=20-k2
			pokerClass.weizhi_x  =k1
			pokerClass.weizhi_y  =k2
			table.insert(self.m_ShouPaiClassTb[k1],pokerClass)
		end
	end
	--SHOW(self.m_ShouPaiClassTb)
end
--出一张 摸一张
function HjDaer_Base:ChangeSortPoker( isCanAni)
	CCLOG("ChangeSortPoker1")
	local paitbCount =#self.m_ShouPaiClassTb
	for k1,v1 in pairs(self.m_ShouPaiClassTb) do
		for k2,v2 in pairs(v1) do
			if  type(v2) =="table" and v2.m_player  then 
                local off_x = self:getPoker(paitbCount,k1)
			    local off_y = k2*self.DEF_M_POKER_Y-self.DEF_POKER_START_Y+self.DEF_POKER_BEGIN_Y
			    v2.m_player:setLocalZOrder(20-k2)
				v2.m_offx=off_x
				v2.m_offy=off_y
				v2.m_zoerod=20-k2
				v2.weizhi_x  =k1
				v2.weizhi_y  =k2
			    if  isCanAni then
			    	v2.m_player:setPositionX(off_x)
                    v2.m_player:runAction(cc.Sequence:create(cc.MoveTo:create(0.2,{x=off_x,y=off_y})))
			    else
                    v2.m_player:setPosition(off_x,off_y)
                end
			end
		end
	end
	--SHOW(self.m_ShouPaiClassTb)
	CCLOG("ChangeSortPoker2")
end
function HjDaer_Base:ReSortPokerTb()
	CCLOG("ReSortPokerTb--------1")
	local paiSort = {}
	for k1,v1 in pairs(self.m_ShouPaiClassTb) do
        for k2,v2 in pairs(v1) do
			if  type(v2) =="table" and v2.m_player  then 
                v2.m_used=true
                table.insert(paiSort,v2)
			end
        end
	end
	CCLOG("ReSortPokerTb--------2")
	self.m_ShouPaiClassTb={}
	self.m_ShouPaiClassTb=LzDaer_M_inSortPokerTB(self.m_ShouPaiClassTb)
	self:ChangeSortPoker(false)
	CCLOG("ReSortPokerTb--------3")
end
--发完牌
function HjDaer_Base:FaPaiEnd( )
	CCLOG("FaPaiEnd   1")
	local array = {}
	array[1] = cc.DelayTime:create(1)
	array[2] = cc.CallFunc:create(function (  )
	   self:GoOnInfo()
	   self:ZhanKaiMyShouPai()
	    if self.m_isVideoState ==true then
            self.m_videoStepIndex=self.m_videoStepIndex+1
            self.m_VideoActiom=true
	    end 
	end)
	self.m_BaseNode:runAction(cc.Sequence:create(array))
	CCLOG("FaPaiEnd   2")
	self:ShouLongMyShouPai()

	CCLOG("FaPaiEnd   3")
end
--收拢牌
function HjDaer_Base:ShouLongMyShouPai(  )
	CCLOG("ShouLongMyShouPai")
	--SHOW(self.m_ShouPaiClassTb)
	for k1,v1 in pairs(self.m_ShouPaiClassTb) do
		if type(v1)=="table" then
			for k2,v2 in pairs(v1) do
				if v2.m_player then 
					local array = {}
					array[1] = cc.DelayTime:create(0.2)
					array[2] = cc.MoveTo:create(0.5,{x = sys.center.x-self.DEF_M_POKER_X/2,y = k2*self.DEF_M_POKER_Y-self.DEF_POKER_START_Y+self.DEF_POKER_BEGIN_Y})
					v2.m_player:runAction(cc.Sequence:create(array))
				end
			end
		end
	end
end
--展开首牌
function HjDaer_Base:ZhanKaiMyShouPai(  )
	CCLOG("展开首牌")
	self.m_canClick=true
	self.m_MyShowTB={}
	if self.m_isVideoState then
		self.m_MyShouPaiTB={}
		self.m_MyShouPaiTB= sys.copyTab(self.m_videoShoPaiTb[self.m_MySeat]) 
	end
	SHOW(self.m_MyShouPaiTB)
	self.m_MyShouPaiTB=LzDaer_M_ZuhePokerTb(self.m_MyShouPaiTB)
	self.m_MyShowTB=LzDaer_M_inSortPokerTB( self.m_MyShouPaiTB)
	--SHOW(m_MyShowTB)
	self:TrimGangfapai()
	--SHOW(self.m_MyShouPaiTB)
end
--游戏状态改变
function HjDaer_Base:SC_DAER_GAME_STATE(key,s)
	SHOW(s)
	CCLOG("SC_DAER_GAME_STATE")
	self.m_GameState=s.state  
	if self.m_GameState  ==emDaEr_GameState_FaPai  then 
        CCLOG("发牌中")
        LzDaer_M_DelDingHeadReadSp()
        self:SetReadyMeanVisible(false,false)
	end
	if self.m_GameState  ==emDaEr_GameState_Long  then 
       CCLOG("龙牌")
	end
	if self.m_GameState  ==emDaEr_GameState_BaoJiao  then 
       CCLOG("报叫")
	end
	if self.m_GameState  ==emDaEr_GameState_Gaming  then 
       CCLOG("有戏中")
	end
end

--翻一张牌
function HjDaer_Base:SC_DAER_FANPAI(key,s)
	SHOW(s)
	CCLOG("SC_DAER_FANPAI---1")
	self:StopInfo()
	local zuowei =s.seat  
	local changValue = s.pai  
	LzDaer_Public_ActionSound("qipai")
	local headTb = LzDaer_M_GetTouXiangLayer()
    LzDaer_Public_PlaySound("poker",headTb[zuowei].xingbie,changValue)
	self:FanYiPai(zuowei,changValue,"fanpai",function (  )
		--self:GoOnInfo()
	end)
	self.m_ResiduePaiNum =s.leftpai or 0
	self:UpdateResiduePai()
	for k,v in pairs(self.m_PaiDuiTB ) do
		if  k>self.m_ResiduePaiNum then 
			v:removeFromParent(true)
			self.m_PaiDuiTB[k] =nil
		end
	end
	local array = {}
    array[1]=cc.DelayTime:create(1)
    array[2]=cc.CallFunc:create(function (  )
    	--self:GoOnInfo()
    end)
    self.m_BaseNode:runAction(cc.Sequence:create(array))
	CCLOG("SC_DAER_FANPAI---2")
end

--  摸牌action
function HjDaer_Base:FanYiPai( zuowei,changValue,typ,cb)
	--self:DelFanPaiFun()
	CCLOG("FanYiPai",zuowei,changValue,typ)
	local function crefanpai(  )
		self.m_fanPaiClass = DaerPokerClass:Create(self.mopai_node,changValue,"fanpai")
		self.m_fanPaiClass.m_player:setPosition(sys.center.x-self.m_fanPaiClass.m_player:getContentSize().width/2,sys.center.y)
		-- 测试代码
		local RotateAngle = 0
		local daseat= LzDaer_M_GetPointZuoWei(zuowei)+1
		if daseat == 1 then
			RotateAngle = 0
		end 
		if daseat == 2 then
			RotateAngle = -60
		end
		if daseat == 3 then
			RotateAngle = 60
		end
		CCLOG("crefanpai---1")
		local time = 0.2
		local array = {}
		array[1] = cc.Spawn:create(cc.MoveTo:create(time,{x = self.DEF_CHUPAI_POS[daseat].x,y = self.DEF_CHUPAI_POS[daseat].y}),cc.RotateBy:create(time/2,RotateAngle))
		array[2] = cc.Spawn:create(cc.OrbitCamera:create(time, 0.1, 0, 0, 90, -90, 0),cc.ScaleTo:create(time,1.2),cc.MoveBy:create(time,{x = 0,y = -10}))
		array[3] = cc.CallFunc:create(function (  )
			if typ ~= "mopai" then
			   self.m_fanPaiClass:UpDatefrantSp(changValue)
			 else
			 	if  changValue ==0 then
                    self.m_fanPaiClass.frantSp:setSpriteFrame("lzde_cp")
			 	else
			        --self.m_fanPaiClass.frantSp:setSpriteFrame("lzde_cp")
			         self.m_fanPaiClass:UpDatefrantSp(changValue)
			    end
		     end
			self.m_fanPaiClass.m_player:setRotation(0)
		end)
		array[4] = cc.Spawn:create(cc.OrbitCamera:create(time/2, 0.1, 0, 90+180, 90, -90, 0),cc.ScaleTo:create(time/2,DEF_POKER_SCALE),cc.MoveBy:create(time,{x = 0,y = -10}))
		array[5] = cc.DelayTime:create(0.8)
		array[6] = cc.CallFunc:create(function (  )
			if typ == "mopai" then --此时为摸牌
				local arrani = {}
				local movetime = 0.2
				local headpos = LzDaer_M_GetTouXiangPOS(zuowei)
				arrani[1] = cc.DelayTime:create(0.5)
				arrani[2] =  cc.Spawn:create(cc.MoveTo:create(movetime,{x = headpos.x,y = headpos.y}),cc.ScaleTo:create(movetime,0.2))
				arrani[3] = cc.CallFunc:create(function (  )
					CCLOG("此时为摸牌---1")
					self:DelFanPaiFun(zuowei)
					CCLOG("此时为摸牌---2")
					if cb then
						CCLOG("此时为摸牌---3")
						cb()
					end 
					self:GoOnInfo()
				end)
				self.m_fanPaiClass.m_player:runAction(cc.Sequence:create(arrani))
			else
				self:GoOnInfo()
			end 
		end)
		self.m_fanPaiClass.m_player:runAction(cc.Sequence:create(array))
		CCLOG("创建展示牌成功")    
	end
	if self.m_fanPaiClass.m_player  then 
		self:Action_UpPaiFadeOut(zuowei,crefanpai)
	else
		crefanpai()
	end
end
-- 删除番的牌
function HjDaer_Base:DelFanPaiFun(zuowei  )
	if self.m_fanPaiClass.m_player  then
	   self.m_fanPaiClass.m_player:removeFromParent(true)
	   self.m_fanPaiClass={}
	end
end
function HjDaer_Base:Action_UpPaiFadeOut(zuowei, cb )
	if self.m_fanPaiClass.m_player  == nil then
		return
	end 
	CCLOG("翻牌消失函数")
	local array = {}
	array[1] = cc.Spawn:create(cc.FadeOut:create(0.2),cc.MoveBy:create(0.2,{x = 0,y = -100}))
	array[2] = cc.CallFunc:create(function (  )
			CCLOG("m_CurrUpPaiSp 执行动作 Action_UpPaiFadeOut 完毕 ")
			self:DelFanPaiFun()
			if cb then
				cb()
			end
	end)
	CCLOG("m_CurrUpPaiSp 执行动作 Action_UpPaiFadeOut ")
	self.m_fanPaiClass.m_player:runAction(cc.Sequence:create(array))
end

--摸一张牌
function HjDaer_Base:SC_DAER_MOPAI(key,s)
	SHOW(s)
	CCLOG("SC_DAER_MOPAI---1")
	self:StopInfo()
	LzDaer_Public_ActionSound("qipai")
	local zuowei =s.seat or self.m_MySeat
	local changValue =s.value  or 0
	if zuowei==self.m_MySeat  then
		CCLOG("SC_DAER_MOPAI自己")
		self:MoYiPai(zuowei,changValue,function (  )
			-- body
		end)
	else
		self:FanYiPai(zuowei,changValue,"mopai",function (  )
			LzDaer_M_CreateOneSp(zuowei)
			self:GoOnInfo()
		end)

   end
	self.m_ResiduePaiNum = s.leftpai
	self:UpdateResiduePai()
    for k,v in pairs(self.m_PaiDuiTB ) do
		if  k>self.m_ResiduePaiNum then 
			v:removeFromParent(true)
			self.m_PaiDuiTB[k] =nil
		end
	end
	CCLOG("SC_DAER_MOPAI---2")
end
--  摸牌action
function HjDaer_Base:OtherMoYiPai( zuowei,cb)
	CCLOG("OtherMoYiPai",zuowei)
	self:DelFanPaiFun()
	CCLOG("OtherMoYiPai---1")
	local daseat= LzDaer_M_GetPointZuoWei(zuowei)+1
	local headpos = LzDaer_M_GetTouXiangPOS(zuowei)
    local m_fanPaiClass=DaerPokerClass:Create(self.mopai_node,changValue,"fanpai")
    m_fanPaiClass.m_player:setPosition(sys.center.x-m_fanPaiClass.m_player:getContentSize().width/2,sys.center.y)
	local array = {}
	array[1]=cc.Spawn:create(cc.MoveTo:create(time,{x = headpos.x,y = headpos.y}),cc.ScaleTo:create(time/2,0.4),cc.FadeOut:create(time))
	array[2]=cc.CallFunc:create(function ( )
		 if cb then cb() end
		 m_fanPaiClass:removeFromParent(true)
		 m_fanPaiClass=nil
	end)
	m_fanPaiClass:runAction(cc.Sequence:create(array))
	CCLOG("OtherMoYiPai---2")
end
--找到插入牌位置
function HjDaer_Base:FindChaRuPos( changValue )
	local weizhi_x,weizhi_y=0,0
	local isFind  =false
	local charu3  =false
    --找到组队的
	for k1,v1 in pairs(self.m_ShouPaiClassTb) do
     	for k2,v2 in pairs(v1) do
     		local vCount = sys.getTBCount(v1)
     		if vCount>=3 then
     			if v2.daer_value ==changValue then
                   CCLOG("插如大于三")
                    charu3=true
                    weizhi_x=k1
	                weizhi_y=k2
                end
     		else
	     		if v2.daer_value ==changValue then
	                weizhi_x=k1
	                weizhi_y=k2
	                isFind=true
	     		end
	     	end
     	end
    end
    if charu3 and isFind ==false then
        weizhi_x=weizhi_x-1
        if weizhi_x<=0 then weizhi_x=1  end
        for k1,v1 in pairs(self.m_ShouPaiClassTb) do
        	local vCount = sys.getTBCount(v1)
        	if vCount<3 then
	            if k1==weizhi_x  then
	               weizhi_y=sys.getTBCount(v1)
	               isFind=true
	               break
	            end
	        end
	    end
	end
    if isFind ==false then 
	    --找到挨着的
	    local findValue =changValue
	    if changValue%10 ==1 then findValue=changValue+1 end
	    if changValue%10 ==0 then findValue=changValue-1 end
	    CCLOG("changValue",changValue)
		for k1,v1 in pairs(self.m_ShouPaiClassTb) do
	     	for k2,v2 in pairs(v1) do
	     		local vCount = sys.getTBCount(v1)
        	    if vCount<3 then
		     		if (v2.daer_value ==findValue+1) or (v2.daer_value ==findValue-1)  then
		                weizhi_x=k1
		                weizhi_y=k2
		                isFind=true
		                break
		     		end
		     	end
	     	end
	    end
	    if isFind ==false then
	       for k1,v1 in pairs(self.m_ShouPaiClassTb) do
		     	for k2,v2 in pairs(v1) do
		     	    local vCount = sys.getTBCount(v1)
        	        if vCount<3 then
			     		if sys.getTBCount(v1)==1 then 
			                weizhi_x=k1
			                weizhi_y=k2
			                isFind=true
			                break
			     		end
			     	end
		     	end
		    end
	    end
	end

	CCLOG("FindChaRuPos",weizhi_x,weizhi_y)
	return weizhi_x,weizhi_y
end
-- 翻牌 摸牌action
function HjDaer_Base:MoYiPai( zuowei,changValue,cb)
    CCLOG("MoYiPai---")
    self:DelFanPaiFun()
    CCLOG("MoYiPai---0")
    local pokerScal =1
    if self.m_isVideoState  then
        pokerScal=0.8
    end
	local  m_fanPaiClass = DaerPokerClass:Create(self.shou_pokernode,changValue,"fanpai",nil,nil,nil)
	m_fanPaiClass.m_player:setPosition(sys.center.x-m_fanPaiClass.m_player:getContentSize().width/2,sys.center.y)
    m_fanPaiClass.m_player:setLocalZOrder(100)

    m_fanPaiClass.m_player:setScale(0.8)
	-- 测试代码
	local RotateAngle = 0
	local Pos = {x = 0,y = 0}
	local daseat= LzDaer_M_GetPointZuoWei(zuowei)+1
	if daseat == 1 then
		RotateAngle = 0
	end 
	if daseat == 2 then
		RotateAngle = -60
	end
	if daseat == 3 then
		RotateAngle = 60
	end
	CCLOG("MoYiPai---1")
	local time = 0.2
	local array = {}
	array[1] = cc.Spawn:create(cc.MoveTo:create(time,{x = self.DEF_CHUPAI_POS[daseat].x,y = self.DEF_CHUPAI_POS[daseat].y}),cc.RotateBy:create(time/2,RotateAngle))
	array[2] = cc.Spawn:create(cc.OrbitCamera:create(time, 0.1, 0, 0, 90, -90, 0),cc.ScaleTo:create(time,0.8),cc.MoveBy:create(time,{x = 0,y = -10}))
	array[3] = cc.CallFunc:create(function (  )
		m_fanPaiClass:UpDatefrantSp(changValue)
		m_fanPaiClass.m_player:setRotation(0)
	end)
	array[4] = cc.Spawn:create(cc.OrbitCamera:create(time/2, 0.1, 0, 90+180, 90, -90, 0),cc.ScaleTo:create(time/2,pokerScal),cc.MoveBy:create(time,{x = 0,y = -10}))
	array[5] = cc.DelayTime:create(0.8)
	array[6] = cc.CallFunc:create(function (  )
		m_fanPaiClass:UpDatefrantSp(changValue,daseat)
		m_fanPaiClass.m_CanClicke=true
		CCLOG("MoYiPai---2")
		m_fanPaiClass.m_player:setScale(1)
		m_fanPaiClass.m_player:setContentSize(m_fanPaiClass.frantSp:getContentSize())
		m_fanPaiClass:TouchListener()
		CCLOG("MoYiPai---3")
		self:ChangeSortPoker(true)
		if cb then cb() end
		CCLOG("MoYiPai---4")
	end)
	array[7] = cc.DelayTime:create(0.2)
	array[8] = cc.CallFunc:create(function (  )
		self:GoOnInfo()
	end)
	m_fanPaiClass.m_player:runAction(cc.Sequence:create(array))
    local weizhi_x,weizhi_y=self:FindChaRuPos(changValue)
	if weizhi_x ==0 and weizhi_y ==0 then
        table.insert(self.m_ShouPaiClassTb[1],m_fanPaiClass)
	else
        for k1,v1 in pairs(self.m_ShouPaiClassTb) do
	        if k1 ==weizhi_x then
               table.insert(v1,weizhi_y,m_fanPaiClass)
	        end
	    end
	end
	CCLOG("创建展示牌成功") 
end
--得到手牌
function HjDaer_Base:GetPlarShouPai(  )
	local shouPaiTb={}
	for k1,v1 in pairs( self.m_MyShowTB) do
		for k2,v2 in pairs(v1) do
			if v2.daer_value  then 
			   table.insert(shouPaiTb,v2.daer_value)
			end
		end
	end
	return  shouPaiTb
end
--当前操作位置
function HjDaer_Base:SC_DAER_NOW_OP_SEAT(key,s)
	SHOW(s)
	CCLOG("SC_DAER_NOW_OP_SEAT")
end
--通知玩家进行的操作
function HjDaer_Base:SC_DAER_CAN_OPERATE(key,s)
	SHOW(s)
	CCLOG("SC_DAER_CAN_OPERATE")
    LzDaer_M_CreOperateUi(self.m_Scene,s)
end
--通知玩家可以进行保叫
function HjDaer_Base:SC_DAER_CAN_BAOJIAO(key,s)
	SHOW(s)
	CCLOG("SC_DAER_CAN_BAOJIAO")
	s={}
	s.guo=1
	s.bao=1
    LzDaer_M_CreOperateUi(self.m_Scene,s)

end
--保叫结果
function HjDaer_Base:SC_DAER_BAOJIAO(key,s)
	SHOW(s)
	CCLOG("SC_DAER_BAOJIAO")
	local zuowei=s.seat
	local baohu = s.baohu  or 0
	if baohu==0 then  return end
    self.m_BaoJiaoTb[zuowei]=1
    -- if self.m_MySeat ==zuowei then 
    --     -- for k1,v1 in pairs(self.m_ShouPaiClassTb) do
    --     --  	for k2,v2 in pairs(v1) do
    --     --  		if v.m_player then
    --     --            CCLOG("报叫置灰")
    --     --            v:SetChangColor(true)
    --     --  		end
    --     --  	end
    --     -- end
    -- end
   self:StopInfo()
   local headTb = LzDaer_M_GetTouXiangLayer()
   LzDaer_Public_PlaySound("baole",headTb[zuowei].xingbie)
   local operate = LzDaer_M_GetPointZuoWei(zuowei)+1
   LzDaerAniamtions.BaoAni(self.act_node,self.DEF_ANI_POS[operate].x,self.DEF_ANI_POS[operate].y,function (  ) 
           LzDaer_M_CreBaojiaoSp(zuowei,1)
        end)
   local array = {}
   array[1]=cc.DelayTime:create(2)
   array[2]=cc.CallFunc:create(function ( )
   	   self:GoOnInfo()
   end)
   self.m_BaseNode:runAction(cc.Sequence:create(array))
end
--通知客户端可以进行拢牌
function HjDaer_Base:SC_DAER_CAN_LONG(key,s)
	SHOW(s)
	CCLOG("SC_DAER_CAN_LONG")
end
--通知拢牌消息
function HjDaer_Base:SC_DAER_LONG(key,s)
	SHOW(s)
	CCLOG("SC_DAER_LONG")
    self:Operate_UI("long",s)
end
--吃的结果
function HjDaer_Base:SC_DAER_CHI(key,s)
	SHOW(s)
	CCLOG("SC_DAER_CHI")
	self:Operate_UI("chi",s)
end
--招的结果
function HjDaer_Base:SC_DAER_ZHAO(key,s)
	SHOW(s)
	CCLOG("SC_DAER_ZHAO")
	self:Operate_UI("zhao",s)
end
--碰的结果
function HjDaer_Base:SC_DAER_PENG(key,s)
	SHOW(s)
	CCLOG("SC_DAER_PENG")

	self:Operate_UI("peng",s)
end
--胡的结果
function HjDaer_Base:SC_DAER_HU(key,s)
	SHOW(s)
	CCLOG("SC_DAER_HU")
	--self:Operate_UI("hu",s)
end
--优先级相关
function HjDaer_Base:SC_DAER_CANCEL_OP(key,s)
	SHOW(s)
	CCLOG("SC_DAER_CANCEL_OP")
end
--是否有操作
function HjDaer_Base:SC_DAER_HAVE_OP(key,s)
	SHOW(s)
	CCLOG("SC_DAER_HAVE_OP")
	LzDaer_M_DelAllTime()
	--local zuowei = s.seat
	CCLOG("SC_DAER_HAVE_OP--1")
	local time = s.timeleft or 0
	LzDaer_M_DelAllTime()
	for k,v in pairs(s.haveop or {}) do
		if v==1 then
		   LzDaer_M_CreTimeUI(k,time)
		end
	end
	CCLOG("SC_DAER_HAVE_OP2")
end
--通知客户端出牌
function HjDaer_Base:SC_DAER_NOTICE_CHUPAI(key,s)
	SHOW(s)
	CCLOG("SC_DAER_NOTICE_CHUPAI")
	local zuowei = s.seat
	local time = s.timeleft or 0
	LzDaer_M_DelAllTime()
	LzDaer_M_DelOperateUI()
	--LzDaer_M_CreTimeUI(zuowei,time)
	if zuowei ==self.m_MySeat then 
       self.m_isCanChuPai =true
       self:CreTipsChuPai()
    else
       self.m_isCanChuPai=false
	end
end
--胡数
function HjDaer_Base:SC_DAER_HU_NUM( key,s )
	CCLOG("SC_DAER_HU_NUM")
	SHOW(s)
	local huNum = s.hu_num
    self:UpdateHuValue(huNum)
end

--某人放弃操作
function HjDaer_Base:SC_DAER_QI( key,s )
	CCLOG("SC_DAER_QI")
	SHOW(s)
    local zuowei=s.seat
    LzDaer_M_DelOneTimeFun(zuowei)

    local m_TouXiangLayerTB = LzDaer_M_GetTouXiangLayer()
    if m_TouXiangLayerTB[zuowei] then 
        m_TouXiangLayerTB[zuowei]:ShowTalkPop("过",nil,20,nil,nil,true,-90)
        LzDaer_Public_ActionSound("guopai")
    end
end
--出牌提示
function HjDaer_Base:CreTipsChuPai(  )
    self.m_chuPaitips =xui.addSprite(self.mopai_node,"ydr_qcp",sys.center.x+220,sys.center.y)
end
function HjDaer_Base:DelTipsChuPai(  )
	if self.m_chuPaitips then
		self.m_chuPaitips:setVisible(false)
	end
end
--出牌 等待
function HjDaer_Base:WaiTeChuPai( s )
	LzDaer_M_DelAllTime()
	LzDaer_M_DelOperateUI()
	local zuowei=s.seat
	local delPai = nil
	local changValue = s.value
	local headTb = LzDaer_M_GetTouXiangLayer()
    LzDaer_Public_PlaySound("poker",headTb[zuowei].xingbie,changValue)
	if zuowei ==self.m_MySeat then
	    self:DelTipsChuPai()
	    self.m_isCanChuPai=false
        for k1,v1 in pairs(self.m_ShouPaiClassTb) do
         	for k2,v2 in pairs(v1) do
         		if v2.m_isOutChuPai ==true then 
                   CCLOG("k1,k2",k1,k2)
                   delPai=table.remove(v1,k2)
         		end
         	end
        end
        if delPai  and delPai.m_player then
        	CCLOG("出牌成功")
            --delPai.m_isOutChuPai=false
            self.m_fanPaiClass=delPai
            -- for k,v in pairs(self.m_ShouPaiClassTb) do
            --     if #v==0 then 
            --         table.remove(self.m_ShouPaiClassTb,k)
            --    	end
            -- end
            self:CleanPokerTbFun()
            --SHOW(self.m_fanPaiClass)
            self:ChangeSortPoker(true)
        else
        	CCLOG("出牌失败")
        	self:CheckSerCount()
        end 
       -- self:CheckSerCount()
	else
       self:ChuYiPai(zuowei,changValue)
	end
	LzDaer_M_DelOneSp(zuowei)
end
--出牌
function HjDaer_Base:SC_DAER_CHUPAI(key,s)
	SHOW(s)
	CCLOG("SC_DAER_CHUPAI")
	self:StopInfo()
	self:WaiTeChuPai(s)
	local array={}
	array[1]=cc.DelayTime:create(1)
	array[2]=cc.CallFunc:create(function ( ... )
		 self:GoOnInfo()
	end)

	self.m_BaseNode:runAction(cc.Sequence:create(array))
end
--出一张牌
function HjDaer_Base:ChuYiPai( zuowei,changValue )
	CCLOG("出一张牌")
	local daseat = LzDaer_M_GetPointZuoWei(zuowei)+1
	local function crefanpai(  )
		local headpos = LzDaer_M_GetTouXiangPOS(zuowei)
		CCLOG("出一张牌 3 ")
		self.m_fanPaiClass = DaerPokerClass:Create(self.mopai_node,changValue,"bottom","shou")
		--self.m_fanPaiClass.m_player:setScale(DEF_POKER_SCALE)
		self.m_fanPaiClass.m_player:setPosition(headpos.x,headpos.y)
		local movetime = 0.25
		CCLOG("出一张牌 4 ")
		-- if daseat  ==1  then
  --          offx= sys.center.x-50
  --          offy= sys.center.y -40
		-- end
		-- if daseat == 2 then
  --           offx= sys.center.x+350
  --           offy= sys.center.y -40
		-- end
		-- if daseat== 3 then
  --           offx= sys.center.x-430
  --           offy= sys.center.y -40,
		-- end
		local array = {}
		CCLOG("出一张牌 5 ")
		array[1] =cc.Spawn:create(cc.ScaleTo:create(movetime/2,DEF_POKER_SCALE),cc.MoveTo:create(movetime,{x = self.DEF_CHUPAI_POS[daseat].x,y = self.DEF_CHUPAI_POS[daseat].y}))
		array[2] = cc.DelayTime:create(0.5)
		array[3] = cc.CallFunc:create(function (  )
			--self:GoOnInfo()
			CCLOG("出一张牌 7 ")
		end)
		CCLOG("出一张牌 6 ")
		self.m_fanPaiClass.m_player:runAction(cc.Sequence:create(array))
    end
    if self.m_fanPaiClass.m_player  then
        CCLOG("出一张牌 2 ") 
		self:Action_UpPaiFadeOut(zuowei,crefanpai)
	else
		CCLOG("出一张牌 1 ")
		crefanpai()
	end
end
---踢出#v==0 
function HjDaer_Base:CleanPokerTbFun(  )
	for i=1,10 do
		for k,v in pairs(self.m_ShouPaiClassTb) do
	   	    if sys.getTBCount(v) ==0 then
	            table.remove(self.m_ShouPaiClassTb,k)
	   	    end
	    end
	end
	
end

---操作
function HjDaer_Base:Operate_UI( opType,s )
	local zuowei =s.seat
	local dekPaicount = 1
	local delCount =0

	local operate = LzDaer_M_GetPointZuoWei(zuowei)+1
    self:Action_ChiPengPai(operate)
    self:StopInfo()
    resetHeartTimeOutCnt()
    if operate==1 then
	    self.m_CanMovePai   =true
	end
    local talkLab=""
    local headTb = LzDaer_M_GetTouXiangLayer()
    LzDaer_Public_PlaySound(opType,headTb[zuowei].xingbie)
	if opType =="long" then
		local changValue =s.long
        CCLOG("拢牌",operate,changValue)
        talkLab="拢"
       -- SHOW(s)
        LzDaerAniamtions.LongAni(self.act_node,self.DEF_ANI_POS[operate].x,self.DEF_ANI_POS[operate].y,function (  )
       	  self:GoOnInfo()
       	  self.m_CanMovePai   =false
        end)
        --resetHeartTimeOutCnt()
        --for k,v in pairs(s.long or {}) do
       	   if operate ==1 then
       	   	   for i=1,4 do 
		       	   for k1,v1 in pairs(self.m_ShouPaiClassTb) do
		       	   	   for k2,v2 in pairs(v1) do
		       	   	   	    if v2.daer_value ==changValue  then
		       	   	   	   	     CCLOG("拢牌---del")
		       	   	   	   	    if v2.m_player then 
		       	   	   	   	    	delCount=delCount+1
		       	   	   	   	  	    v2.m_player:removeFromParent(true)
		       	   	   	   	  	    table.remove(v1,k2)
		       	   	   	   	    end   
		       	   	   	    end
		       	   	    end
		       	    end
		       	end
		    else
		    	if self.m_isVideoState  then
		    		for i=1,4 do 
	                    for k1,v1 in pairs(self.m_OtherPokerTb[zuowei] or {}) do
	                		if v1.m_player  and v1.daer_value ==changValue then
	                			v1.m_player:removeFromParent(true)
	                            table.remove(self.m_OtherPokerTb[zuowei],k1)
	                            CCLOG("video-----dellong")
	                            break
	                		end
	                	end
	                end
	        	end
	        end
       	    table.insert(self.m_KanTB[zuowei],{changValue,changValue,changValue,["ty"]="long"})
       	    
       --end
       dekPaicount=4
       if delCount~=4  and operate ==1 and self.m_isVideoState ==false  then
       	     CCLOG("delCount",delCount)
       	    SHOW(self.m_ShouPaiClassTb)
		    tips.creUpTimeTips("请求同步手牌")
		    CS_DAER_SYNC_SP()
	    end 

	end
    if opType=="zhao"   then
        CCLOG("招牌")
        talkLab="招"
        LzDaerAniamtions.ZhaoAni(self.act_node,self.DEF_ANI_POS[operate].x,self.DEF_ANI_POS[operate].y,function (  )
       	  self:GoOnInfo()
       	  self.m_CanMovePai   =false
        end)
        local changValue =s.value
        dekPaicount=3
        if operate ==1 then
        	for i=1,dekPaicount do
		        for k1,v1 in pairs(self.m_ShouPaiClassTb) do
		   	   	    for k2,v2 in pairs(v1) do
		   	   	   	    if v2.daer_value ==changValue  then
		   	   	   	    	CCLOG("招牌--del")
	   	   	   	    	   	if v2.m_player then 
	   	   	   	    	   		delCount=delCount+1
	       	   	   	   	  	    v2.m_player:removeFromParent(true)
	       	   	   	   	  	    table.remove(v1,k2)
	       	   	   	   	    end
		   	   	   	    end
		   	   	    end
		   	    end 
		   	end
		   	if delCount~=3 and self.m_isVideoState ==false then
		   		CCLOG("delCount",delCount)
		   	   SHOW(self.m_ShouPaiClassTb)
		       tips.creUpTimeTips("请求同步手牌")
		       CS_DAER_SYNC_SP()
	        end
	    else
	    	if self.m_isVideoState  then
	    		for i=1,dekPaicount do
                    for k1,v1 in pairs(self.m_OtherPokerTb[zuowei] or {}) do
                		if v1.m_player  and v1.daer_value ==changValue then
                			v1.m_player:removeFromParent(true)
                            table.remove(self.m_OtherPokerTb[zuowei],k1)
                             CCLOG("video-----zhao")
                            break
                		end
                	end
	        	end
	        end
	   	end
   	    table.insert(self.m_KanTB[zuowei],{changValue,changValue,changValue,["ty"]="zhao"})
   	   
    end
    if opType=="peng"   then
        CCLOG("碰牌")
         talkLab="碰"
        LzDaerAniamtions.PengAni(self.act_node,self.DEF_ANI_POS[operate].x,self.DEF_ANI_POS[operate].y,function (  )
       	  self:GoOnInfo()
       	  self.m_CanMovePai   =false
       end)
        local changValue =s.value
        dekPaicount=2
        CCLOG("碰牌--------",changValue)
        --SHOW(self.m_ShouPaiClassTb)
        if operate ==1 then
        	for i=1,dekPaicount do
        		for k1,v1 in pairs(self.m_ShouPaiClassTb) do
		   	   	    for k2,v2 in pairs(v1) do
		   	   	   	    if v2.daer_value ==changValue  then
	   	   	   	    	    if v2.m_player then 
	   	   	   	    	    	CCLOG("碰牌--del")
	   	   	   	    	    	delCount=delCount+1
	       	   	   	   	  	    v2.m_player:removeFromParent(true)
	       	   	   	   	  	    table.remove(v1,k2)
	       	   	   	   	    end
		   	   	   	    end
		   	   	    end
		   	    end 
        	end 
        	if delCount~=2 and self.m_isVideoState ==false then
        	    CCLOG("delCount",delCount)
        	   SHOW(self.m_ShouPaiClassTb)
		       tips.creUpTimeTips("请求同步手牌")
		       CS_DAER_SYNC_SP()
	        end 
	    else
	        if self.m_isVideoState  then
	    		for i=1,dekPaicount do
                    for k1,v1 in pairs(self.m_OtherPokerTb[zuowei] or {}) do
                		if v1.m_player  and v1.daer_value ==changValue then
                			v1.m_player:removeFromParent(true)
                            table.remove(self.m_OtherPokerTb[zuowei],k1)
                             CCLOG("video-----peng")
                            break
                		end
                	end
	        	end
	        	--CCLOG("video-----pengcount",sys.getTBCount(self.m_OtherPokerTb[zuowei]))
	            --SHOW(self.m_OtherPokerTb[zuowei])
	        end   
	        
	   	end
	   	--SHOW(self.m_ShouPaiClassTb)
   	    table.insert(self.m_KanTB[zuowei],{changValue,changValue,changValue,["ty"]="peng"})
   	    
    end
    if opType=="chi"   then
       CCLOG("吃牌")
       talkLab="吃"
       LzDaerAniamtions.ChiAni(self.act_node,self.DEF_ANI_POS[operate].x,self.DEF_ANI_POS[operate].y,function (  )
       	  self:GoOnInfo()
       	  self.m_CanMovePai   =false
       end)
       if s.chi  then
            local delTb = {s.chi.o1,s.chi.o2}
		    table.insert(self.m_KanTB[zuowei],{s.chi.o1,s.chi.o2,s.chi.pai,["ty"]="chi"})
		    dekPaicount=2
		    if operate ==1 then
	            for k,changValue in pairs(delTb) do
	            	local flag = false
	            	for k1,v1 in pairs(self.m_ShouPaiClassTb) do
			   	   	    for k2,v2 in pairs(v1) do
			   	   	   	    if v2.daer_value ==changValue  then	
		   	   	   	    	    if v2.m_player then
		   	   	   	    	        delCount=delCount+1 
		   	   	   	    	        CCLOG("吃牌--del")
		       	   	   	   	  	    v2.m_player:removeFromParent(true)
		       	   	   	   	  	    table.remove(v1,k2)
		       	   	   	   	  	    flag=true
		       	   	   	   	  	    break
		       	   	   	   	    end
			   	   	   	    end
			   	   	    end
			   	   	    if flag then break end
			   	    end 
	            end
	        else
	        	if self.m_isVideoState  then
                    for k,changValue in pairs(delTb) do
                    	for k1,v1 in pairs(self.m_OtherPokerTb[zuowei] or {}) do
                    		if v1.m_player  and v1.daer_value ==changValue then
                    			v1.m_player:removeFromParent(true)
                                table.remove(self.m_OtherPokerTb[zuowei],k1)
                                 CCLOG("video-----chi")
                                break
                    		end
                    	end
                    end
	        	end
            end
            if s.bi then 
               delTb={}
               table.insert(delTb,s.bi.o1)
               table.insert(delTb,s.bi.o2)
               table.insert(delTb,s.bi.pai)
               table.insert(self.m_KanTB[zuowei],{s.bi.o1,s.bi.o2,s.bi.pai,["ty"]="bi"})
              -- self:CleanPokerTbFun()
               dekPaicount=5
               talkLab="吃和比"
               if operate ==1 then
		            for k,changValue in pairs(delTb) do
		            	local flag = false
		            	for k1,v1 in pairs(self.m_ShouPaiClassTb) do
				   	   	    for k2,v2 in pairs(v1) do
				   	   	   	    if v2.daer_value ==changValue  then
				   	   	   	    	
			   	   	   	    	    if v2.m_player then 
			   	   	   	    	    	CCLOG("bi--del")
			   	   	   	    	    	delCount=delCount+1 
			       	   	   	   	  	    v2.m_player:removeFromParent(true)
			       	   	   	   	  	    table.remove(v1,k2)
			       	   	   	   	  	    flag=true
		       	   	   	   	  	         break
			       	   	   	   	    end
				   	   	   	    end
				   	   	    end
				   	   	    if flag then break end
				   	    end 
		            end
		        else
		        	if self.m_isVideoState  then
	                    for k,changValue in pairs(delTb) do
	                    	for k1,v1 in pairs(self.m_OtherPokerTb[zuowei] or {}) do
	                    		if v1.m_player  and v1.daer_value ==changValue then
	                    			v1.m_player:removeFromParent(true)
	                                table.remove(self.m_OtherPokerTb[zuowei],k1)
	                                 CCLOG("video-----bi")
	                                break
	                    		end
	                    	end
	                    end
		        	end
	            end
            end
            SHOW(delTb)  
            if operate ==1 and self.m_isVideoState ==false  then
	            if delCount==2 or delCount==5  then

	            else
	               CCLOG("delCount",delCount)
	               SHOW(self.m_ShouPaiClassTb)
			       tips.creUpTimeTips("请求同步手牌")
			       CS_DAER_SYNC_SP()
		        end 
		    end 
        end
    end
    local m_TouXiangLayerTB = LzDaer_M_GetTouXiangLayer()
    if m_TouXiangLayerTB[zuowei] then 
       m_TouXiangLayerTB[zuowei]:ShowTalkPop(talkLab,nil,20,nil,nil,true,-90)
    end
	if  self.m_isVideoState ==false  then
		if operate ==1 then
		    self:CleanPokerTbFun()
		    self:ChangeSortPoker(true) 
		end
		for i=1,dekPaicount do
			LzDaer_M_DelOneSp(zuowei)
		end	
	else
		self:DelayTimeFun(function (  )
			
		end,0.2)
        self:Video_SortPai(zuowei)
	end
	self:UpdateKan(zuowei)
	CCLOG("Operate_UI is end")
end
function LzDaer_M_GetMoveState(  )
	return  HjDaer_Base.m_CanMovePai  
end
--检查手牌与服务器
function HjDaer_Base:CheckSerCount(  )
	CCLOG("检查手牌与服务器")
	local shouCiunt = 0
	for k1,v1 in pairs(self.m_ShouPaiClassTb) do
		for k1,v2 in pairs(v1) do
			if v2 ~=nil then
                shouCiunt=shouCiunt+1
			end
		end
	end
	CCLOG("shouCiunt",shouCiunt)
	if shouCiunt%3~=2 then
	   SHOW(self.m_fanPaiClass)
       tips.creUpTimeTips("请求同步手牌")
       CS_DAER_SYNC_SP()
	end
end
function HjDaer_Base:SC_DAER_SYNC_SP( key,s )
   SHOW(s)
   CCLOG("SC_DAER_SYNC_SP")
  -- if 1 then self:GoOnInfo()   return end
   self.m_MyShouPaiTB=s.shoupai
   self.m_KanTB[self.m_MySeat]={}
   if s.hu_num  and s.hu_num>0 then
   	 self:UpdateHuValue(s.hu_num)
   end
    if s.peng  then 
    	for k1,v1 in pairs(s.peng) do
    		table.insert(self.m_KanTB[self.m_MySeat],{v1,v1,v1,["ty"]="peng"})
    	end
    end
    if s.long  then 
    	for k1,v1 in pairs(s.long) do
    		table.insert(self.m_KanTB[self.m_MySeat],{v1,v1,v1,["ty"]="long"})
    	end
    end
    if s.zhao  then 
    	for k1,v1 in pairs(s.zhao) do
    		table.insert(self.m_KanTB[self.m_MySeat],{v1,v1,v1,["ty"]="zhao"})
    	end
    end
    if s.chi  then 
    	for k1,v1 in pairs(s.chi) do 
    		SHOW(v1)
    		table.insert(self.m_KanTB[self.m_MySeat],{v1.o1,v1.o2,v1.pai,["ty"]="chi"})
    	end
    end
    if s.fei  then 
       self.m_PutoutTB[self.m_MySeat]=s.fei
    end
	CCLOG("self.m_KanTB")
    SHOW(self.m_KanTB)
	self:UpdateKan(self.m_MySeat,"duanxian")
	self:UpdatePutount(self.m_MySeat,"duanxian")	
	self:ZhanKaiMyShouPai()
end
--更新坎
function HjDaer_Base:UpdateKan( zuowei,typ )
	CCLOG("更新坎",zuowei)
	if  typ ~= "duanxian" then
		--self:DelFanPaiFun(zuowei)
	end 
	if self.m_KanNodeTB[zuowei] then
		self.m_KanNodeTB[zuowei]:removeFromParent()
		self.m_KanNodeTB[zuowei] = nil
	end 
	self.m_KanNodeTB[zuowei] = cc.Node:create()
	self.da_pokerNode:addChild(self.m_KanNodeTB[zuowei])
	self.m_KanShowSpTB[zuowei] = {}
	local kantb = {}
	for k,v in pairs(self.m_KanTB) do
		if k == zuowei then
			kantb = v
		end 
	end
	--kantb={{1,1,1,["ty"]="long"},{1,1,1,["ty"]="long"},{1,1,1,["ty"]="long"}}
	local operate = LzDaer_M_GetPointZuoWei(zuowei)+1
	if  operate== 1 then
		local offx = 48
		local offy = 40
		local adjustx = -10
		local adjuscal = 0.02
        local posTbx = {
              [1]={0,14,28},
              [2]={0,13,26},
              [3]={0,12,24},
              [4]={-3,11,25},
              [5]={-5,8,22},
              [6]={-7,5,18},
        }
		self.m_KanNodeTB[zuowei]:setPosition({x = sys.center.x-600,y = 20})
		for k,v in pairs(kantb) do
			self.m_KanShowSpTB[zuowei][k] = {}
			for k1,v1 in pairs(v) do
				local ofy = 0
				local ofx = 20
				local tempx = k
				if k==1  then tempx=1 end 
				if k==2  then tempx=4 end 
				if k==3  then tempx=2 end
				if k==4  then tempx=5 end 
				if k==5  then tempx=3 end 
				if k==6  then tempx=6 end
				local offscal = 0
				local tubiaooffx =36
				if tempx > 3 then
					tempx = tempx - 2
					ofy = 130
					ofx = 15
					offscal = 0.06
					tubiaooffx =-5
					offy=38
				end
				if type(v1) == "number"  then
					self.m_KanShowSpTB[zuowei][k][k1] = DaerPokerClass:Create(self.m_KanNodeTB[zuowei],v1,"bottom","zhao",nil,nil,1-(k1-1)*adjuscal-offscal)
					--self.m_KanNodeTB[zuowei]:addChild(self.m_KanShowSpTB[zuowei][k][k1])
					local addx = posTbx[tempx][k1]  or 0
					self.m_KanShowSpTB[zuowei][k][k1].m_player:setPosition({x = offx*tempx+addx,y = offy*k1+ofy})
					self.m_KanShowSpTB[zuowei][k][k1].m_player:setLocalZOrder(20 - k1)
					--self.m_KanShowSpTB[zuowei][k][k1].m_player:setScale(1-(k1-1)*adjuscal-offscal)
				end 
				if type(v1) == "string" then
					local caozuosp = nil
					local resName = nil 
					if v1 == "long" then
						resName="lzde_long"
						caozuosp = xui.addSprite(self.m_KanNodeTB[zuowei],resName, offx*tempx,offy+ofy,sys.ap.leftBottom,20)
					end
					if v1 == "zhao" then
						resName="lzde_zhao"
						caozuosp = xui.addSprite(self.m_KanNodeTB[zuowei],resName, offx*tempx,offy+ofy,sys.ap.leftBottom,20)
					end	
				end 
			end

		end
	end
	if operate == 2 then
		local offx = 45
		local offy = 30
		local adjustx = 10
		local adjuscal = 0.02
		local posTbx = {
              [1]={0,-10,-20},
              [2]={0,-10,-20},
              [3]={0,-10,-20},
              [4]={1,-10,-20},
              [5]={1,-10,-20},
              [6]={1,-10,-20},
        }
		self.m_KanNodeTB[zuowei]:setPosition({x = sys.center.x + 420,y = sys.center.y + 100})
		for k,v in pairs(kantb) do
			self.m_KanShowSpTB[zuowei][k] = {}
			for k1,v1 in pairs(v) do
				local ofy = 0
				local offscal = 0
				local tempx = k
				local off_x = -1
				offx=38
				local tubiaooffx = -16
				if k > 3 then
					tempx = tempx - 4
					ofy = 110
					offscal = 0.06
					tubiaooffx = 23
					off_x=-5
					offx = 40
				end
				if type(v1) == "number" then
					local addx = posTbx[k][k1]  or 0
					self.m_KanShowSpTB[zuowei][k][k1] = DaerPokerClass:Create(self.m_KanNodeTB[zuowei],v1,"right","zhao",nil,nil,0.76+(k1-1)*adjuscal+offscal)
					--self.m_KanNodeTB[zuowei]:addChild(m_KanShowSpTB[zuowei][k][k1])
					self.m_KanShowSpTB[zuowei][k][k1].m_player:setPosition({x = -offx*tempx +addx+off_x,y = offy*k1 - ofy})
					self.m_KanShowSpTB[zuowei][k][k1].m_player:setLocalZOrder(20 - k1)
					--self.m_KanShowSpTB[zuowei][k][k1].m_player:setScale(1-(k1-1)*adjuscal-offscal)
				end 
				CCLOG("k1===========",k1,v1)
				if type(v1) == "string" then
					local caozuosp = nil
					local resName = nil 
					if v1 == "long" then
						resName="lzde_long"
						caozuosp = xui.addSprite(self.m_KanNodeTB[zuowei],resName,-offx*tempx,offy - ofy,sys.ap.leftBottom,20)
					    caozuosp:setScale(0.9)
					end
					if v1 == "zhao" then
						resName="lzde_zhao"
						caozuosp = xui.addSprite(self.m_KanNodeTB[zuowei],resName, -offx*tempx,offy - ofy,sys.ap.leftBottom,20)
					    caozuosp:setScale(0.9)
					end	
				end 
			end
		end
	end
	if operate == 3  then
		local offx = 47
		local offy = 30
		local adjustx = 10
		local adjuscal = 0.02
	    local posTbx = {
              [1]={0,10,20},
              [2]={0,10,20},
              [3]={0,10,20},
              [4]={1,10,20},
              [5]={1,10,20},
              [6]={1,10,20},
        }
		self.m_KanNodeTB[zuowei]:setPosition({x = sys.center.x-470,y = sys.center.y+100})
		for k,v in pairs(kantb) do
			self.m_KanShowSpTB[zuowei][k] = {}
			for k1,v1 in pairs(v) do
				local ofy = 0
				local ofx = 0
				local tempx = k
				local offscal = 0
				local tubiaooffx =36
				offx=38
				if k > 3 then
					tempx = tempx - 4
					ofy = 110
					ofx = 20
					offscal =0.06
					ofx=0
					tubiaooffx =-5
					offx=41
				end
				if type(v1) == "number" then
					local addx = posTbx[k][k1]  or 0
					self.m_KanShowSpTB[zuowei][k][k1] =  DaerPokerClass:Create(self.m_KanNodeTB[zuowei],v1,"left","zhao",nil,nil,0.76+(k1-1)*adjuscal+offscal)
					--self.m_KanNodeTB[zuowei]:addChild(self.m_KanShowSpTB[zuowei][k][k1])
					self.m_KanShowSpTB[zuowei][k][k1].m_player:setPosition({x = offx*tempx + addx+ofx,y = offy*k1 - ofy})
					self.m_KanShowSpTB[zuowei][k][k1].m_player:setLocalZOrder(20 - k1)
					--self.m_KanShowSpTB[zuowei][k][k1].m_player:setScale(1-(k1-1)*adjuscal-offscal)
				end 
				if type(v1) == "string" then
					local caozuosp = nil
					local resName = nil 
					if v1 == "long" then
						resName="lzde_long"
						caozuosp = xui.addSprite(self.m_KanNodeTB[zuowei],resName,  offx*tempx,offy - ofy,sys.ap.leftBottom,20)
					    caozuosp:setScale(0.9)
					end
					if v1 == "zhao" then
						resName="lzde_zhao"
						caozuosp = xui.addSprite(self.m_KanNodeTB[zuowei],resName,  offx*tempx,offy - ofy,sys.ap.leftBottom,20)
						caozuosp:setScale(0.9)
					end	
				end 
			end
		end
	end
end
function HjDaer_Base:Action_ChiPengPai(cPos, cb )
	if self.m_fanPaiClass.m_player  == nil then
		return
	end 
	CCLOG("翻牌消失函数")
    local movePosTb={
      [1]={x = sys.center.x-520,y = 20},
      [2]={x = sys.center.x + 420,y = sys.center.y + 100},
      [3]={x = sys.center.x-470,y = sys.center.y+100}
}
	
	local array = {}
	-- array[1] = cc.FadeOut:create(0.2)
	array[1] = cc.Spawn:create(cc.FadeOut:create(0.2),cc.MoveTo:create(0.2,{x = movePosTb[cPos].x,y = movePosTb[cPos].y}))
	array[2] = cc.CallFunc:create(function (  )
			CCLOG("m_CurrUpPaiSp 执行动作 Action_ChiPengPai 完毕 ")
			self:DelFanPaiFun()
			if cb then
				cb()
			end
	end)
	CCLOG("m_CurrUpPaiSp 执行动作 Action_ChiPengPai ")
	self.m_fanPaiClass.m_player:runAction(cc.Sequence:create(array))
end
--手牌进入弃牌堆
function HjDaer_Base:SC_DAER_PAIDUI(key,s )
	CCLOG("SC_DAER_PAIDUI")
	SHOW(s)
	self:StopInfo()
	local zuowei = s.seat
	local changValue = s.value
	table.insert(self.m_PutoutTB[zuowei],changValue)
    self:UpdatePutount(zuowei)
    self:Action_OutPaiToZhuoMian(zuowei,function ( )
    	--self:GoOnInfo()
    end)
    local array = {}
    array[1]=cc.DelayTime:create(1)
    array[2]=cc.CallFunc:create(function (  )
    	self:GoOnInfo()
    end)
    self.m_BaseNode:runAction(cc.Sequence:create(array))
end
--得到打出pai
function HjDaer_Base:UpdatePutount( zuowei ,typ)
	local operate = LzDaer_M_GetPointZuoWei(zuowei)+1
	if  typ ~= "duanxian" then
		--self:DelFanPaiFun(zuowei)
		self:Action_OutfuiPai(zuowei)
	end 
	if self.m_PutoutNodeTB[zuowei] then
		self.m_PutoutNodeTB[zuowei]:removeFromParent()
		self.m_PutoutNodeTB[zuowei] = nil
	end 
	self.m_PutoutNodeTB[zuowei] = cc.Node:create()
	self.da_pokerNode:addChild(self.m_PutoutNodeTB[zuowei])
	self.m_PutoutShowSpTB[zuowei] = {}
	local putouttb = {}
	for k,v in pairs(self.m_PutoutTB) do
		if k == zuowei then
			putouttb = v
		end 
	end
	---putouttb={1,2,3,4,5,6,7,8,9,10,11,12}
	local operate = LzDaer_M_GetPointZuoWei(zuowei)+1
	if operate  ==1 then
	    local jianju_x = 50
	    local jianju_y = 45
	    local adjuscal = 0.02
	    local posTbx = {0,-5,0,-3,0,-2,0,0,0,2,0,4}
        self.m_PutoutNodeTB[zuowei]:setPosition(sys.center.x-jianju_x*3,sys.center.y-40)
        for k,v in pairs(putouttb) do
       	    local jia_x = 0
       	    local a =math.ceil(k/2) 
       	    local b = k%2  
       	    if b==0 then b=2  end
       	    self.m_PutoutShowSpTB[zuowei][k]= DaerPokerClass:Create(self.m_PutoutNodeTB[zuowei],v,"bottom","da",a,nil,0.98+adjuscal*(b-1))
            self.m_PutoutShowSpTB[zuowei][k].m_player:setPosition(jianju_x*(a-1)+posTbx[k],-jianju_y*(b-1))
            --self.m_PutoutShowSpTB[zuowei][k].m_player:setLocalZOrder(20-k)
        end
    elseif  operate  ==3 then
    	local jianju_x =40
	    local jianju_y = 40
	    local adjuscal = 0.02
        self.m_PutoutNodeTB[zuowei]:setPosition(sys.center.x-190-jianju_x,sys.center.y+155)
        local posTbx={0,-2,-3,-4,-5,-4,0,0,0,0,0,2}
        for k,v in pairs(putouttb) do
       	    local jia_x = 0
       	    local a =math.ceil(k/6) 
       	    local b = k%6  
       	    if b==0 then b=6 jia_x=-3 end
       	    --if k==7 then break end
       	    self.m_PutoutShowSpTB[zuowei][k]= DaerPokerClass:Create(self.m_PutoutNodeTB[zuowei],v,"left","da",a,nil,0.76+adjuscal*b)
            self.m_PutoutShowSpTB[zuowei][k].m_player:setPosition(jianju_x*(a-1)-7*(b-1)+posTbx[k]+jia_x,-jianju_y*(b-1))
            --self.m_PutoutShowSpTB[zuowei][k].m_player:setLocalZOrder(20+k)
        end
    elseif operate  ==2 then
    	local jianju_x =40
	    local jianju_y = 40
	    local adjuscal = 0.02
        self.m_PutoutNodeTB[zuowei]:setPosition(sys.center.x+150,sys.center.y+155)
        local posTbx={0,-1,-2,-3,-4,-5,0,0,0,0,0,0}
        for k,v in pairs(putouttb) do
       	    local jia_x = 0
       	    local a =math.ceil(k/6) 
       	    local b = k%6  
       	    if b==0 then b=6   end
       	    self.m_PutoutShowSpTB[zuowei][k]= DaerPokerClass:Create(self.m_PutoutNodeTB[zuowei],v,"right","da",a,nil,0.76+adjuscal*b)
            self.m_PutoutShowSpTB[zuowei][k].m_player:setPosition(jianju_x*(a-1)+7*(b-1)+posTbx[k],-jianju_y*(b-1))
            --self.m_PutoutShowSpTB[zuowei][k].m_player:setLocalZOrder(20-k)
        end
	end
	--self:Action_OutPaiToZhuoMian(1)
end
function HjDaer_Base:Action_OutfuiPai(cPos, cb )
	if self.m_fanPaiClass.m_player  == nil then
		return
	end 
	CCLOG("翻牌消失函数")
	local operate = LzDaer_M_GetPointZuoWei(cPos)+1
    local movePosTb={
      [1]={x = sys.center.x-150,y = sys.center.y-40},
      [2]={x = sys.center.x+150,y = sys.center.y+155},
      [3]={x = sys.center.x-240,y = sys.center.y+155},
    }
	
	local array = {}
	-- array[1] = cc.FadeOut:create(0.2)
	array[1] = cc.Spawn:create(cc.ScaleTo:create(0.2,0.01),cc.FadeOut:create(0.2),cc.MoveTo:create(0.2,{x = movePosTb[operate].x,y = movePosTb[operate].y}))
	array[2] = cc.CallFunc:create(function (  )
			CCLOG("m_CurrUpPaiSp 执行动作 Action_ChiPengPai 完毕 ")
			self:DelFanPaiFun()
			if cb then
				cb()
			end
	end)
	CCLOG("m_CurrUpPaiSp 执行动作 Action_ChiPengPai ")
	self.m_fanPaiClass.m_player:runAction(cc.Sequence:create(array))
end
--到处那张牌
function HjDaer_Base:Action_OutPaiToZhuoMian( zuowei,cb )
	if self.m_PutoutShowSpTB[zuowei]  then 
		local taget = self.m_PutoutShowSpTB[zuowei][#self.m_PutoutShowSpTB[zuowei]]
		if taget.m_player  then 
			local posy = taget.m_player:getPositionY()
			taget.m_player:setPositionY(posy+50)
			local array = {}
			array[1] = cc.MoveBy:create(0.2,{x = 0,y = -50})
			array[2] = cc.CallFunc:create(function (  )
				if cb then
					cb()
				end
			end)
			taget.m_player:runAction(cc.Sequence:create(array))
		end
	end
end
--牌起始位置
function HjDaer_Base:getPokerBeginX(tableCount )
	local beginx=sys.center.x
	local offx = 0
	if self.m_KanTB[self.m_MySeat]  then 
		local kanCount = sys.getTBCount(self.m_KanTB[self.m_MySeat])
		local paiHang =#self.m_ShouPaiClassTb
		if tableCount <8 then 
			offx=-self.DEF_M_POKER_X/2
			if tableCount%2==0 then
				offx=-self.DEF_M_POKER_X/2
			end
		end
	end
	if tableCount%2~=0 then
		beginx=sys.center.x-self.DEF_M_POKER_X/2*(tableCount)-self.DEF_M_POKER_X/2
	else
		beginx=sys.center.x-self.DEF_M_POKER_X/2*(tableCount)-self.DEF_M_POKER_X
	end

	return beginx
end
--得到牌位置
function HjDaer_Base:getPoker( tableCount,index )
	local beginx = self:getPokerBeginX(tableCount)
	return  beginx+self.DEF_M_POKER_X*index
end


--得到指定座位与我的相对座位之差
function LzDaer_M_GetPointZuoWei( zuowei )
	local zw = zuowei - HjDaer_Base.m_MySeat
	if zw < 0 then
		zw = zw + 3
	end 
	return zw
end
--自己
function LzDaer_M_GetMyZuoWei(  )
	return HjDaer_Base.m_MySeat
end
function LzDaer_M_CallCanChuPai(  )
	local isCan =false
	CCLOG("LzDaer_M_CallCanChuPai",HjDaer_Base.m_GameState,"ddf" ,HjDaer_Base.m_isCanChuPai)
	if HjDaer_Base.m_GameState ==emDaEr_GameState_Gaming and HjDaer_Base.m_isCanChuPai==true then 
		isCan =true
    end
    return isCan
end
function LzDaer_M_IsChuPaiOut(  )
	local isChu = true
	for k1,v1 in pairs(HjDaer_Base.m_ShouPaiClassTb) do
		for k1,v2 in pairs(v1) do
			if v2 ~=nil    then
                if v2.m_isInClicke then
                    isChu=false
                end
                if v2.m_isOutChuPai then
                    isChu=false
                end
			end
		end
	end
	return isChu
end
function LzDaer_M_MoveInsertFun( chonsePai)
	CCLOG("LzDaer_M_MoveInsertFun")
	--SHOW(chonsePai) 
	local isSort = false
	local weizhi_x = nil
	local weizhi_y = nil
	local chonsePaiPos = {}
	local m_maxX = 0
	local m_minX = 0
	local m_isMaxY = false
	local delPai =  nil
	local shouPaiCount1=0
	for k1,v1 in pairs(HjDaer_Base.m_ShouPaiClassTb) do
		for k1,v2 in pairs(v1) do
			if v2 ~=nil then
                shouPaiCount1=shouPaiCount1+1
			end
		end
	end
	chonsePaiPos.x= chonsePai.m_player:getPositionX()
	chonsePaiPos.y= chonsePai.m_player:getPositionY()
	local changValue = chonsePai.daer_value
	SHOW(chonsePaiPos)
	m_minX=HjDaer_Base.m_ShouPaiClassTb[1][1].m_offx
	m_maxX=HjDaer_Base.m_ShouPaiClassTb[#HjDaer_Base.m_ShouPaiClassTb][1].m_offx+HjDaer_Base.DEF_M_POKER_X
	if chonsePaiPos.x<=m_minX then 
		CCLOG("左边")
		if #HjDaer_Base.m_ShouPaiClassTb>=10 then  CCLOG("#HjDaer_Base.m_ShouPaiClassTb]>=10") return  isSort end
		for k1,v1 in pairs( HjDaer_Base.m_ShouPaiClassTb) do
				for k2,v2 in pairs(v1) do
					if k1==chonsePai.weizhi_x  and chonsePai.weizhi_y==k2 then 
					  delPai=table.remove(v1,k2)
					end
				end
			end
		SHOW(HjDaer_Base.m_MyShowTB)
		for k,v in pairs( HjDaer_Base.m_ShouPaiClassTb) do
			if #v==0 then
			   CCLOG("HjDaer_Basedel") 
			   table.remove(HjDaer_Base.m_ShouPaiClassTb,k)
			end
		end
		table.insert(HjDaer_Base.m_ShouPaiClassTb,1,{chonsePai})
		SHOW(HjDaer_Base.m_ShouPaiClassTb)
		HjDaer_Base.m_isAction=true
		HjDaer_Base:ChangeSortPoker(true)
		isSort=true
	elseif  chonsePaiPos.x>=m_maxX  then
		 CCLOG("右边边")
		 if #HjDaer_Base.m_ShouPaiClassTb>=10 then CCLOG("#HjDaer_Base.m_ShouPaiClassTb]>=10") return  isSort end
		 for k1,v1 in pairs( HjDaer_Base.m_ShouPaiClassTb) do
			for k2,v2 in pairs(v1) do
				if k1==chonsePai.weizhi_x  and chonsePai.weizhi_y==k2 then 
				   delPai=table.remove(v1,k2)
				end
			end
		end
		--SHOW(HjDaer_Base.m_MyShowTB)
		for k,v in pairs( HjDaer_Base.m_ShouPaiClassTb) do
			if #v==0 then
			   CCLOG("HjDaer_Basedel") 
			   table.remove(HjDaer_Base.m_ShouPaiClassTb,k)
			end
		end
		table.insert(HjDaer_Base.m_ShouPaiClassTb,{chonsePai})
		SHOW(HjDaer_Base.m_ShouPaiClassTb)
		HjDaer_Base.m_isAction=true
		HjDaer_Base:ChangeSortPoker(true)
		isSort=true
	else
		CCLOG("中间")
		--CCLOG("LzDaer_M_MoveInsertFun2",changValue,chonsePai.weizhi_x,chonsePai.weizhi_y )
		for k1,v1 in pairs(HjDaer_Base.m_ShouPaiClassTb) do
			for k2,v2 in pairs(v1) do
				local shuallCount = #v1
				if shuallCount <3  then 
					if k1==chonsePai.weizhi_x and k2 ==chonsePai.weizhi_y   then 
						CCLOG("自己的牌")
					else
						local rect ={}
						rect.x=v2.m_offx
						rect.y=HjDaer_Base.DEF_M_POKER_Y*(k2-1)
						rect.height=HjDaer_Base.DEF_M_POKER_Y

						if k2==1 then 
                           rect.height=HjDaer_Base.DEF_POKER_START_Y--HjDaer_Base.DEF_M_POKER_Y+HjDaer_Base.DEF_POKER_BEGIN_Y
                           rect.y=v2.m_offy
                           --SHOW(rect)
                        else
                           rect.y=HjDaer_Base.DEF_M_POKER_Y*(k2-1)+HjDaer_Base.DEF_POKER_BEGIN_Y
						end
						rect.width =HjDaer_Base.DEF_M_POKER_X
						local iswai = false
						if k2==sys.getTBCount(v1)  then                      
							rect.height=sys.center.y-HjDaer_Base.DEF_M_POKER_Y*(k2-1)
							iswai=true
						end
                        if sys.getTBCount(v1) ==1 then
                            if chonsePaiPos.y> HjDaer_Base.DEF_M_POKER_Y then  
                                CCLOG("=====1")
                                SHOW(rect) 
                                rect.y=0
                            end
                        end
						if cc.rectContainsPoint( rect, chonsePaiPos ) then
						   weizhi_x=k1
						   weizhi_y=k2
							if iswai then 
								
								if chonsePaiPos.y> rect.y+HjDaer_Base.DEF_M_POKER_Y then 
                                   m_isMaxY=true
								end
							end	
						    CCLOG("weizhi_x1",weizhi_x,"weizhi_y",weizhi_y)
						    break 
						end
					end
				else
					if k1 ==chonsePai.weizhi_x and k2 ~=chonsePai.weizhi_y then
                        local rect ={}
						rect.x=v2.m_offx
						rect.y=HjDaer_Base.DEF_M_POKER_Y*(k2-1)
						rect.height=HjDaer_Base.DEF_M_POKER_Y
						if k2==1 then 
                           rect.height=HjDaer_Base.DEF_M_POKER_Y+HjDaer_Base.DEF_POKER_BEGIN_Y
                        else
                           rect.y=HjDaer_Base.DEF_M_POKER_Y*(k2-1)+HjDaer_Base.DEF_POKER_BEGIN_Y
						end
						rect.width =HjDaer_Base.DEF_M_POKER_X
						local iswai = false
						if k2==sys.getTBCount(v1)  then                      
							rect.height=sys.center.y-HjDaer_Base.DEF_M_POKER_Y*(k2-1)
							iswai=true
						end
						if cc.rectContainsPoint( rect, chonsePaiPos ) then
						   weizhi_x=k1
						   weizhi_y=k2
							if iswai then 
								if chonsePaiPos.y> rect.y+HjDaer_Base.DEF_M_POKER_Y then 
                                   m_isMaxY=true
								end
							end
						    CCLOG("weizhi_x",weizhi_x,"weizhi_y",weizhi_y)
						   break 
						end
					end
				end
			end
		end

		if weizhi_x  and  weizhi_y then 
            for k1,v1 in pairs( HjDaer_Base.m_ShouPaiClassTb) do
				for k2,v2 in pairs(v1) do
					if k1==chonsePai.weizhi_x  and chonsePai.weizhi_y==k2 then 
					   delPai= table.remove(v1,k2)
					end
				end
			end
			--CCLOG("xianzhong")
			--SHOW(delPai)
			--SHOW(HjDaer_Base.m_ShouPaiClassTb)
			for k1,v1 in pairs( HjDaer_Base.m_ShouPaiClassTb) do
				for k2,v2 in pairs(v1) do
				    if k1==weizhi_x then 
						  local keyindex=weizhi_y
						  CCLOG("插入",keyindex,m_isMaxY)
						  --if m_isMaxY then keyindex=weizhi_y+1 if keyindex>=3 then keyindex=3 end end
						  if m_isMaxY and weizhi_y==2 then 
                              table.insert(v1,chonsePai)        
						  else
						      table.insert(v1,keyindex,chonsePai)
						  end
						  break
				    end
				end
			end 
			--SHOW(HjDaer_Base.m_ShouPaiClassTb)
			for k,v in pairs( HjDaer_Base.m_ShouPaiClassTb) do
				if #v==0 then
				   CCLOG("HjDaer_Basedel") 
				   table.remove(HjDaer_Base.m_ShouPaiClassTb,k)
				end
			end
			--SHOW(HjDaer_Base.m_ShouPaiClassTb)
			HjDaer_Base.m_isAction=true
			HjDaer_Base:ChangeSortPoker(true)
			isSort=true
		end
	end
	local shouPaiCount2 = 0
	for k1,v1 in pairs(HjDaer_Base.m_ShouPaiClassTb) do
		for k1,v2 in pairs(v1) do
			if v2 ~=nil then
                shouPaiCount2=shouPaiCount2+1
			end
		end
	end
	if shouPaiCount1~=shouPaiCount2 then
	   CCLOG("移动出错")
	   HjDaer_Base:CheckSerCount()
    end
	return isSort
end

---拖失败
function LzDaer_M_MoveLoseCall(  )
	HjDaer_Base:ChangeSortPoker(false)
end
function LzDaer_M_PushReadyBntCallFun(  )
	for i=1,3 do
		LzDaer_M_DelAllDuiSp(i)
	end
	HjDaer_Base:UpdateHuValue(0)
end

---回放UI
function HjDaer_Base:CreHuiFangUIfun(  )
    local StopBtn =nil
    local PlayerBtn=nil
    local Layer=cc.Layer:create()
    self.hf_node:addChild( Layer )
    --遮罩
    local mask=xui.creMaskLy( Layer)

    local startY =sys.center.y-200
    --后退
    local houtuiBtn = MyBtnClass:new("lzde_houtui_zc","lzde_houtui_dj","lzde_houtui_zc",function ( ... )
        self.m_ClikeCount=self.m_ClikeCount- self.m_VideoKHCount
        CCLOG("Push 后退",self.m_ClikeCount)
        self.m_VideoActiom=true
    end)
    Layer:addChild(houtuiBtn.btnLy)
    houtuiBtn.btnLy:setPosition(sys.center.x-270,startY)

    local  function PlayerBtnCall( state )
        CCLOG("PlayerBtnCall",state)
        if state ==2 then
            if StopBtn then
                StopBtn.SetMyBtnVisible(true)
            end
            if PlayerBtn then
                PlayerBtn.SetMyBtnVisible(false)
            end
        else
            if StopBtn then
                StopBtn.SetMyBtnVisible(false)
            end
            if PlayerBtn then
                PlayerBtn.SetMyBtnVisible(true)
            end
        end
    end
    --重播
    local rePlayerBtn = MyBtnClass:new("lzde_replay_zc","lzde_replay_dj","lzde_replay_zc",function ( ... )
        self.m_videoStepIndex=1
        self.m_VideoActiom=true
        PlayerBtnCall(2)
        CCLOG("重播")
        self:cleanVideoUI()
    end)
    Layer:addChild(rePlayerBtn.btnLy)
    rePlayerBtn.btnLy:setPosition(sys.center.x-455,startY)
    PlayerBtn = MyBtnClass:new("lzde_play_zc","lzde_play_dj","lzde_play_zc",function ( ... )
        PlayerBtnCall(2)      
        self:PausePlayer()

    end)
    Layer:addChild(PlayerBtn.btnLy)
    --播放
    PlayerBtn.btnLy:setPosition(sys.center.x-90,startY-30)
    PlayerBtn.SetMyBtnVisible(false)

    --停止
    StopBtn = MyBtnClass:new("lzde_zanting_zc","lzde_zanting_dj","lzde_zanting_zc",function ( ... )
        PlayerBtnCall(1) 
        self:PauseStop()
    end)
    Layer:addChild(StopBtn.btnLy)
    StopBtn.btnLy:setPosition(sys.center.x-90,startY-30)
    --快进
    local  KuaijinBtn = MyBtnClass:new("lzde_kuaijin_zc","lzde_kuaijin_dj","lzde_kuaijin_zc",function (  )
        self.m_ClikeCount=self.m_ClikeCount+self.m_VideoKHCount
        self.m_VideoActiom=true   
        CCLOG("快进",self.m_videoStepIndex)
    end)
    Layer:addChild(KuaijinBtn.btnLy)
    KuaijinBtn.btnLy:setPosition(sys.center.x+145,startY)
   
    self:SetMaxStepFun(  )
    --创建头像
    self:CreHuiFangHead()
    --监听
    self:HunFangListener()

    local balanceTB = {}
    if self.m_VideoInfo.js and self.m_VideoInfo.js  then 
        balanceTB.jiesuan=self.m_VideoInfo.js
    end
    CCLOG("CreHuiFangUIfun")
    SHOW(self.m_playerInfo)
    balanceTB.player=self.m_playerInfo
    self.m_VideoJieSuanBtn=MyBtnClass:new("xxqp_js_xq_zc","xxqp_js_xq_dj","xxqp_js_xq_zc",function ( ... )
        LzDaer_M_CreResultUI(self.m_BaseNode,self.m_Scene,balanceTB)
        self.m_VideoJieSuanBtn.SetMyBtnVisible(false)
    end)
    Layer:addChild(self.m_VideoJieSuanBtn.btnLy,12)
    self.m_VideoJieSuanBtn.btnLy:setPosition(sys.center.x-105,sys.center.y)
   	self.m_VideoJieSuanBtn.SetMyBtnVisible(false)
end
--暂停
function  HjDaer_Base:PauseStop()
    CCLOG("Push 暂停")
    self.pauseActions =   CCDirector:getInstance():getActionManager():pauseAllRunningActions()
end
--播放
function  HjDaer_Base:PausePlayer()
    CCLOG("Push 播放")
    if  self.pauseActions ~= nil then
        CCDirector:getInstance():getActionManager():resumeTargets(self.pauseActions)
        self.pauseActions=nil
    end
end

---回放init
function HjDaer_Base:VideoInit(  )
   CCLOG("会放 VideoInit")
   self.m_VideoInfo={}
  -- self.m_VideoTimeNode         =nil
   self.m_videoStepIndex        =1             --步骤
   self.MaxSetpCount            =1             --最大步骤
   self.m_videoShoPaiTb         ={}
   self.m_VideoListenerTime     =0.1
   self.m_ClikeCount            =0
   self.m_VideoKHCount          =2            --快进步骤
   self.m_playerInfo            ={}
   self.m_VideoActiom           =true         --是否会掉
   self.pauseActions            =nil          --暂停
   self.m_OtherPokerNodeTb      ={}
   self.m_OtherPokerTb          ={{},{},{}}
   self.m_Cliper                ={}

end
--时间
function HjDaer_Base:DelayTimeFun(callCb,time)
    local array={}
    array[1]=CCDelayTime:create(time or 1)
    array[2]=CCCallFunc:create(function (  )
        if callCb then
            callCb()
        end
      end)
    self.m_VideoTimeNode:runAction(CCSequence:create(array))
end
--回放放回
function HjDaer_Base:GoBallFun(  )
    CCLOG("回放放回")
    self:DelTimeHunFang()
    self:GoOnInfo()
end
--设置最大步骤
function HjDaer_Base:SetMaxStepFun(  )
    self.MaxSetpCount=sys.getTBCount(self.m_VideoInfo.gamedata.op)+1
    CCLOG("设置最大步骤",self.MaxSetpCount)
    self.m_ZhuangZuoWei = 1
    if self.m_VideoInfo.gamedata.zhuang  then
       self.m_ZhuangZuoWei=self.m_VideoInfo.gamedata.zhuang
    end
    for k,v in pairs(self.m_VideoInfo.gamedata.card) do
         self.m_videoShoPaiTb[k] =v
    end
end

---每部数据
function HjDaer_Base:FindPerStepDate( )
    local m_OperteTb ={}
    local m_OperteDateTb={}
    if self.m_videoStepIndex>1 then
        local keyIndex = self.m_videoStepIndex-1
        m_OperteTb = self.m_VideoInfo.gamedata.op
        m_OperteDateTb=self:GetOperteDate(m_OperteTb,keyIndex)
    end
    return  m_OperteDateTb
end
--得到操纵数据
function HjDaer_Base:GetOperteDate( data,index )
	CCLOG("GetOperteDate","index",index)
    local InitShouTb = {}
    InitShouTb.shoupaiTb={}
    for i=1,3 do
        InitShouTb.shoupaiTb[i]=sys.copyTab(self.m_VideoInfo.gamedata.card[i])
    end
    InitShouTb.Operate={}
    if data[index]  then
       InitShouTb.Operate=data[index]
    end
    --SHOW(InitShouTb)
    InitShouTb.kantb ={{},{},{}}
    InitShouTb.feitb ={{},{},{}}
    InitShouTb.leftpai=20
    for k,v in pairs(data) do
    	if v.o and k<=index then
    		local zuowei =v.s
    		local operateSeat = LzDaer_M_GetPointZuoWei(zuowei)+1
            if v.o==emDaErHisOp_FanPai then
               InitShouTb.leftpai=InitShouTb.leftpai-1
            end
            if v.o== emDaErHisOp_MoPai  then
               InitShouTb.leftpai=InitShouTb.leftpai-1
               local changValue=v.v
               table.insert(InitShouTb.shoupaiTb[zuowei],changValue)
               CCLOG("摸牌action")
            end
            if v.o ==emDaErHisOp_ChiPai  then
            	--吃
                if v.v1 then
                    for k1,v1 in pairs(InitShouTb.shoupaiTb[zuowei]) do
                  	    if v.v1 ==v1 then
                  	    	table.remove(InitShouTb.shoupaiTb[zuowei],k1)
                  	    	break
                  	    end
                    end
                end
                if v.v2 then
                    for k1,v1 in pairs(InitShouTb.shoupaiTb[zuowei]) do
                  	    if v.v2 ==v1 then
                  	    	table.remove(InitShouTb.shoupaiTb[zuowei],k1)
                  	    	break
                  	    end
                    end
                end
                table.insert(InitShouTb.kantb[zuowei],{v.v1,v.v2,v.v,["ty"]="chi"})
                --比
                if v.c1 and v.c1>0 then
                    for k1,v1 in pairs(InitShouTb.shoupaiTb[zuowei]) do
                  	    if v.c1==v1 then
                  	    	table.remove(InitShouTb.shoupaiTb[zuowei],k1)
                  	    	break
                  	    end
                    end
                    for k1,v1 in pairs(InitShouTb.shoupaiTb[zuowei]) do
                  	    if v.c2 ==v1 then
                  	    	table.remove(InitShouTb.shoupaiTb[zuowei],k1)
                  	    	break
                  	    end
                    end
                    for k1,v1 in pairs(InitShouTb.shoupaiTb[zuowei]) do
                  	    if v.v ==v1 then
                  	    	table.remove(InitShouTb.shoupaiTb[zuowei],k1)
                  	    	break
                  	    end
                    end
                    table.insert(InitShouTb.kantb[zuowei],{v.c1,v.c2,v.v,["ty"]="chi"})
                end
            end
            if v.o ==emDaErHisOp_LongPai  then
            	local long=v.v
            	--long[1]=v.v
                --for k2,v2 in pairs(long) do
                	for i=1,4 do
                		for k1,v1 in pairs(InitShouTb.shoupaiTb[zuowei]) do
	                  	    if v2 ==long then
	                  	    	table.remove(InitShouTb.shoupaiTb[zuowei],k1)
	                  	    end
	                    end
                	end
                	table.insert(InitShouTb.kantb[zuowei],{long,long,long,["ty"]="long"})
                --end
            end
            if v.o ==emDaErHisOp_ZhaoPai  then
            	for i=1,3 do
            		for k1,v1 in pairs(InitShouTb.shoupaiTb[zuowei]) do
                  	    if v.v ==v1 then
                  	    	table.remove(InitShouTb.shoupaiTb[zuowei],k1)
                  	    end
                    end
            	end
            	table.insert(InitShouTb.kantb[zuowei],{v.v,v.v,v.v,["ty"]="zhao"})
            end
            if v.o ==emDaErHisOp_PengPai  then
            	for i=1,2 do
            		for k1,v1 in pairs(InitShouTb.shoupaiTb[zuowei]) do
                  	    if v.v ==v1 then
                  	    	table.remove(InitShouTb.shoupaiTb[zuowei],k1)
                  	    end
                    end
            	end
            	table.insert(InitShouTb.kantb[zuowei],{v.v,v.v,v.v,["ty"]="peng"})
            end
            if v.o ==emDaErHisOp_ChuPai  then
        		for k1,v1 in pairs(InitShouTb.shoupaiTb[zuowei]) do
              	    if v.v ==v1 then
              	    	table.remove(InitShouTb.shoupaiTb[zuowei],k1)
              	    	break
              	    end
                end
            end
            if v.o ==emDaErHisOp_Qi  then
                table.insert(InitShouTb.feitb[zuowei],v.v)
            end
   	    end
    end
    return  InitShouTb
end
--删定时器
function HjDaer_Base:DelTimeHunFang(  )
    if self.m_hunFangTime then
        CCDirector:getInstance():getScheduler():unscheduleScriptEntry( self.m_hunFangTime )
        self.m_hunFangTime = nil
    end
end
--回放监听 
function HjDaer_Base:HunFangListener(  )
    self:DelTimeHunFang()
    local update = function()
       self:PlayIngPerStep()
    end
    self.m_hunFangTime=CCDirector:getInstance():getScheduler():scheduleScriptFunc(update, self.m_VideoListenerTime,false)
end
---清理界面
function HjDaer_Base:cleanVideoUI(  )
	self:DelFanPaiFun()
	self.m_VideoTimeNode:stopAllActions()
    self.m_BaseNode:stopAllActions()
    self.m_otherPaiNode:stopAllActions()
    self.shou_pokernode:stopAllActions()
    self.act_node:stopAllActions()
    self.act_node:removeAllChildren(true)
	self:Video_UpdateCoin(false)
	self.m_VideoJieSuanBtn.SetMyBtnVisible(false)
    self:cleanGameData()
    self.m_otherPaiNode:removeAllChildren(true)
    self.m_OtherPokerNodeTb      ={}
    self.m_OtherPokerTb          ={{},{},{}}
    self.m_videoShoPaiTb         = {}
    self.m_Cliper                ={}
    LzDaer_M_CloseResultUI()
    self:Video_UpdateCoin(false)
end
--播放每一步
function HjDaer_Base:PlayIngPerStep(  )
    --CCLOG("PlayIngPerStep",self.m_videoStepIndex,self.m_VideoActiom)
    if  self.m_VideoActiom ==false  then  CCLOG("self.m_VideoActiom is false") return end
    --初始化
    local m_isKuaiOrTui = false
    --CCLOG("self.m_ClikeCount",self.m_ClikeCount)
    self.m_videoStepIndex=self.m_ClikeCount+self.m_videoStepIndex
    if self.m_videoStepIndex<1 then self.m_videoStepIndex=1 end
    if self.m_videoStepIndex>self.MaxSetpCount   then  
        if self.m_ClikeCount ~=0 then       
            self.m_videoStepIndex=self.MaxSetpCount 
        else
        	self.m_VideoJieSuanBtn.SetMyBtnVisible(true)
            self:Video_UpdateCoin(true)
            self.m_VideoActiom =false
            CCLOG("播完了",self.m_videoStepIndex)
            return  
        end
    end
    self:GoOnInfo()
    if self.m_ClikeCount ~=0 then 
    	m_isKuaiOrTui=true
        self:cleanVideoUI()
        self.m_ClikeCount =0
    end
    --发牌
    if self.m_videoStepIndex==1 then
    	self.m_VideoActiom =false
	    for k,v in pairs(self.m_VideoInfo.gamedata.card) do
	        self.m_videoShoPaiTb[k] =sys.copyTab(v)
	    end
    	self:Video_FaPai()
    end
    if self.m_videoStepIndex>1 then
        self:PlayerOperateFun(m_isKuaiOrTui)
    end  
end
--回放创建touxiang
function HjDaer_Base:CreHuiFangHead( )
    if  self.m_VideoInfo.pl  then
        for k,v in pairs(self.m_VideoInfo.pl) do
            if v.id and self.m_MyInfo.playerid ==v.id then
                self.m_MySeat = v.st
                CCLOG("CreHuiFangHead ",self.MyZuoWeiPos)
            end
        end
        local sc_info = {}
        sc_info.playerlist={}
        for k,v in pairs(self.m_VideoInfo.pl ) do
            if v.st  then
                local info = {}
                info.seat=v.st
                info.coin=0  --v.c
                info.nickname=v.nk
                info.sex= v.sx  or 0
                info.playerid=v.id
                info.clientip =v.ip
                info.headurl =v.hd
                info.areaid  =Pt_GetMyCurAreaIdx()
                table.insert(sc_info.playerlist,info)
            end
        end
        self.m_playerInfo=sc_info.playerlist
        LzDaer_M_CreTouXiang( self.head_node, sc_info )
        local m_TouXiangLayerTB = LzDaer_M_GetTouXiangLayer()
	    if m_TouXiangLayerTB[self.m_ZhuangZuoWei].ZhuangSp then 
	       m_TouXiangLayerTB[self.m_ZhuangZuoWei].ZhuangSp:setVisible(true)
	    end
    end
    if self.m_VideoInfo.gamedata.baohu  then
        for k,v in pairs(self.m_VideoInfo.gamedata.baohu ) do
        	if v==1 then
                LzDaer_M_CreBaojiaoSp(k,v)
            end
        end
    end
end
--回放发牌
function HjDaer_Base:Video_FaPai(  )
    local s ={}
    s.zhuang=self.m_ZhuangZuoWei or self.m_MySeat
    self:SC_DAER_FAPAI("nil",s)
end
--video 闯将其他手牌
function HjDaer_Base:CreOtherPoker( zuowei,count )
    if   self.m_OtherPokerNodeTb[zuowei]  then
    	 self.m_OtherPokerNodeTb[zuowei]:removeFromParent(true)
    	 self.m_OtherPokerNodeTb[zuowei]=nil
    	 self.m_OtherPokerTb[zuowei]={}
    	 self.m_Cliper[zuowei]      =nil
    end
    self.m_OtherPokerNodeTb[zuowei]=cc.Node:create()
    self.m_otherPaiNode:addChild( self.m_OtherPokerNodeTb[zuowei])
    local operateSeat = LzDaer_M_GetPointZuoWei(zuowei)+1
    local pokerCount =  20
    local pokerTb ={} 
    local startY = sys.center.y
    local startX = sys.center.x
    local jianjuY = 30
    if operateSeat ==2 then
        pokerTb=self.m_videoShoPaiTb[zuowei]
        startX=sys.width-400+95
    end
    if operateSeat ==3 then
        pokerTb=self.m_videoShoPaiTb[zuowei]
        startX=0-95
    end
    table.sort(pokerTb,function ( a,b )
        
    	return a<b
    end)
    CCLOG("YbYdr_M_CreOtherPoker----",operateSeat,startX)
    startY=sys.center.y+sys.getTBCount(pokerTb)*jianjuY/2-270
    local BRNN_VIEW_WITH  =sys.width
    local BRNN_VIEW_HEIGHT =sys.height
    local stencilSize = {}
    stencilSize[1]={x=0,y=0}
    stencilSize[2]={x=BRNN_VIEW_WITH,y=0}       
    stencilSize[3]={x=BRNN_VIEW_WITH,y=BRNN_VIEW_HEIGHT}
    stencilSize[4]={x=0,y=BRNN_VIEW_HEIGHT}
    self.m_Cliper[zuowei] = xui.addClipNode( self.m_OtherPokerNodeTb[zuowei], stencilSize,0,60, BRNN_VIEW_WITH, BRNN_VIEW_HEIGHT, sys.ap.leftBottom)

    for k,v in pairs(pokerTb) do
        local changpai =  DaerPokerClass:Create( self.m_Cliper[zuowei],v,"bottom","shou")
		--self.m_fanPaiClass.m_player:setScale(DEF_POKER_SCALE)
		changpai.m_player:setAnchorPoint(sys.ap.centerBottom)
		changpai.m_player:setPosition(200+startX,startY-jianjuY*k)
		changpai.m_player:setScale(0.65)
        table.insert( self.m_OtherPokerTb[zuowei],changpai)
		if count==k then break end
    end
end
--操作
function HjDaer_Base:PlayerOperateFun( m_isKuaiOrTui )
	CCLOG("是否快进",m_isKuaiOrTui)
    local m_OperteTb= self:FindPerStepDate()
    self.m_VideoActiom=false
    if m_isKuaiOrTui then
        self.m_videoShoPaiTb=sys.copyTab(m_OperteTb.shoupaiTb)
        self.m_MyShouPaiTB=sys.copyTab(m_OperteTb.shoupaiTb[self.m_MySeat])
        self.m_KanTB=sys.copyTab(m_OperteTb.kantb)
        self.m_PutoutTB=sys.copyTab(m_OperteTb.feitb)
        self:ZhanKaiMyShouPai()
        for i=1,3 do
        	if i~=self.m_MySeat then
        		self:CreOtherPoker(i,21)
        	end
        	self:UpdateKan(i,"duanxian")
        	self:UpdatePutount(i,"duanxian")
        end
		self.m_ResiduePaiNum =m_OperteTb.leftpai
		self:UpdateResiduePai()
        for i=1,self.m_ResiduePaiNum do
        	self.m_PaiDuiTB[i] =  xui.addSprite(self.m_gameNode,"lzde_zjpd",sys.center.x,sys.center.y+140+i*2,5)     
        end
        self.m_videoStepIndex=self.m_videoStepIndex+1
        self.m_VideoActiom=true
        --SHOW(m_OperteTb)
        return 
    end
    
    if m_OperteTb.Operate.o==emDaErHisOp_FanPai then
        CCLOG("video -----翻公用牌")
        self:Video_Fan(m_OperteTb.Operate)
    elseif m_OperteTb.Operate.o==emDaErHisOp_MoPai then
	    CCLOG("video -----玩家摸牌")
	    self:Video_Mopai(m_OperteTb.Operate)
	elseif m_OperteTb.Operate.o==emDaErHisOp_ChiPai then
	    CCLOG("video -----吃牌")
	    self:Video_CHI(m_OperteTb.Operate)
	elseif m_OperteTb.Operate.o==emDaErHisOp_LongPai then
	    CCLOG("video -----拢牌")
	      self:Video_Long(m_OperteTb.Operate)
	elseif m_OperteTb.Operate.o==emDaErHisOp_ZhaoPai then
		CCLOG("video -----招牌")
	    self:Video_Zhao(m_OperteTb.Operate)
	elseif m_OperteTb.Operate.o==emDaErHisOp_PengPai then
		CCLOG("video -----碰牌")
	    self:Video_Peng(m_OperteTb.Operate)
	elseif m_OperteTb.Operate.o==emDaErHisOp_ChuPai then
		CCLOG("video -----出牌")
		self:Video_Chu(m_OperteTb.Operate)
	elseif m_OperteTb.Operate.o==emDaErHisOp_Hu then
	    CCLOG("video -----胡牌")
	    self:Video_Hu(m_OperteTb.Operate)
    elseif m_OperteTb.Operate.o==emDaErHisOp_Qi then
	    CCLOG("video -----弃牌")
	    self:Video_Qi(m_OperteTb.Operate)
	else
		CCLOG("video------没有操作")
    end
end
--摸牌
function HjDaer_Base:Video_Mopai( OperteTb )
	SHOW(OperteTb)
	CCLOG("Video_Mopai")
	CCLOG("Video_Chu---1")
	local zuowei =OperteTb.s
	local changValue = OperteTb.v
	local daseat = LzDaer_M_GetPointZuoWei(zuowei)+1
	if zuowei ==self.m_MySeat then
	    self:MoYiPai(zuowei,changValue,function (  )
	    	self.m_videoStepIndex=self.m_videoStepIndex+1
            self.m_VideoActiom=true
	    end)
	else
        self:FanYiPai(zuowei,changValue,"mopai",function (  )
        	table.insert(self.m_videoShoPaiTb[zuowei],changValue)
        	self:CreOtherPoker(zuowei,33)
            self.m_videoStepIndex=self.m_videoStepIndex+1
            self.m_VideoActiom=true
        end)
	end
	self.m_ResiduePaiNum =self.m_ResiduePaiNum -1
	self:UpdateResiduePai()
	-- self:DelayTimeFun(function (  )
	-- 	self.m_videoStepIndex=self.m_videoStepIndex+1
 --        self.m_VideoActiom=true
	-- end,1.5)
end
function HjDaer_Base:Video_Chu( OperteTb)
	CCLOG("Video_Chu---1")
	local zuowei = OperteTb.s
	local changValue = OperteTb.v
	local delPai =nil
	local daseat = LzDaer_M_GetPointZuoWei(zuowei)+1
	if daseat==1 then
		CCLOG("Video_Chu---2")
		--SHOW(self.m_ShouPaiClassTb)
        for k1,v1 in pairs(self.m_ShouPaiClassTb) do
        	local flag =false
   	   	    for k2,v2 in pairs(v1) do
   	   	   	    if v2.daer_value ==changValue  then
   	   	   	   	    if v2.m_player then  	  	    
   	   	   	   	  	    delPai= table.remove(v1,k2)
   	   	   	   	  	    flag =true
   	   	   	   	  	    break
   	   	   	   	    end   
   	   	   	    end
   	   	    end
   	   	    if flag then break end
   	    end
	else
		CCLOG("Video_Chu---3")
        for k,v in pairs(self.m_OtherPokerTb[zuowei] or {}) do
        	if v.m_player and  v.daer_value ==changValue then
                delPai= table.remove(self.m_OtherPokerTb[zuowei],k)
                break
        	end
        end
	end
	SHOW(delPai)
	CCLOG("Video_Chu---4")
	if delPai and delPai.m_player then
		CCLOG("Video_Chu---5")
		self:DelFanPaiFun()
		self.m_fanPaiClass =delPai
		delPai.m_player:setLocalZOrder(100)
		local weizhi_y = (20-sys.getTBCount(self.m_OtherPokerTb[zuowei]))*15+40
		local time =0.2
		local array = {}
		array[1]= cc.Spawn:create(cc.MoveTo:create(time,{x = self.DEF_CHUPAI_POS[daseat].x,y =self.DEF_CHUPAI_POS[daseat].y-weizhi_y}),cc.ScaleTo:create(time,DEF_POKER_SCALE))
		array[2]=cc.CallFunc:create(function (  )
	       self.m_videoStepIndex=self.m_videoStepIndex+1
           self.m_VideoActiom=true
           self:Video_SortPai(zuowei)
		end)
		delPai.m_player:runAction(cc.Sequence:create(array))
	end
	
end
---重新整理牌
function HjDaer_Base:Video_SortPai( zuowei )
	CCLOG("Video_SortPai",zuowei)
    local operateSeat = LzDaer_M_GetPointZuoWei(zuowei)+1
    local startY = sys.center.y
    local startX = sys.center.x
    local jianjuY = 30
    if operateSeat ==2 then
        startX=sys.width-400+95
    end
    if operateSeat ==3 then
        startX=0-95
    end
	if operateSeat ==1 then
		self:CleanPokerTbFun()
        self:ChangeSortPoker(true)
	else
        local PaiCount =sys.getTBCount(self.m_OtherPokerTb[zuowei])
		startY=sys.center.y+(PaiCount)*jianjuY/2-270
		if self.m_Cliper[zuowei]   then
	       local delCount = 20-PaiCount
	       self.m_Cliper[zuowei]:setPositionY(60+delCount*jianjuY/2-20)
		end
		local count = 0
        for k,v in pairs(self.m_OtherPokerTb[zuowei] or {}) do
        	if v.m_player  then
        	   count=count+1
               local array = {}
               array[1]=cc.MoveTo:create(0.1,{x=200+startX,y=startY-jianjuY*k})
               v.m_player:runAction(cc.Sequence:create(array))
        	end
        end
	end
	
	CCLOG("Video_SortPai is end")
end
function HjDaer_Base:Video_Fan( OperteTb )
	local s = {}
	s.seat=OperteTb.s
	s.pai =OperteTb.v 
	s.leftpai=self.m_ResiduePaiNum -1
	self:SC_DAER_FANPAI("nil",s)
	self:DelayTimeFun(function (  )
		self.m_videoStepIndex=self.m_videoStepIndex+1
        self.m_VideoActiom=true
	end,1.5)
end
function HjDaer_Base:Video_CHI(OperteTb )
	local s = {}
	s.seat=OperteTb.s
	s.chi={}
	s.chi.o1=OperteTb.v1  
	s.chi.o2=OperteTb.v2 
	s.chi.pai=OperteTb.v 
	if  OperteTb.c1 and OperteTb.c1>0 then
       s.bi={}
       s.bi.o1=OperteTb.c1  
	   s.bi.o2=OperteTb.c2 
	   s.bi.pai=OperteTb.v 
	end
	self:Operate_UI("chi",s)

	self:DelayTimeFun(function (  )
		self.m_videoStepIndex=self.m_videoStepIndex+1
        self.m_VideoActiom=true
	end,1.5)
end
function HjDaer_Base:Video_Long( OperteTb )
	local s = {}
	s.seat=OperteTb.s
	s.long=OperteTb.v
	--s.long[1]=OperteTb.v 
	SHOW(s)
	self:Operate_UI("long",s)

	self:DelayTimeFun(function (  )
		self.m_videoStepIndex=self.m_videoStepIndex+1
        self.m_VideoActiom=true
	end,1.5)
end
function HjDaer_Base:Video_Zhao( OperteTb )
	local s = {}
	s.seat=OperteTb.s
	s.value =OperteTb.v 
	self:Operate_UI("zhao",s)
	self:DelayTimeFun(function (  )
		self.m_videoStepIndex=self.m_videoStepIndex+1
        self.m_VideoActiom=true
	end,1.5)
end
function HjDaer_Base:Video_Peng( OperteTb )
	local s = {}
	s.seat=OperteTb.s
	s.value =OperteTb.v 
	self:Operate_UI("peng",s)
	self:DelayTimeFun(function (  )
		self.m_videoStepIndex=self.m_videoStepIndex+1
        self.m_VideoActiom=true
	end,1.5)
end

function HjDaer_Base:Video_Qi( OperteTb )
	local s = {}
	s.seat=OperteTb.s
	s.value =OperteTb.v 
	self:SC_DAER_PAIDUI("nil",s)
    self:DelayTimeFun(function (  )
		self.m_videoStepIndex=self.m_videoStepIndex+1
        self.m_VideoActiom=true
	end,1.5)
end
--video 胡
function HjDaer_Base:Video_Hu( OperteTb)
	CCLOG("Video_HuVideo_HuVideo_HuVideo_Hu")
	local zuowei = OperteTb.s
	local operate = LzDaer_M_GetPointZuoWei(zuowei)+1
	local hutype =OperteTb.h  or 0
    local m_TouXiangLayerTB = LzDaer_M_GetTouXiangLayer()
    if hutype==1 then
       LzDaer_Public_PlaySound("zimo",m_TouXiangLayerTB[zuowei].xingbie)
    elseif hutype ==2 then
        LzDaer_Public_PlaySound("hu",m_TouXiangLayerTB[zuowei].xingbie)
    elseif hutype ==3 then
        LzDaer_Public_PlaySound("baile",m_TouXiangLayerTB[zuowei].xingbie)
    end
   	local operate = LzDaer_M_GetPointZuoWei(zuowei)+1
	LzDaerAniamtions.HuAni(self.act_node,self.DEF_ANI_POS[operate].x,self.DEF_ANI_POS[operate].y,function (  )
	end)
	self.m_VideoJieSuanBtn.SetMyBtnVisible(true)
	self:Video_UpdateCoin(true)
end
--video 金币
function HjDaer_Base:Video_UpdateCoin(isShow)
    local m_TouXiangLayerTB = LzDaer_M_GetTouXiangLayer()  or {}
    for k,v in pairs(self.m_VideoInfo.pl) do
        if v.st then 
            if m_TouXiangLayerTB[v.st]  then 
                if isShow then
                   m_TouXiangLayerTB[v.st]:UpDateJiaQian(v.c)
                else
                   m_TouXiangLayerTB[v.st]:UpDateJiaQian(0)
                end
            end
        end
    end
end


function HjDaer_Base:Test_YbYdr1( ... )
end
function HjDaer_Base:testjues( ... )

end