
function LzDaer_Public_ActionSound( ac )
    local voice,effect = Pt_GetSoundInfo()
    if effect == 0 then
        return
    end 
    if ac=="xipai"  then
       sys.playSound(LzDaer_publicaudioRes.sound.xipai)
    end
    if ac=="fapai"  then
       sys.playSound(LzDaer_publicaudioRes.sound.fapai)
    end
    if ac=="guopai"  then
       sys.playSound(LzDaer_publicaudioRes.sound.guopai)
    end
    if ac=="qipai"  then
       sys.playSound(LzDaer_publicaudioRes.sound.qipai)
    end
end
function LzDaer_Public_PlaySound( chatc,xingbie,daer_value)
    local voice,effect = Pt_GetSoundInfo()
    if effect == 0 then
        return
    end
    CCLOG("LzDaer_Public_PlaySound",chatc,xingbie)
    local tabnumlab = ""
    if xingbie == emSex_Boy then
        tabnumlab = "boy"
    end
    if xingbie == emSex_Girl then
        tabnumlab = "girl"
    end
    if tabnumlab ~= "" then
        if chatc  =="poker"  then
            CCLOG("daer_value",daer_value)
            sys.playSound(LzDaer_publicaudioRes.sound[tabnumlab][tostring("poker_"..daer_value)])
        end
        if chatc  =="baile"  then
            sys.playSound(LzDaer_publicaudioRes.sound[tabnumlab]["poker_baile"])
        end
        if chatc  =="baole"  then
            sys.playSound(LzDaer_publicaudioRes.sound[tabnumlab]["poker_baole"])
        end
        if chatc  =="chi"  then
            sys.playSound(LzDaer_publicaudioRes.sound[tabnumlab]["poker_chi"])
        end
        if chatc  =="haidi"  then
            sys.playSound(LzDaer_publicaudioRes.sound[tabnumlab]["poker_haidi"])
        end
        if chatc  =="hu"  then
            sys.playSound(LzDaer_publicaudioRes.sound[tabnumlab]["poker_hu"])
        end
        if chatc  =="long"  then
            sys.playSound(LzDaer_publicaudioRes.sound[tabnumlab]["poker_long"])
        end
        if chatc  =="peng"  then
            sys.playSound(LzDaer_publicaudioRes.sound[tabnumlab]["poker_peng"])
        end
        if chatc  =="shuishangpiao"  then
            sys.playSound(LzDaer_publicaudioRes.sound[tabnumlab]["poker_shuishangpiao"])
        end        
        if chatc  =="tianhu"  then
            sys.playSound(LzDaer_publicaudioRes.sound[tabnumlab]["poker_tianhu"])
        end
        if chatc  =="zhao"  then
            sys.playSound(LzDaer_publicaudioRes.sound[tabnumlab]["poker_zhao"])
        end
        if chatc  =="zimo"  then
            sys.playSound(LzDaer_publicaudioRes.sound[tabnumlab]["poker_zimo"])
        end       
    end
end
-- function LzDaer_Public_PlayerTalk( chatc,xingbie)
--     CCLOG("LzDaer_Public_PlayerTalk",chatc)
--     local voice,effect = Pt_GetSoundInfo()
--     if effect == 0 then
--         return
--     end
--     local tabnumlab = ""
--     if xingbie == emSex_Boy then
--         tabnumlab = "boy"
--     end
--     if xingbie == emSex_Girl then
--         tabnumlab = "girl"
--     end    
--     if tabnumlab ~= "" then
       
--     end 
-- end
function LzDaer_Public_SortFun(pokerTB )
    local pokersortTB = {}
    for i=1,10 do
        local daer_value=i
        if i ==10 then daer_value=0 end
        for k,v in pairs(pokerTB) do
            if  v[1]["daer_value"]%10==daer_value then
                table.insert(pokersortTB,v)
            end
        end
    end
    return  pokersortTB
end
--组合牌
function LzDaer_M_ZuhePokerTb( handPaiTB )
   local  paizuTb = {}
   for k,v in pairs(handPaiTB) do
       local paiTb = {}
       paiTb.daer_value =v
       paiTb.m_used     =false
       table.insert(paizuTb,paiTb)    
   end
   return paizuTb
end
--结算组合tb
function LzDaer_M_JieSuanPokerTb( pokerTB )
    local paizuTb = {}
    local thePos = 0
    local handPaiTB =LzDaer_M_ZuhePokerTb(pokerTB)
    local firstSearchTB = {}  
    for i=1,20 do
        firstSearchTB[i] = 0
        for k,v in pairs(handPaiTB) do
            if v.daer_value == i then
                firstSearchTB[i] = firstSearchTB[i]+1
            end
        end
    end
    --找一拢一坎
    for k,v in pairs(firstSearchTB) do
        if v==4  or v==3 then
            thePos=thePos+1
            paizuTb[thePos]={}
            local count = 0
            for k1,v1 in pairs(handPaiTB) do
                if v1.daer_value==k and v1.m_used==false then
                   v1.m_used=true
                   table.insert( paizuTb[thePos],v1)
                   count=count+1
                   if count==3 then break end
                end
            end
        end
    end
     --找2 7 10
    for k1,v1 in pairs(handPaiTB) do
        for k2,v2 in pairs(handPaiTB) do
           for k3,v3 in pairs(handPaiTB) do
                if v1.daer_value ==2 and v1.m_used==false and v2.daer_value ==7 and v2.m_used==false and  v3.daer_value ==10 and v3.m_used==false then
                    thePos=thePos+1
                    v1.m_used=true
                    v2.m_used=true
                    v3.m_used=true
                    paizuTb[thePos]={v1,v2,v3} 
                end
                 if v1.daer_value ==12 and v1.m_used==false and v2.daer_value ==17 and v2.m_used==false and  v3.daer_value ==20 and v3.m_used==false then
                    thePos=thePos+1
                    v1.m_used=true
                    v2.m_used=true
                    v3.m_used=true
                    paizuTb[thePos]={v1,v2,v3} 
                end
           end
        end
    end
    --找顺子3张
    for i=1,20 do
        if i==1 or i==11 then 
            for k1,v1 in pairs(handPaiTB) do
                for k2,v2 in pairs(handPaiTB) do
                   for k3,v3 in pairs(handPaiTB) do
                        if v1.daer_value ==i and v1.m_used==false and v2.daer_value ==i+1 and v2.m_used==false and  v3.daer_value ==i+2 and v3.m_used==false then
                            thePos=thePos+1
                            v1.m_used=true
                            v2.m_used=true
                            v3.m_used=true
                            paizuTb[thePos]={v1,v2,v3} 
                        end     
                   end
                end
            end
        end
    end
    --找顺子3张
    for i=1,20 do
        -- if i==1 or i==11 then 
            for k1,v1 in pairs(handPaiTB) do
                for k2,v2 in pairs(handPaiTB) do
                   for k3,v3 in pairs(handPaiTB) do
                        if v1.daer_value ==i and v1.m_used==false and v2.daer_value ==i+1 and v2.m_used==false and  v3.daer_value ==i+2 and v3.m_used==false then
                            thePos=thePos+1
                            v1.m_used=true
                            v2.m_used=true
                            v3.m_used=true
                            paizuTb[thePos]={v1,v2,v3} 
                        end     
                   end
                end
            end
        --end
    end
    --剩余的牌
    local pCount = 0
    for k,v in pairs(handPaiTB) do
        if v.m_used==false then 
            if pCount ==0 then
               thePos=thePos+1
               paizuTb[thePos]={}
            end
            v.m_used=true
            table.insert(paizuTb[thePos],v)
            pCount=pCount+1
            if pCount==3 then pCount=0 end
        end
    end
    CCLOG("LzDaer_M_JieSuanPokerTb")
    SHOW(paizuTb)
    return paizuTb
end
function LzDaer_M_JieSuanWinPokerTb( pokerTB)
    local paizuTb = {}
    local thePos = 0
    local handPaiTB =LzDaer_M_ZuhePokerTb(pokerTB)
    local pCount = 0
    for k,v in pairs(handPaiTB) do
        if v.m_used==false then 
            if pCount ==0 then
               thePos=thePos+1
               paizuTb[thePos]={}
            end
            v.m_used=true
            table.insert(paizuTb[thePos],v)
            pCount=pCount+1
            if pCount==3 then pCount=0 end
        end
    end
    return paizuTb
end
--组合牌tb
function LzDaer_M_inSortPokerTB( pokerTB )
    local paizuTb = {}
    local thePos = 0
    local handPaiTB =pokerTB --Eqs_M_ZuhePokerTb(pokerTB)
    local firstSearchTB = {}
    local secondSecarchTb = {}
    local duiziTb = {}
    for i=1,20 do
        firstSearchTB[i] = 0
        for k,v in pairs(handPaiTB) do
            if v.daer_value == i then
                firstSearchTB[i] = firstSearchTB[i]+1
            end
        end
    end
    --找一拢一坎
    for k,v in pairs(firstSearchTB) do
        if v==4  or v==3 then
            thePos=thePos+1
            paizuTb[thePos]={}
            for k1,v1 in pairs(handPaiTB) do
                if v1.daer_value==k and v1.m_used==false then
                   v1.m_used=true
                   table.insert( paizuTb[thePos],v1)
                end
            end
        end
    end
    --找2 7 10
    -- for k1,v1 in pairs(handPaiTB) do
    --     for k2,v2 in pairs(handPaiTB) do
    --        for k3,v3 in pairs(handPaiTB) do
    --             if v1.daer_value ==2 and v1.m_used==false and v2.daer_value ==7 and v2.m_used==false and  v3.daer_value ==10 and v3.m_used==false then
    --                 thePos=thePos+1
    --                 v1.m_used=true
    --                 v2.m_used=true
    --                 v3.m_used=true
    --                 paizuTb[thePos]={v1,v2,v3} 
    --             end
    --              if v1.daer_value ==12 and v1.m_used==false and v2.daer_value ==17 and v2.m_used==false and  v3.daer_value ==20 and v3.m_used==false then
    --                 thePos=thePos+1
    --                 v1.m_used=true
    --                 v2.m_used=true
    --                 v3.m_used=true
    --                 paizuTb[thePos]={v1,v2,v3} 
    --             end
    --        end
    --     end
    -- end
    --找对子三张组合
    for i=1,10 do
        duiziTb[i]={}
        for k,v in pairs(handPaiTB) do
            if v.m_used ==false and v.daer_value%10==i then
               table.insert( duiziTb[i],v)
            end
        end
    end
    CCLOG("找对子三张组合")
    --SHOW(duiziTb)
    local shiyongtb = {}
    for k,v in pairs(duiziTb) do
        if #v==3 then 
           thePos=thePos+1
           for k1,v1 in pairs(v) do
               table.insert(shiyongtb,v1)
           end
            paizuTb[thePos]=v
           --table.insert( paizuTb[thePos],v1)
        end
    end
    for k,v in pairs(handPaiTB) do
        for k1,v1 in pairs(shiyongtb) do
            if v1.daer_value ==v.daer_value then
               v.m_used=true
            end
        end
    end
    --找一对
    for i=1,20 do
        secondSecarchTb[i] = 0
        for k,v in pairs(handPaiTB) do
            if v.daer_value == i and v.m_used==false then
                secondSecarchTb[i] = secondSecarchTb[i]+1
            end
        end
    end
    for k,v in pairs(secondSecarchTb) do
        if v==2 then
            thePos=thePos+1
             paizuTb[thePos]={}
            for k1,v1 in pairs(handPaiTB) do
                if v1.daer_value==k and v1.m_used==false then
                   v1.m_used=true
                   table.insert( paizuTb[thePos],v1)
                end
            end
        end
    end
    -- --找顺子3张
    -- local tbPos = 0
    -- local paiTB ={}
    -- for i=1,20 do
    --     for k1,v1 in pairs(handPaiTB) do
    --         for k2,v2 in pairs(handPaiTB) do
    --            for k3,v3 in pairs(handPaiTB) do
    --                 if v1.daer_value ==i and v1.m_used==false and v2.daer_value ==i+1 and v2.m_used==false and  v3.daer_value ==i+2 and v3.m_used==false then
    --                     thePos=thePos+1
    --                     v1.m_used=true
    --                     v2.m_used=true
    --                     v3.m_used=true
    --                     paizuTb[thePos]={v1,v2,v3} 
    --                 end     
    --            end
    --         end
    --     end
    -- end
    -- --找2张连续
    -- for i=1,20 do
    --     for k1,v1 in pairs(handPaiTB) do
    --         for k2,v2 in pairs(handPaiTB) do
    --             if v1.daer_value ==i and v1.m_used==false and v2.daer_value ==i+1 and v2.m_used==false then
    --                 thePos=thePos+1
    --                 v1.m_used=true
    --                 v2.m_used=true
    --                 paizuTb[thePos]={v1,v2} 
    --             end     
    --         end
    --     end
    -- end
    -- 大小相同
    local daxiaoTb ={}
    for i=1,10 do
        daxiaoTb[i]={}
        for k,v in pairs(handPaiTB) do
            if v.m_used ==false and v.daer_value %10 ==i then 
               table.insert(daxiaoTb[i],v)
            end
        end
    end
    CCLOG("大小相同1")
    local shiyongtb1 = {}
    for k,v in pairs(daxiaoTb) do
        if #v==2 then 
           thePos=thePos+1
           for k1,v1 in pairs(v) do
               table.insert(shiyongtb1,v1)
           end
           paizuTb[thePos]=v
           --table.insert( paizuTb[thePos],v1)
        end
    end
    --SHOW(shiyongtb1)
    CCLOG("大小相同2")
    for k,v in pairs(handPaiTB) do
        for k1,v1 in pairs(shiyongtb1) do
            if v1.daer_value ==v.daer_value then
               v.m_used=true
            end
        end
    end
    --判断 是否超过10列
    local haveCount = #paizuTb
    CCLOG("haveCount",haveCount)
   -- SHOW(paizuTb)
    local haveYizhang = 0
    for k,v in pairs(handPaiTB) do
        if v.m_used ==false then 
            haveYizhang=haveYizhang+1 
        end
    end
    CCLOG("haveYizhang",haveYizhang)
    local hangCount = haveYizhang+haveCount
    if hangCount<=10 then 
        --找一张
        CCLOG("小于10")
        for k,v in pairs(handPaiTB) do
            if v.m_used ==false then
                 v.m_used=true
                 thePos=thePos+1
                 paizuTb[thePos]={v} 
            end
        end
    else
        CCLOG("大于10")
        local shengyuzu =10-haveCount
        if shengyuzu<1 then shengyuzu=1 end
        local zucount = math.ceil(haveYizhang/shengyuzu)
        for i=1,shengyuzu do
            thePos=thePos+1
            paizuTb[thePos]={}
            local index = 0
            for k,v in pairs(handPaiTB) do
                if v.m_used ==false then 
                   v.m_used=true
                   index=index+1
                   table.insert(paizuTb[thePos],v)
                   if index==zucount then break end
                end
            end
        end      
    end
    for i=1,10 do
        for k,v in pairs(paizuTb) do
            if sys.getTBCount(v)==0 then
                table.remove(paizuTb,k)
            end
        end
    end
    paizuTb=LzDaer_Public_SortFun(paizuTb)
    local paicount = 0
    for i,v in ipairs(paizuTb) do
       paicount=#v+paicount
    end
    assert(paicount==#handPaiTB,"牌的数量错误")
    return paizuTb
end

--找到每列胡数
function LzDaer_M_FindPreHuValue(paiTb )
    local hu_num = 0
    if sys.getTBCount(paiTb)<3 then return hu_num end
    local pai_valu = {}
    for k,v in pairs(paiTb) do
        if v.daer_value then
            if pai_valu[v.daer_value] then
                pai_valu[v.daer_value]=pai_valu[v.daer_value]+1
            else
                pai_valu[v.daer_value]=1
            end
        end
    end
    for k,v in pairs(pai_valu) do
        if v==4 then
            if DEF_DAER_GAME_ID==100 then
                if k<=10 then 
                    hu_num=6 
                    if  k==2 or k==7 or k==10 then
                       hu_num=12
                    end
                    break
                elseif k>10 then
                    hu_num=6
                    if  k==12 or k==17 or k==20 then
                       hu_num=12
                    end
                    break
                end
            elseif  DEF_DAER_GAME_ID==18 then
                if k<=10 then 
                    hu_num=6 
                    if  k==2 or k==7 or k==10 then
                       hu_num=12
                    end
                    break
                elseif k>10 then
                    hu_num=6
                    if  k==12 or k==17 or k==20 then
                       hu_num=12
                    end
                    break
                end
            else
                if k<=10 then 
                    hu_num=12 
                    if  k==2 or k==7 or k==10 then
                       hu_num=15
                    end
                    break
                elseif k>10 then
                    hu_num=15
                    if  k==12 or k==17 or k==20 then
                       hu_num=18
                    end
                    break
                end
            end
        elseif v ==3 then
            CCLOG("DEF_DAER_GAME_ID",DEF_DAER_GAME_ID,"kkk-=====",k)
            if DEF_DAER_GAME_ID==100 then
                if k<=10 then 
                    hu_num=3 
                    if  k==2 or k==7 or k==10 then
                       hu_num=9
                    end
                    break
                elseif k>10 then
                    hu_num=6
                    if  k==12 or k==17 or k==20 then
                       hu_num=12
                    end
                    break
                end
            elseif  DEF_DAER_GAME_ID==108 then
                if k<=10 then 
                    hu_num=3 
                    if  k==2 or k==7 or k==10 then
                       hu_num=9
                    end
                    break
                elseif k>10 then
                    hu_num=6
                    if  k==12 or k==17 or k==20 then
                       hu_num=12
                    end
                    break
                end
            else
                if k<=10 then 
                    hu_num=6 
                    if  k==2 or k==7 or k==10 then
                       hu_num=9
                    end
                    break
                elseif k>10 then
                    hu_num=9
                    if  k==12 or k==17 or k==20 then
                       hu_num=12
                    end
                    break
                end
            end
        end
    end
    if pai_valu[2] and pai_valu[7] and pai_valu[10] then 
       hu_num=6
    end
    if pai_valu[12] and pai_valu[17] and pai_valu[20] then 
       hu_num=9
    end
    if pai_valu[1] and pai_valu[2] and pai_valu[3] then 
       hu_num=3
    end
    if pai_valu[11] and pai_valu[12] and pai_valu[13] then 
       hu_num=6
    end
    CCLOG("hu_num",hu_num)
    return hu_num
end
function LzDaer_M_CreLayerTouch( p,touchStartCB,movecb,touchEndCB )
    local touchBeginPoint = nil
    local function onTouchBegan(touch, event)
        local location = touch:getLocation()
        touchBeginPoint = {x = location.x, y = location.y}
        local s         = p:getContentSize()
        local rect      = { x=0, y=0, width=s.width, height=s.height }
        local touchP    = p:convertToNodeSpace( touchBeginPoint )
        if sys.Point_In_Rect(rect, touchP) then
            -- CCTOUCHBEGAN event must return true
            if touchStartCB ~= nil then
                touchStartCB()
            end
            return true
        else
            return false
        end
    end
    local function onTouchMove(touch, event)
        local location = touch:getLocation()
        touchMovePoint = {x = location.x, y = location.y}
        local s         = p:getContentSize()
        local rect      = { x=0, y=0, width=s.width, height=s.height }
        local touchP    = p:convertToNodeSpace( touchMovePoint )
        local isin = false
        if sys.Point_In_Rect(rect, touchP) then
            isin = true
        else
            isin = false
        end
        if movecb then
            movecb(isin)
        end
    end
    local function onTouchEnd( touch, event )
        local location = touch:getLocation()
        touchBeginPoint = {x = location.x, y = location.y}
        local s         = p:getContentSize()
        local rect      = { x=0, y=0, width=s.width, height=s.height }
        local touchP    = p:convertToNodeSpace( touchBeginPoint )
        if sys.Point_In_Rect(rect, touchP) then
            if touchEndCB ~= nil then
                touchEndCB()
            end
        else
        end
    end

    local listener = cc.EventListenerTouchOneByOne:create()
    listener:setSwallowTouches(true)  --不允许消息向下流转
    listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN )
    listener:registerScriptHandler(onTouchMove,cc.Handler.EVENT_TOUCH_MOVED )
    listener:registerScriptHandler(onTouchEnd,cc.Handler.EVENT_TOUCH_ENDED )
    local eventDispatcher = p:getEventDispatcher()
    eventDispatcher:addEventListenerWithSceneGraphPriority(listener, p)
end

function LzDaer_M_GetHuTypeRes( hutype,xingbie )
    local res = nil
    local huname=""
    if hutype  ==1 then 
       res = "lzde_jsk_zm"
       --LzDaer_Public_PlaySound("zimo",xingbie)
        huname="自摸"
    end   
    if hutype  ==2 then 
       res = "lzde_jsk_hu"
       --LzDaer_Public_PlaySound("hu",xingbie)
       huname="胡"
    end
    if hutype  ==3 then 
       res = "lzde_jsk_fp"
       --LzDaer_Public_PlaySound("baile",xingbie)
       huname="放炮"
    end
    if hutype==4 then
       huname="查叫"
    end
    return res
end
function LzDaer_M_GetPaiXinRes( paixinValue ,xingbie )
    local res = nil
    local paixinNameTb = {}
    if DEF_DAER_GAME_ID==15 then
        paixinNameTb={
            [emDaEr_PaiXing_Red]="红胡",
            [emDaEr_PaiXing_Black]="黑胡",
            [emDaEr_PaiXing_Kun]="昆胡",
            [emDaEr_PaiXing_Geng]="梗",
            [emDaEr_PaiXing_TianHu]="天胡",

            [emDaEr_PaiXing_DiHu]="地胡",
            [emDaEr_PaiXing_LuanHu]="乱胡",
            [emDaEr_PaiXing_BaoHu]="暴胡",
            [emDaEr_PaiXing_HDL]="海底",
            [emDaEr_PaiXing_SHP]="水上漂",

            [emDaEr_PaiXing_ZiMo]="自摸",
            [emDaEr_PaiXing_Gui]="归",
            [emDaEr_PaiXing_SLSK]="三拢四坎",
            [emDaEr_PaiXing_SanZhao]="三招",
            [emDaEr_PaiXing_HeiPai]="黑摆",
            
            [emDaEr_PaiXing_ChaJiao]="查叫",
            [emDaEr_PaiXing_DingBao]="顶暴",
        }

    elseif DEF_DAER_GAME_ID==99 then
        paixinNameTb={
            --[emDaErJA_PaiXing_Red]="红胡",
            [emDaErJA_PaiXing_Kun]="昆胡",
            [emDaErJA_PaiXing_Black]="黑胡",
            [emDaErJA_PaiXing_Geng]="梗",
            [emDaErJA_PaiXing_TianHu]="天胡",

            [emDaErJA_PaiXing_DiHu]="地胡",
            --[emDaErJA_PaiXing_LuanHu]="乱胡",
            [emDaErJA_PaiXing_BaoHu]="暴胡",
            [emDaErJA_PaiXing_HDL]="海底",
            [emDaErJA_PaiXing_SHP]="水上漂",
            [emDaErJA_PaiXing_DingBao]="顶暴",

            [emDaErJA_PaiXing_ZiMo]="自摸",
            [emDaErJA_PaiXing_Gui]="归",
            [emDaErJA_PaiXing_SLSK]="三拢四坎",
            [emDaErJA_PaiXing_SanZhao]="三招",
            [emDaErJA_PaiXing_HeiPai]="黑摆",

            [emDaErJA_PaiXing_ChaJiao]="查叫",
            [emDaErJA_PaiXing_Red]="红胡",

        }
    elseif DEF_DAER_GAME_ID==100 then
        paixinNameTb={
            [emDaErCN_PaiXing_Red]="红胡",
            --[emDaErCN_PaiXing_Kun]="昆胡",
            [emDaErCN_PaiXing_Black]="黑胡",
            --[emDaErCN_PaiXing_Geng]="梗",
            [emDaErCN_PaiXing_TianHu]="天胡",

            [emDaErCN_PaiXing_DiHu]="地胡",
            [emDaErCN_PaiXing_LuanHu]="乱胡",
            [emDaErCN_PaiXing_BaoHu]="暴胡",
            [emDaErCN_PaiXing_HDL]="海底",
            --[emDaErCN_PaiXing_SHP]="水上漂",
            [emDaErCN_PaiXing_DingBao]="顶暴",
            [emDaErCN_PaiXing_ZiMo]="自摸",
            --[emDaErCN_PaiXing_Gui]="归",
            --[emDaErCN_PaiXing_SLSK]="三拢四坎",
            --[emDaErCN_PaiXing_SanZhao]="三招",
            --[emDaErCN_PaiXing_HeiPai]="黑摆",
            [emDaErCN_PaiXing_ChaJiao]="查叫",
        }
     elseif DEF_DAER_GAME_ID==108 then
        paixinNameTb={
            [emDaErWX_PaiXing_BaoHu]="爆胡",
            [emDaErWX_PaiXing_ZiMo]="自摸",
            [emDaErWX_PaiXing_SHP]="头块",
            [emDaErWX_PaiXing_HDL]="海底",
            [emDaErWX_PaiXing_TianHu]="天胡",

            [emDaErWX_PaiXing_Geng]="棒胡",

            [emDaErWX_PaiXing_Kun]="列列数",
            [emDaErWX_PaiXing_Red]="红胡",
            [emDaErWX_PaiXing_Black]="黑胡",
            [emDaErWX_PaiXing_SLSK]="三拢四坎",
            [emDaErWX_PaiXing_Gui]="四王爷",
            [emDaErWX_PaiXing_ZhaBaoHu]="炸爆",
            [emDaErWX_PaiXing_RedKun]="红列列",
            [emDaErWX_PaiXing_BlackKun]="黑列列",
            [emDaErWX_PaiXing_RedGeng]="红棒",
            [emDaErWX_PaiXing_BlackGeng]="黑棒",
            [emDaErWX_PaiXing_YiKeZhu]="一棵珠",
            [emDaErWX_PaiXing_YiKeZhuKun]="一颗珠列列数",
            [emDaErWX_PaiXing_YiKeZhuGeng]="一颗珠棒",
            [emDaErWX_PaiXing_ChaJiao]="查叫",
        }
    end
    return paixinNameTb[paixinValue] or "nil"
end
function LzDaer_M_CloseJisuanUI(  )
    local sDirector = CCDirector:getInstance()
    local currScene = sDirector:getRunningScene()
    if currScene then
       if currScene:getChildByName("basenode") then
          if currScene:getChildByName("basenode"):getChildByName("jiesuanNode") then
             currScene:getChildByName("basenode"):removeChildByName("jiesuanNode")
          end
       end
    end
end
---游戏规则
function Lzde_M_PushGuiZeCB(  )
    CCLOG("Lzde_M_PushGuiZeCB")
    --local roominfo =Pt_M_GetRoomInfoTb()
    local tbRoomInfo =Pt_M_GetRoomInfoTb()
    local tbVideo = Pt_M_GetVideoInfoFun()
    local bVideo = Pt_M_GetIsVideoFun()
    local tbTemp = Pt_GetSel_NewMethodex(tbRoomInfo,tbVideo,bVideo)
    local getInfoTb =Pt_Parase_Sel_SubFun_Mi(tbTemp)
    local sDirector = CCDirector:getInstance()
    local currScene = sDirector:getRunningScene()
    local shownode = cc.Node:create()
    currScene:addChild(shownode,104)
    xui.creMaskLy(shownode)
    local bg = xui.addSprite( shownode,"lzde_yxgz_bjb", sys.center.x,sys.center.y)
    --local bg =xui.addSpr9(currScene,"lzde_yxgz_bjb",717,426,sys.center.x,sys.center.y)
    bg:setLocalZOrder(105)
    Pt_M_UIAni_ScaleOut(bg)
    local size = bg:getContentSize()
    local startY = size.height-60
    local statrX =60
    local statrX2 =75
    local jian_y = 50
    local closeBtn = MyBtnClass:new("lzde_cancel_zc","lzde_cancel_dj","lzde_cancel_zc",
                        function ( )
                            Pt_M_UIAni_ScaleIn(bg,function (  )
                                shownode:removeFromParent(true)
                                shownode=nil
                            end)
                        end)
    bg:addChild(closeBtn.btnLy,4)
    closeBtn.btnLy:setPosition(bg:getContentSize().width-50, bg:getContentSize().height-50)

    local function CreguizeFun( nameStr,showStr,order )
        local node = cc.Node:create()
        local title = xui.addLabel(node,nameStr,cc.c3b(124,95,48),26,statrX,startY,sys.ap.leftCenter)
        local gameNameLabel =xui.addLabel(node,showStr,cc.c3b(255,255,255),26,statrX2+title:getContentSize().width,startY,sys.ap.leftCenter)
        local labelSpbg=xui.addSpr9(node,"lzde_yxgz_bjfk",gameNameLabel:getContentSize().width+20,44,gameNameLabel:getPositionX()-10,gameNameLabel:getPositionY(),sys.ap.leftCenter)
        labelSpbg:setLocalZOrder(order or -1)
        bg:addChild(node)
        return node
    end
    --游戏名字
    local gameName   = ""
    if tbTemp.cname then
        gameName=tbTemp.cname
    end
    CreguizeFun("游戏名称:",gameName)
    startY=startY-jian_y
    --local getInfoTb =Pt_Parase_Sel_SubFun_Mi(roominfo.deskparam)
    SHOW(getInfoTb)
    --规则选项
    local wanfaTb = {}
    local wanfaChangTb={}
    local guizeCount = 0
    local hangcount = 3
    local hand_count = 0
    for k,v in pairs(getInfoTb) do
        if v.deffun then
            local strName = ""
            local getStr =  ""
            if v.deffun==emUserDef_DR_Sel_LimitDing then 
                strName="颗数选择:"
                getStr = v.na
                CreguizeFun(strName,getStr)
                startY=startY-jian_y
            else
                if v.na then   
                    if string.utf8len(v.na)<8 then
                       hand_count=hand_count+1
                       table.insert(wanfaTb,{["na"]=v.na,["size"]=string.utf8len(v.na)})
                    else
                       table.insert(wanfaChangTb,{["na"]=v.na,["size"]=string.utf8len(v.na)})
                    end
                end
            end
        end  
    end
    SHOW(wanfaTb)
    local tbcount = sys.getTBCount(wanfaTb)+ sys.getTBCount(wanfaChangTb)
    if tbcount<3 then  hangCount=tbcount  end
    if tbcount>0  then 
        local hang_y = 28
        local hang_x = 160
        local creNode = cc.Node:create()
        local title = xui.addLabel(creNode,"游戏玩法:",cc.c3b(124,95,48),26,statrX,startY,sys.ap.leftCenter)
        for k,v in pairs(wanfaTb) do
            guizeCount=guizeCount+1
            local a = guizeCount%hangcount 
            if a==0 then a =hangcount end
            local b = math.ceil(guizeCount/hangcount)
            local guiLabel =xui.addLabel(creNode,v.na,cc.c3b(255,255,255),26,statrX2+title:getContentSize().width+hang_x*(a-1),startY-(b-1)*hang_y,sys.ap.leftCenter)
        end
        local dangcount =math.ceil(sys.getTBCount(wanfaTb)/hangcount)
        CCLOG("dangcount---",dangcount)
        for k,v in pairs(wanfaChangTb) do
            guizeCount=guizeCount+1
            local guiLabel =xui.addLabel(creNode,v.na,cc.c3b(255,255,255),26,statrX2+title:getContentSize().width,startY-(dangcount+k-1)*hang_y-(k-1),sys.ap.leftCenter)
        end
        local labelSpbg=xui.addSpr9(creNode,"lzde_yxgz_bjfk",hang_x*hangcount,hang_y*(math.ceil(sys.getTBCount(wanfaTb)/hangcount)+sys.getTBCount(wanfaChangTb))+20,statrX2+title:getContentSize().width-10,startY+jian_y/2,sys.ap.topLeft)
        labelSpbg:setLocalZOrder( -2)
        bg:addChild(creNode)
        startY=startY-(hang_y*(math.ceil(sys.getTBCount(wanfaTb)/hangcount)+sys.getTBCount(wanfaChangTb))+20)
    end
    --选择局数
    if Pt_Get_SelectGameMode()<=emMode_2 then 
        CreguizeFun("选择局数:",Pt_GetLimit_MaxJuNum(),-3)
        startY=startY-jian_y
    end
    --支付方式
    CreguizeFun("支付方式:",Pt_GetPayTypeFun( tbRoomInfo.costtype))
    startY=startY-jian_y
end
 
local m_bgclickCount = 1

function Daer_P_GetBgNum(  )
    return m_bgclickCount
end
function Daer_P_CreSetUI( p,M_GameBtn )
    if not p then return end
    local basenode = cc.Node:create()
    p:addChild(basenode,101)

    local startx = sys.width - 80
    local starty = sys.height - 80
    --设置
    local setbtn = MyBtnClass:new("gframe/xxqp_sz_zc","gframe/xxqp_sz_dj","gframe/xxqp_sz_zc",function (  )
        local useExit = (Pt_M_GameStateFun() ~= emRoomState_Wait and Pt_M_GameStateFun() ~= emRoomState_JSWait and Pt_Get_SelectGameMode() == emMode_2 and not M_GameBtn.isWatcher())
        UIMgr:openUI('FlowerOptionUI',useExit)
    end,nil,true,nil,{width = 79,height = 77})
    setbtn.btnLy:setPosition(startx, starty )
    basenode:addChild(setbtn.btnLy)
end
