|
- local ZPDef = ZPFramework.ZPImport("zp_base.luaScript.ZPDef")
- local ZPRoomView = ZPFramework.ZPFrameworkClassImprot("zp_base.luaScript.Views.Room.ZPRoomView")
- local PokerUtil = require("zp_doushisi.luaScript.Views.Room.doushisiPokerUtil")
- local ZPMessage = ZPFramework.ZPImport("zp_base.luaScript.Protocol.ZPMessage")
- local PokerCardNode = require("zp_doushisi.luaScript.Views.Room.doushisiCardNode")
- local DoushisiRoomConfig = require("zp_doushisi.luaScript.Views.Room.doushisiRoomConfig")
- local ZPFuc = ZPFramework.ZPImport("zp_base.luaScript.ZPFunctions")
- local ZPRoomQuickStartView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomQuickStartView")
- local ZPRoomPlayerView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomPlayerView")
- local ZPRoomToolView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomToolView")
- local ZPRoomXiaoJuChaPaiView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomXiaoJuChaPaiView")
- local DouShiSiRoomOperationView=ZPFramework.ZPImport("zp_doushisi.luaScript.Views.Room.doushisiRoomOperationView")
- local doushisiRoomXiaoJuView=ZPFramework.ZPImport("zp_doushisi.luaScript.Views.Room.doushisiRoomXiaoJuView")
- local doushisiRoomSettingView=ZPFramework.ZPImport("zp_doushisi.luaScript.Views.Room.doushisiRoomSettingView")
- local ZPRoomCountAllView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomCountAllView")
- local ZPWanFa=ZPFramework.ImportWanFa("luaScript.SubGameDefine.ZiPai.ZPWanFa")
- local QiPaiView = require("zp_doushisi.luaScript.Views.Room.doushisiQiPaiView")
- local GroupCardView = require("zp_doushisi.luaScript.Views.Room.doushisiGroupCardView")
- local ZPSound = ZPFramework.ZPImport("zp_base.luaScript.ZPSound")
-
- local CENTER_X=640*g_radio_x
- local CENTER_Y=360*g_radio_y
-
-
- local doushisiRoomView = class("doushisiRoomView", ZPRoomView)
-
- function doushisiRoomView:ctor()
- doushisiRoomView.super.ctor(self)
-
- self._selfCards = {}
-
- for i = 1,ZPDef.GameMaxPlayer do
- self._selfCards[i] = {}
- end
-
- --是否是起手操作的标志
- self.isQiShou = true
- --操作牌数组
- self.opOutCard = {}
- --摸牌
- self.moValue = 0
- --要吃的那张牌
- self.chiCard = 0
- --是否包赔
- self.isBaopei = 0
- --是否是必吃的牌
- self.isBiChi = 0 --是否必吃
- --点击过后是否需要提示包赔
- self.isTishi = false
- --弃牌的缩放大小
- self.littleCardScale = 0.4
- --报叫的状态
- self.baoJiaoStatus = 0
-
- self.outCardScale = 0.5
-
- self.qiPaiView = {}
-
-
- self.touchPoker = nil
-
- end
-
- function doushisiRoomView:onEnter()
- doushisiRoomView.super.onEnter(self)
- end
-
-
- function doushisiRoomView:loadRoomUI()
- local ui = loadUI("zp_doushisi/res/ui/ui_fangjian/doushisi_ui_fangjian.ui");
- self.ui = ui;
- self:addChild(ui);
- end
-
-
- function doushisiRoomView:initBaseNode()
- --自己的出生坐标,视图是4
- self.boxPosList4 = {}
- local weaveCardPos4 = self.ui.Items.Layout_StartPos:getPosition()
- for i = 1, self.lieShuMax do
- --矩形3
- self.boxPosList4[i] = cc.p(weaveCardPos4.x + 90 * (i - 1),weaveCardPos4.y)--手牌间隙改这里
- end
-
- self.leftCardNumPos = self.ui.Items.TextBMFont_leftCardNum:getPosition()
- --坐标记录
- self.srcOutCardPosList = {}
- self.scorePosList = {}
- for k = 1,ZPDef.GameMaxPlayer do
- local name = string.format("Layout_outCardPoint_%d",k)
- local imgName = string.format("ImageView_outCardImg_%d",k)
- self.ui.Items[name]:setScale(self.outCardScale)
- self.srcOutCardPosList[k] = self.ui.Items[imgName]:getPosition()
- --操作分数坐标
- --name = string.format("TextBMFont_Score_%d",k)
- --self.scorePosList[k] = self.ui.Items[name]:getPosition()
- end
-
- --初始化扎鸟
- self.PlayerView:initPlayerPiaoFenByRule()
-
- local timestr = os.date("%y-%m-%d %H:%M:%S")
- self.ui.Items.Text_systemTime:setText(timestr)
- --定时器
- if not self.Time then
- self.Time = cc.Director:getInstance():getScheduler():scheduleScriptFunc(function()
- local timestr = os.date("%y-%m-%d %H:%M:%S")
- self.ui.Items.Text_systemTime:setText(timestr)--(getTimeString())
- end,1.0,false)
- end
-
- --创建弃牌层
- for i = 1, ZPDef.GameMaxPlayer do
- self.qiPaiView[i] = QiPaiView:new(i)
- self.qiPaiView[i]:setPosition(DoushisiRoomConfig.DISCARD_START_POS[i])
- self.ui.Items.Layout_QiPai:addChild(self.qiPaiView[i])
- end
-
-
- --[[ for i = 1, ZPDef.GameMaxPlayer do
- local touNode = string.format("Layout_tuopai_%d",i)
- self.ui.Items[touNode]:setVisible(false)
- end--]]
-
-
- for i = 1, ZPDef.GameMaxPlayer do
- self.opOutCard[i] = GroupCardView:new(i)
- self.opOutCard[i]:setPosition(DoushisiRoomConfig.GROUPCARD_START_POS[i])
- self.ui.Items.Layout_GroupCard:addChild(self.opOutCard[i])
- end
-
- self.ui.Items.ImageView_tou_tip:setVisible(false)
- end
-
-
-
- function doushisiRoomView:initToolLayer()
- --人物头像层
- self.PlayerView = ZPRoomPlayerView:new()
- self.ui.Items.Layout_Player:addChild(self.PlayerView)
-
- --操作界面(吃碰杠胡)
- self.operationView = DouShiSiRoomOperationView:new()
- --self.operationView:setVisible(false)
- self.ui.Items.Layout_Tool:addChild(self.operationView)
-
- --加载工具层
- self.toolView = ZPRoomToolView:new()
- self.ui.Items.Layout_Tool:addChild(self.toolView)
-
- local headInfos = {}
- for k,v in pairs(self.PlayerView.allNodes) do
- if k == 2 then
- local pos = cc.pAdd(v.player:getPosition(),cc.p(150,30))
- table.insert(headInfos,{headPos=pos})
- elseif k == 4 then
- local pos = cc.pAdd(v.player:getPosition(),cc.p(40,40))
- table.insert(headInfos,{headPos=pos})
- elseif k == 3 then
- local pos = cc.pAdd(v.player:getPosition(),cc.p(40,40))
- table.insert(headInfos,{headPos=pos})
- elseif k == 1 then
- local pos = cc.pAdd(v.player:getPosition(),cc.p(0,40))
- table.insert(headInfos,{headPos=pos})
- end
- end
-
- self.playerPos = headInfos
-
- -- 小局查牌界面
- self.xiaojuChaPaiView = ZPRoomXiaoJuChaPaiView:new(self.colorType)
- self.xiaojuChaPaiView:setVisible(false)
- --亮牌界面确定
- local function cb()
- --显示小局结算
- if self.xiaojuView then
- self.xiaojuView:setVisible(true)
- end
- end
- self.xiaojuChaPaiView:setQueDingCallBack(cb)
- self.xiaojuChaPaiView:showHuCardCallBack(handler(self , self.onShowHuCard))
- self:addChild(self.xiaojuChaPaiView)
- end
-
-
- -- 设置房间信息
- function doushisiRoomView:setRoomInfo()
- self.ui.Items.ListView:removeAllChildren()
- self.ui.Items.ListView:getInnerContainer():setAutoSize(true)
- local rules = ZPWanFa.getClubRuleInfo(app.room.roomInfo.strGameInfo)
- for k,v in pairs(rules) do
- local text = self.ui.Items.Text_Rule:getCopied()
- text:setVisible(true)
- text:setString(tostring(v.value[1]))
- self.ui.Items.ListView:addChild(text)
- end
- self.ui.Items.ListView:jumpToTopOnSizeChanged();
- end
-
- --显示提牌按钮
- function doushisiRoomView:showTiPaiBtn(vis)
- vis = vis or false
- self.ui.Items.Button_tipai:setVisible(false)
- end
-
-
- function doushisiRoomView:onGameReconnection()
- --logE("ZiPai当前版本号:"..ZPFuc.getZPCurVersion())
- --更新房间基础数据
- self:updateRoomBaseData()
-
- local roomInfo = app.room.roomInfo;
-
- --self:updateAllGpsInfo()
- --self:checkGpsDistance(nil,roomInfo.nGameStartCount==0)
- --self:checkMyGpsNeedUpdate();
-
- --断线重连
- if roomInfo.nGameStartCount > 0 then
- local function runOnGameReconnection(onEnd)
- self.isQiShou = false
- local roomInfo = app.room.roomInfo;
- self.ui.Items.ImageView_handTempCard:stopAllActions()
- --显示庄家
- self:updateBanker()
- self:showOwner()
- self:showXiaojia()
- local myUserID = app.room:getMyRecordUserId()
- --解散状态
- local isDismiss = false
- local uid = 0
- for k,v in pairs(roomInfo.arrayTableInfo) do
- local viewId = app.room:getViewIdByUserId(k)
- local nOffLineState = v.nOnlineStatus
- --显示离线
- self.PlayerView:setPlayerOffLine(nOffLineState ~= 1,viewId)
-
- local viewId = app.room:getViewIdByUserId(k)
- --记录玩家解散状态 0:初始状态, 1:发起解散 2: 同意解散 3:不同意解散
- app.room.dismissInfo[k] = v.nDisbandStatus;
- app.room.roomInfo.memberList[k].nDisbandStatus = v.nDisbandStatus;
- --有人发起解散时才显示解散界面
- if v.nDisbandStatus == 1 then
- isDismiss = true
- uid = k
- end
- end
-
- --有人发起解散时才显示解散界面
- if isDismiss then
- app.room.roomInfo.nDismissStateTime = roomInfo.nDismissStateTime;
- app.room.roomInfo.nDismissToTalTime = roomInfo.nDismissToTalTime;
-
- local view = require("luaScript.Views.Room.RoomDismissView"):new(uid,app.room.roomInfo.memberList,roomInfo.nDismissStateTime)
- view:setAnchorPoint(cc.p(0.5, 0.5));
- app:showWaitDialog(view);
- end
-
- --如果一局结束,玩家点了准备,不再显示牌信息
- if ZPDef.ReconnectState.GAME_STATUS_ROUND_OVER == roomInfo.nStatus and roomInfo.memberList[myUserID].nPlayerFlag == 1
- or ZPDef.ReconnectState.GAME_STATUS_GAME_OVER == roomInfo.nStatus and roomInfo.memberList[myUserID].nPlayerFlag == 1
- then --游戏为停止或开始状态
- self:onUserReadyResponse()
- self.ui.Items.Button_tipai:setVisible(false)
- if onEnd then
- onEnd()
- end
- return
- end
-
- --胡牌类型
- local huType = ZPDef.ReconnectHuType.NO_HU
-
- --状态显示
- if ZPDef.ReconnectState.GAME_STATUS_ROUND_OVER == roomInfo.nStatus
- or ZPDef.ReconnectState.GAME_STATUS_GAME_OVER == roomInfo.nStatus then --游戏为停止或开始状态
- for hi,hv in pairs(app.room.roomInfo.hupaiInfo) do
- if hv.huPaiUid > -1 then
- app.room.roomInfo.baopeiUserid =app.room:getUserIdBySeatId(hv.BaoPeiUid)
- app.room.roomInfo.fourNormolNum = hv.fourNormolNum
- app.room.roomInfo.threeNormolNum = hv.threeNormolNum
- end
- end
-
- self.ui.Items.Button_tipai:setVisible(false)
- --显示小局结算亮牌画布
- self:setLiangPaiVisible(true)
- --显示底牌
- self.xiaojuChaPaiView:showDiPai()
- --亮手牌
- huType = self.xiaojuChaPaiView:liangShouPai(true)
-
- local function nextCallBackFun()
- self:resetGameData()
- end
-
- self.xiaojuView = doushisiRoomXiaoJuView:new(nextCallBackFun,true,self.colorType)
-
- self:addChild(self.xiaojuView)
-
- --播放黄庄动画
- if roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_HUANG_ZHUANG then
- local userInfo=app.room:getUserInfo(app.user.loginInfo.uid)
- if userInfo then
- ZPSound.PlayHuangZhuang(userInfo.sex)
- end
- self.xiaojuChaPaiView:PlayHuangZhuangAni(false)
- end
-
- self.xiaojuView:setVisible(true)
-
- self:setBtnSitDownVisible(false)
- end
-
- local diPaiMax = table.nums(roomInfo.dipaiList)
- for k,v in pairs(roomInfo.arrayTableInfo) do
- local viewId = app.room:getViewIdByUserId(k)
- local nScore = v.nTotalMoney or 0
-
- --玩家分数
- self.PlayerView:setPlayerScore(viewId,nScore)
- --扎鸟
- --self.PlayerView:setPlayerPiaoFen(viewId,v.nZhaBirdScore)
-
- --恢复手牌
- if k == myUserID then
- self:createCard(false,myUserID,nil)
- end
-
-
- --恢复爆牌动画
- if v.nBaoPaiStatus == 2 and not (ZPDef.ReconnectState.GAME_STATUS_ROUND_OVER == roomInfo.nStatus
- or ZPDef.ReconnectState.GAME_STATUS_GAME_OVER == roomInfo.nStatus) and viewId == self:getMeViewId() then
- --self.PlayerView:playBaoAnim(viewId)
- self.baoJiaoStatus = 1 --已经报叫
-
- local nBankerSeatId = app.room.roomInfo.nBankSeatId
- local toujiaViewId = app.room:getViewIdBySeatId(nBankerSeatId)
-
- local nSeatId = roomInfo.showCardSeatId
- local curOpViewId = app.room:getViewIdBySeatId(nSeatId)
-
- if ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_BAO == roomInfo.nStatus
- or ZPDef.ReconnectState.GAME_STATUS_WAIT_BANKER_OUTCARD == roomInfo.nStatus
- and viewId == toujiaViewId then --当前是庄家出牌并且自己的ID是头家 这时候放开出牌,其他时候手牌全锁
- elseif (ZPDef.ReconnectState.GAME_STATUS_WAIT_OUT_CARDS == roomInfo.nStatus or ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_TOU == roomInfo.nStatus)
- and curOpViewId == viewId then --如果报叫后进了牌,则只能打进的牌
- app.room.roomInfo.tingCards = {}
- table.insert(app.room.roomInfo.tingCards, app.room.roomInfo.curEnterCard)
- else
- app.room.roomInfo.tingCards = {}
- end
- self:lockMyHandCards()
- end
-
- if v.nBaoPaiStatus == 2 then
- self.PlayerView:setPlayerBaoJiaoVisible(viewId,true)
- end
-
-
- local hushu = 0
- --恢复组合牌
- for key,value in pairs(v.tableWeaveCard) do
- local isShow = true
- local card = value.opcard
- local optype = value.type
-
- local list = value.card
-
- --上面吃或不吃不要用if else因为还可能都不成立
- --创建桌面操作牌
- self:recontactDoOperation(viewId,list,optype)
- end
- self.tableHuXiList[viewId] = hushu
- --self.PlayerView:setPlayerHuXi(viewId,hushu)
- --self.PlayerView:setPlayerHuXi("油:"..tostring(hushu))
- if viewId ~= self:getMeViewId() then
- self.PlayerView:setLeftCardNum(viewId,true,tonumber(v.leftCardNum))
- else
- self.myHandCardNums = tonumber(v.leftCardNum)
- end
-
- end
-
-
- --恢复弃牌
- for k,v in pairs(roomInfo.arrayTableInfo) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- for key,value in pairs(v.desertedArea) do
- --普通弃牌
- self:playQiPaiAni(false,value.card,viewId,nil,false)
- end
-
- end
-
- --听牌显示
- local max = table.nums(app.room.roomInfo.tingCards)
- if max > 0 then
- --self:setTingCardViewVisible(true,app.room.roomInfo.tingCards)
- end
-
- --显示玩家剩余手牌
- if app.room.roomInfo.offLineInfo and next(app.room.roomInfo.offLineInfo) ~= nil then
- for i,v in pairs(app.room.roomInfo.offLineInfo) do
- if v.extInfo then
- local extIf = json.decode(v.extInfo)
- if extIf.HuShu and v.nUserId then
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- end
- end
- end
- end
-
- --吃后巴后油牌
- local viewId = app.room:getViewIdBySeatId(roomInfo.showCardSeatId)
- if app.room.roomInfo.disCard and ZPDef.ReconnectState.GAME_STATUS_WAIT_OUT_CARDS == roomInfo.nStatus and viewId == self:getMeViewId() then
- self:lockYouPai(app.room.roomInfo.disCard)
- end
-
-
- local myViewId = self:getMeViewId()
-
- --状态显示
- if ZPDef.ReconnectState.GAME_STATUS_ROUND_OVER == roomInfo.nStatus
- or ZPDef.ReconnectState.GAME_STATUS_GAME_OVER == roomInfo.nStatus then --游戏为停止或开始状态
- self.PlayerView:hideLeftCard()
- --所有的暗偎默认亮起一张
- --self:showLastAnWeiPai()
- --点炮显示
- --self:showPaoImage()
- for hi,hv in pairs(app.room.roomInfo.hupaiInfo) do
- if hv.huPaiUid > -1 then
- local winerViewId = app.room:getViewIdByUserId(hv.huPaiUid)
- app.room.roomInfo.huType = hv.huTypes
- app.room.roomInfo.baopeiUserid =app.room:getUserIdBySeatId(hv.BaoPeiUid)
- self:playHuEffect(winerViewId,nil,true)
- end
- end
-
- --完成手牌展示
- for k,v in pairs(roomInfo.arrayTableInfo) do
- local cardData = roomInfo.memberList[v.nUserId].cardList
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- local lens = table.nums(cardData)
- local cardLens = table.nums(self._selfCards[viewId])
-
- if viewId == 1 or viewId == 2 then
- cardData = {}
- local lens = table.nums(roomInfo.memberList[v.nUserId].cardList)
- local list = roomInfo.memberList[v.nUserId].cardList
-
- for i = 1,lens do
- cardData[i] = table.remove(list,#list)
- end
- end
-
- for i = lens+1, cardLens do
- if self._selfCards[viewId][i] then
- self._selfCards[viewId][i]:setVisible(false)
- end
- end
-
- if self._selfCards[viewId] then
- for i = 1, lens do
- if self._selfCards[viewId][i] then
- self._selfCards[viewId][i]:setCard(cardData[i])
- end
- end
- end
- end
-
-
- local viewId = self:getMeViewId()
-
- self:setCircleCardLeftPanelView(true,viewId,diPaiMax)
- self.PlayerView:setAllClockVisible(false)
-
- elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_TIAN_HU == roomInfo.nStatus
- or ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_AFTER_TURN_OVER == roomInfo.nStatus
- or ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_TOU == roomInfo.nStatus
- or ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_AFTER_OUTCARD == roomInfo.nStatus
- or ZPDef.ReconnectState.GAME_STATUS_WAIT_QIANGBA == roomInfo.nStatus then -- 天胡,翻牌后等待玩家操作中,出牌后等待玩家操作中
- local nSeatId = roomInfo.showCardSeatId
- local nCard = roomInfo.showCard
- local operateCode = roomInfo.mainOpCode
- local viewId = app.room:getViewIdBySeatId(nSeatId)
- local nUserId = app.room:getUserIdBySeatId(nSeatId)
- local opCardList = {}
-
- local curOpeateid = roomInfo.curOpreateID --当前操作ID
- local curOpView = app.room:getViewIdBySeatId(curOpeateid)
-
- --记录真实数据
- self.outCard = nCard
- self.EatOperationCode = operateCode
- self.moPaiViewId = viewId
-
-
- if ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_TIAN_HU == roomInfo.nStatus then --等待天胡
- local hasGuo = true
- self.isQiShou = true
- self.isGodHand = true
-
- local curOpView = app.room:getViewIdBySeatId(curOpeateid)
-
- local operationCardlist = {}
-
- if #roomInfo.startOpList.BacardList > 0 then
- operationCardlist[ZPDef.OpCode.OP_BA_QI_SHOU] = {}
- for k,v in pairs(roomInfo.startOpList.BacardList or {}) do
- table.insert(operationCardlist[ZPDef.OpCode.OP_BA_QI_SHOU],v)
- end
- end
- --操作码
- if #roomInfo.startOpList.ToucardList > 0 then
- operationCardlist[ZPDef.OpCode.OP_TOU_QI_SHOU] = {}
- local toulist = {}
- for k,v in pairs(roomInfo.startOpList.ToucardList or {}) do
- for _,value in pairs(v.cardlist) do
- table.insert(toulist,value)
- end
- table.insert(operationCardlist[ZPDef.OpCode.OP_TOU_QI_SHOU],toulist)
- toulist = {}
- end
- end
-
- local retHu1 = bit32.band(operateCode,ZPDef.OpCode.OP_TIAN_HU)
-
- if self.isQiShou and retHu1 > 0 then
- hasGuo = false
- end
-
- if curOpView == self:getMeViewId() then
- if operateCode > 0 then
- self:showOpeation(operateCode,operationCardlist,self.isQiShou,hasGuo) --天胡没有过
- end
- end
-
- self.ui.Items.ImageView_tou_tip:setVisible(true)
-
- elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_TOU == roomInfo.nStatus then --玩家进牌状态
- self.isQiShou = false
- self.isGodHand = true
- local operationCardlist = {}
- if #roomInfo.startOpList.BacardList > 0 then
- operationCardlist[ZPDef.OpCode.OP_BA_ZHUA] = {}
- for k,v in pairs(roomInfo.startOpList.BacardList or {}) do
- table.insert(operationCardlist[ZPDef.OpCode.OP_BA_ZHUA],v)
- end
- end
- --操作码
- if #roomInfo.startOpList.ToucardList > 0 then
- operationCardlist[ZPDef.OpCode.OP_TOU_ZHUA] = {}
- local toulist = {}
- for k,v in pairs(roomInfo.startOpList.ToucardList or {}) do
- for _,value in pairs(v.cardlist) do
- table.insert(toulist,value)
- end
- table.insert(operationCardlist[ZPDef.OpCode.OP_TOU_ZHUA],toulist)
- toulist = {}
- end
- end
-
- if roomInfo.startOpList.ishu == 1 then
- operationCardlist[ZPDef.OpCode.OP_HU] = {}
- table.insert(operationCardlist[ZPDef.OpCode.OP_HU],0) --自摸的时候发0
- end
-
- if operateCode > 0 then
- self:showOpeation(operateCode,operationCardlist,self.isQiShou,true) --天胡没有过
- end
- elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_AFTER_OUTCARD == roomInfo.nStatus then
- --是否已经操作过 0表示没有,非0表示已经提交了操作
- self.isQiShou = false
- self.isGodHand = true
- if roomInfo.isBaopeiCard == 1 then
- self.isBiChi = 2
- end
-
- if operateCode ~= 0 and roomInfo.isSubmitOp == 0 then
- opCardList[ZPDef.OpCode.OP_HU] = {}
- table.insert(opCardList[ZPDef.OpCode.OP_HU],nCard)
- opCardList[ZPDef.OpCode.OP_PENG] = {}
- local penglist = {}
- for k,v in pairs(roomInfo.pengCardlist or {}) do
-
- for _,val in pairs(v.cardlist or {}) do
- table.insert(penglist,val)
- end
- table.insert(opCardList[ZPDef.OpCode.OP_PENG],penglist)
- penglist = {}
- end
- opCardList[ZPDef.OpCode.OP_CHI] = {}
- for k,v in ipairs(roomInfo.chiPaiList) do
- table.insert(opCardList[ZPDef.OpCode.OP_CHI],v)
- end
- self:showOpeation(operateCode,opCardList,self.isQiShou,true)
- self:setOutCardVisible(true,viewId,nCard,false,nil,true)
- elseif roomInfo.isSubmitOp == 1 or roomInfo.isSubmitOp == 0 or roomInfo.isSubmitOp == 2 then
- self:setOutCardVisible(true,viewId,nCard,false,nil,true)
- end
- elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_AFTER_TURN_OVER == roomInfo.nStatus then
- self.isGodHand = true
- if roomInfo.isSubmitOp == 1 then
- operateCode = 0
- self:playMoPaiAni(diPaiMax,nCard,viewId,operateCode,roomInfo.showCardFlag,nil,true)
- elseif roomInfo.isSubmitOp == 0 then --自己摸牌翻牌
- local isBaoPeiCard = false
- if roomInfo.isBaopeiCard == 1 then
- self.isBiChi = 2
- end
- if roomInfo.isBaopeiGuo == 1 then
- self.isTishi = true
- end
- self:playMoPaiAni(diPaiMax,nCard,viewId,operateCode,roomInfo.showCardFlag,nil,true,isBaoPeiCard,roomInfo.chiPaiList,roomInfo.pengCardlist)
- elseif roomInfo.isSubmitOp == 2 then --比牌不显示出牌或者摸牌
- operateCode = 0
- self:playMoPaiAni(diPaiMax,nCard,viewId,operateCode,roomInfo.showCardFlag,nil,true)
- self.operationView:touchEatOneCardCallBack(true)
- end
- elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_QIANGBA == roomInfo.nStatus then
- if operateCode ~= 0 and roomInfo.isSubmitOp == 0 then
- opCardList[ZPDef.OpCode.OP_HU] = {}
- table.insert(opCardList[ZPDef.OpCode.OP_HU],nCard)
- self:showOpeation(operateCode,opCardList,false,true)
- end
- end
-
- --显示剩余牌
- --如果有出的牌,则闹钟显示在该玩家,如果没有则显示在等待操作的玩家
- if nCard > 0 then
- self:setCircleCardLeftPanelView(true,viewId,diPaiMax)
- else
- self:setCircleCardLeftPanelView(true,curOpView,diPaiMax)
- end
-
-
- elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OUT_CARDS == roomInfo.nStatus or ZPDef.ReconnectState.GAME_STATUS_WAIT_BANKER_OUTCARD == roomInfo.nStatus then --等待玩家出牌中
- --显示底牌
- self.isQiShou = false
- self.isGodHand = true
- local viewId = app.room:getViewIdBySeatId(roomInfo.showCardSeatId)
- --显示剩余牌
- self:setCircleCardLeftPanelView(true,viewId,diPaiMax)
- if viewId == self:getMeViewId() then
- self.isGodHand = false
- self:setGuideView(true)
- self.bOutCard = true
- end
- elseif ZPDef.ReconnectState.GAME_STATUS_AUTO_DISCSRD == roomInfo.nStatus then --玩家自动弃牌中
- self.isQiShou = false
- self.isGodHand = true
- local nSeatId = roomInfo.showCardSeatId
- local nCard = roomInfo.disCard
- local viewId = app.room:getViewIdBySeatId(nSeatId)
- --显示剩余牌
- self:setCircleCardLeftPanelView(true,viewId,diPaiMax)
- --弃牌
- self:playQiPaiAni(true,nCard,viewId,nil)
- elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_BAO == roomInfo.nStatus then --等待玩家爆牌中
- --爆牌中
- self.isGodHand = true
- local viewId = app.room:getViewIdBySeatId(roomInfo.showCardSeatId)
- self:setCircleCardLeftPanelView(true,viewId,diPaiMax)
- for k,v in pairs(roomInfo.arrayTableInfo) do
- local viewId = app.room:getViewIdByUserId(k)
- local nBankerSeatId = app.room.roomInfo.nBankSeatId
- local toujiaviewId = app.room:getViewIdBySeatId(nBankerSeatId)
-
- if viewId == self:getMeViewId() and viewId ~= toujiaviewId then
- app.room.roomInfo.tingCards = {}
- end
- --等待爆牌状态
- if v.nBaoPaiStatus == 1 and k == app.user.loginInfo.uid then
- self.operationView:showBaoPaiOpView(true)
- end
- end
-
-
- self.ui.Items.ImageView_tou_tip:setVisible(true)
- end
-
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-ZPRoomView - self:addCallBack(runOnGameReconnection)" )
- self:addCallBack(runOnGameReconnection)
-
- else
- --未开局正常坐下这里会进来
- for k,v in pairs(roomInfo.memberList or {}) do
- local viewId = app.room:getViewIdByUserId(k)
- local nOffLineState = v.nOnlineStatus or 1
- --显示离线
- self.PlayerView:setPlayerOffLine(nOffLineState ~= 1,viewId)
- end
-
- --未开局重连坐下
- for k,v in pairs(roomInfo.arrayTableInfo or {}) do
- local viewId = app.room:getViewIdByUserId(k)
- local nOffLineState = v.nOnlineStatus
- --显示离线
- self.PlayerView:setPlayerOffLine(nOffLineState ~= 1,viewId)
- end
-
- self.ui.Items.Layout_fapaiqi:setVisible(false)
- end
- end
-
-
- --断线重连
- function doushisiRoomView:recontactDoOperation(viewId,list,optype)
- logD("doushisiRoomView recontactDoOperation")
- if optype == ZPDef.SendCardType.TOU_THREE_SAME or optype == ZPDef.SendCardType.CHI_PAI_PENG then
- for k,v in ipairs(list) do
- self.opOutCard[viewId]:addGroupCard(v,1)
- end
- elseif optype == ZPDef.SendCardType.BA_FOUR_SAME then
- for k,v in ipairs(list) do
- self.opOutCard[viewId]:addGroupCard(v,1)
- end
- elseif optype == ZPDef.SendCardType.TWO_SUM_CHI then
- for k,v in ipairs(list) do
- self.opOutCard[viewId]:addGroupCard(v,1)
- end
- end
-
- end
-
-
- -- 立即开始
- function doushisiRoomView:onQuickStartResponse(event)
- log("2000000000-doushisiRoomView - runnQuickStartResponse()" )
- if not event or not event.response then
- return
- end
- logE("onQuickStartResponse() response = ", event.response)
- local response = event.response
- --app.room.roomInfo.nShowDismiss = true
- local isStart = true
- local selectNums = table.nums(app.room.quickStartInfo)
-
- for i,v in pairs(app.room.quickStartInfo) do
- if v > 1 then
- --有人投过票
- isStart = false
- end
- end
-
- if tolua.isnull(self.quickStartView) then
- for i,v in pairs(app.room.quickStartInfo) do
- if v == 1 then
- self.quickStartView = ZPRoomQuickStartView:new(i);
- self.quickStartView:setAnchorPoint(cc.p(0.5, 0.5));
- app:showWaitDialog(self.quickStartView);
- log("onQuickStartResponse() v = 1 "..i )
- return
- else
- local startuid = 0
- for i,v in pairs(app.room.quickStartInfo) do
- if v == 1 then
- startuid = i
- end
- end
- self.quickStartView = ZPRoomQuickStartView:new(startuid);
- self.quickStartView:setAnchorPoint(cc.p(0.5, 0.5));
- app:showWaitDialog(self.quickStartView);
- log("onQuickStartResponse() v ~= 1 "..i )
- return
- end
- end
- end
- end
-
- --更新房间基础数据
- function doushisiRoomView:updateRoomBaseData()
- --初始化背景
- local ZiPaigameBgPicture = "gameBgPicture"..(ZPDef.GameID or app.gameId)
- local idx2 = tonumber(loadUserInfo(ZiPaigameBgPicture)) or 2
- self:setTableImg(idx2)
-
- local roomInfo = app.room.roomInfo;
-
- -- 房间号
- self.ui.Items.Text_roomNum:setText(tostring(roomInfo.nShowTableId));
-
- --局数
- self:updateGameNums()
-
- --房间玩法
- --local ruleAll = ZPFuc.getRuleInfo();
- --self.toolView.ui.Items.Text_Rule:setText(ruleAll)
- self:setRoomInfo()
-
- self:onUserReadyResponse()
-
- for i = 1,ZPDef.GameMaxPlayer do
- self.PlayerView:updatePlayerInfo(i)
- end
-
- -- 是否显示邀请好友
- self:setWetChatVisible(table.nums(app.room.roomInfo.memberList) < ZPFuc.getCreateRoomPlayerNum())
- self.toolView:showFastStart(true)
-
- if isReviewVersion() then
- self:setWetChatVisible(false);
- end
-
- -- 更新玩家手牌列表时,按需显示
- if app.room.roomInfo.nGameStartCount > 0 then
- self:setWetChatVisible(false)
- end
- if app.room.roomInfo.nGameStartCount == 0 then
- self.ui.Items.Button_tipai:setVisible(false)
- end
- end
-
- function doushisiRoomView:setTableImg(idx)
- local name = string.format("zp_doushisi/res/ui/zy_fangjian/bg/fangjian_di_%d.jpg",idx)
- --桌布
- self.ui.Items.ImageView_bg:loadTexture(name)
-
- local cacheGameBgPic = "gameBgPicture"..(ZPDef.GameID or app.gameId)
-
- saveUserInfo(cacheGameBgPic,idx)
- end
-
- function doushisiRoomView:loadTextureCache()
- doushisiRoomView.super.loadTextureCache(self)
-
- ZPFuc.loadSpriteFromFile("zp_doushisi/res/ui/zy_fangjian/cards/zy_dss_handcards.plist")
- ZPFuc.loadSpriteFromFile("zp_doushisi/res/ui/zy_fangjian/cards/zy_dss_outCard.plist")
- ZPFuc.loadSpriteFromFile("zp_doushisi/res/ui/zy_fangjian/cards/zy_dss_hu_cards.plist")
- end
-
- --改变外发光颜色
- function doushisiRoomView:changeOutCardLight(isMoPai)
- end
-
- --隐藏提示界面
- function doushisiRoomView:setGuideView(bVisible)
- if app.room:isLittleFamily() then
- bVisible = false
- end
- self.ui.Items.Layout_tips:setVisible(false)
- self.ui.Items.Button_OutCard:setVisible(false)
- self.ui.Items.Button_OutCard:setEnabled(false)
- self.ui.Items.ImageView_OutCard_tip:setVisible(bVisible)
- --[[ if bVisible then
- self.ui.Items.ImageView_3:playClip("tip")
- end--]]
- end
-
-
-
-
- --隐藏出牌点
- function doushisiRoomView:setOutCardVisible(bVisible,viewId,card,isSend,onEnd,isNoShowAni)
- for i = 1 ,ZPDef.GameMaxPlayer do
- local name = string.format("Layout_outCardPoint_%d",i)
- self.ui.Items[name]:setVisible(false)
- end
-
- --重置出牌坐标
- self:resetOutCardPoint()
- --显示出牌
- if bVisible then
- self.isMoPaiOperator = false
- self:changeOutCardLight(false)
- local name = string.format("Layout_outCardPoint_%d",viewId)
- local mLayout = self.ui.Items[name]
- mLayout:setVisible(true)
- local imgName = string.format("ImageView_outCardImg_%d",viewId)
- local fileName = PokerUtil.pokerPng(card,ZPDef.CardType.CARD_TYPE_HAND)
- local mSprite = self.ui.Items[imgName]
- local srcPos = mSprite:getPosition()
- self.ui.Items[imgName]:loadTextureFromPlist(fileName)
-
- local beginPos
- local time = self.gameSpeedConfig.CHU_PAI_TIME
- if viewId == self:getMeViewId() then
- beginPos = self.ui.Items.ImageView_handTempCard:getPosition()
- beginPos = mSprite:getParent():convertToNodeSpace(beginPos)
- else
- if viewId == 1 then
- beginPos = cc.p(srcPos.x + 400,srcPos.y)
- elseif viewId == 2 then
- beginPos = cc.p(srcPos.x,srcPos.y + 200)
- elseif viewId == 3 then
- beginPos = cc.p(srcPos.x - 400,srcPos.y)
- end
- end
-
- mSprite:setPosition(beginPos)
- mSprite:setScale(0)
-
- if isNoShowAni then
- mSprite:setScale(1)
- mSprite:setPosition(srcPos)
- if onEnd then
- onEnd()
- end
- return
- end
-
- local spawn = cc.Spawn:create(cc.ScaleTo:create(time,1,1),cc.MoveTo:create(time,srcPos))
- local seq = cc.Sequence:create(spawn,cc.CallFunc:create(function ()
- if isSend then
- local request = ZPMessage.OutCard:new()
- request.nCard = card
- --默认包赔为0
- request.baoPei = 0
- logE("doushisiRoomView:setOutCardVisible"..table.tostring(request))
- self.ui:sendMsg(app.room, "sendOutCard", request, function(status, response)
- logE("doushisiRoomView sendOutCard() response = ", table.tostring(response))
- end)
- end
- if onEnd then
- onEnd()
- end
- end))
- mSprite:runAction(seq)
- end
- end
-
-
-
- function doushisiRoomView:initGameButton()
- --出牌按钮
- self.ui.Items.Button_OutCard:registerClick(function()
- local value = self.ui.Items.ImageView_handTempCard.value
- --send sender
- self.isGodHand = true;
- self.touchPoker:setOpacity(0)
- self:setCardNormal()
- self:sendOutCard(value)
- self.bOutCard = false
- end)
- --提牌按钮
- self.ui.Items.Button_tipai:registerClick(function()
- self:requestFlashHandCard()
- end)
- --暂时屏蔽提牌功能
- self:showTiPaiBtn(true)
-
- --点击空白
- self.ui.Items.Layout_Touch:registerClick(nil,function()
- --[[ local list = {13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13}
- for i = 1,ZPDef.GameMaxPlayer do
- for k,v in pairs(list) do
- self.opOutCard[i]:addGroupCard(v,1)
- end
- end--]]
-
-
- --[[ for i = 1 ,ZPDef.GameMaxPlayer do
- self:setOutCardVisible(true,i,13,false,nil,true)
- end--]]
-
-
-
- --[[ for i = 1,ZPDef.GameMaxPlayer do
- self.PlayerView.allNodes[i].player:setVisible(true)
- end
-
- local fapaiList = {
- [1] = {
- list = {0,0,0,0,0,0,0,0},
- num = 8,
- viewId = 4,
- },
- [2] = {
- list = {0,0,0,0,0,0,0},
- num = 8,
- viewId = 3,
- },
- [3] = {
- list = {0,0,0,0,0,0,0},
- num = 8,
- viewId = 2,
- },
- [4] = {
- list = {0,0,0,0,0},
- num = 8,
- viewId = 1,
- }
- }
-
- --self:sendCards(fapaiList)
-
- self:runAction(cc.Sequence:create(cc.CallFunc:create(function()
- self:sendCards(fapaiList)
- end),cc.DelayTime:create(0.8),cc.CallFunc:create(function()
- local viewId = self:getMeViewId()
- local lens = table.nums(self._selfCards[viewId])
- self.handCardItem = self._selfCards[viewId]
-
- for i = 1,lens do
- local card = self._selfCards[viewId][i]:getVal()
- table.insert(self.handCardValueLocal,card)
- end
- --注册点击
- self:registerCardTouch()
- if onEnd then
- onEnd()
- end
- end)))--]]
-
- --隐藏工具界面 详情
- if self.toolView.ui.Items.ImageView_Rule_bg then
- self.toolView.ui.Items.ImageView_Rule_bg:setVisible(false)
- end
- self.ui.Items.Layout_Rule:setVisible(false)
- self.ui.Items.Button_wanfa:setVisible(true)
- end)
-
- -- 玩法
- self.ui.Items.Button_wanfa:registerClick(function ()
- playBtnEffect()
- self.ui.Items.Layout_Rule:setVisible(not self.ui.Items.Layout_Rule:isVisible())
- self.ui.Items.Button_wanfa:setVisible(false)
- end)
-
- if app.room.roomInfo.nGameStartCount and app.room.roomInfo.nGameStartCount > 0 then
- self.ui.Items.Layout_Rule:setVisible(false)
- else
- self.ui.Items.Layout_Rule:setVisible(true)
- self.ui.Items.Button_wanfa:setVisible(false)
- self.ui.Items.Layout_Rule:runAction(cc.Sequence:create(
- cc.DelayTime:create(2),
- cc.CallFunc:create(function()
- self.ui.Items.Layout_Rule:setVisible(false)
- self.ui.Items.Button_wanfa:setVisible(true)
- end)))
- end
-
- self.ui.Items.Text_Rule:setVisible(false)
- local bar = self.ui.Items.ListView:getVBar()
- bar:setVisible(false)
- end
-
-
- function doushisiRoomView:showXiaojia()
- self.PlayerView:hideXiaoJia()
- --只显示当前的庄家座位号
- local nBankerSeatId = app.room.roomInfo.xiaoSeatId
- local viewId = app.room:getViewIdBySeatId(nBankerSeatId)
- self.PlayerView:setPlayerXiaoJiaVisible(viewId,true)
- end
-
-
- --更新头家家
- function doushisiRoomView:updateBanker()
- --隐藏所有的庄家头家标志
- self.PlayerView:setBankerVisible()
- self.PlayerView:hideTouJia()
- --只显示当前的庄家座位号
- local nBankerSeatId = app.room.roomInfo.nBankSeatId
- local viewId = app.room:getViewIdBySeatId(nBankerSeatId)
- if self.PlayerView:setPlayerTouJiaVisible(viewId,true) then
-
- else
- showTooltip("头家椅子号"..nBankerSeatId.."不匹配")
- end
- end
- -- 游戏开始
- function doushisiRoomView:onGameStartResponse()
-
- local function runGameStartResponse(onEnd)
- log("2000000000-doushisiRoomView - runGameStartResponse()" )
-
- self.ui.Items.Layout_fapaiqi:setVisible(true)
-
- local actualNum = app.room:getActualPlayerNum()
- --重置玩家数据
- self:resetGameData()
- app.room.roomInfo.tingCards = {}
- app.room.roomInfo.disCard = {}
-
- if not tolua.isnull(self.quickStartView) then
- self.quickStartView:removeView()
- self.quickStartView = nil
- end
-
- --写入数据
- for k,v in pairs(app.room.roomInfo.memberList) do
- v.nPlayerFlag = 2
- end
-
- --更新玩家状态状态
- self:onUserReadyResponse()
-
- -- 隐藏邀请好友
- self:setWetChatVisible(false)
- self.toolView:showFastStart(false)
-
- -- 更新局数
- self:updateGameNums()
- --更新位置
- app.room:updateUserSeateShowId()
-
- for k,v in pairs(app.room.roomInfo.memberList) do
- local nSeatShowId = app.room:getViewIdByUserId(v.nUserId)
- self.PlayerView:updatePlayerInfo(nSeatShowId)
- end
- --更新庄家
- self:updateBanker()
- self:showXiaojia()
-
-
- --翻牌
- local fanpaiSeatid = app.room.roomInfo.fanpaiSeatId
- local fanCard = app.room.roomInfo.fanpaiValue
- local fanViewId = app.room:getViewIdBySeatId(fanpaiSeatid)
-
- local function callback()
- self:playMoPaiAni(app.room.roomInfo.leftCardNum,fanCard,1,0,1,nil,false)
- end
-
- local function call_func()
- self:setOutCardVisible(false)
- local toujiaId = app.room.roomInfo.nBankSeatId
- local toujiaViewId = app.room:getViewIdBySeatId(toujiaId)
- self.PlayerView:setPlayerTouJiaVisible(toujiaViewId,true)
- end
-
- local seq = cc.Sequence:create(cc.CallFunc:create(callback),cc.DelayTime:create(1),cc.CallFunc:create(call_func),cc.CallFunc:create(function()
- if onEnd then
- onEnd()
- end
- end))
-
- self.ui:runAction(seq)
-
-
-
- end
- log("2000000000-doushisiRoomView - addCallBack(runGameStartResponse)" )
- self:addCallBack(runGameStartResponse);
- end
-
-
- function doushisiRoomView:onGameSendCardResponse()
- local function runGameSendCardResponse(onEnd)
- self.PlayerView:stopAndHideBaoAnim()
- log("2000000000-doushisiRoomView - runGameSendCardResponse()" )
- if self.taiPaiTimer then
- cc.Director:getInstance():getScheduler():unscheduleScriptEntry(self.taiPaiTimer)
- end
-
- --显示指示器
- local bankerViewId = app.room:getViewIdBySeatId(app.room.roomInfo.nBankSeatId)
- local leftCardNum = app.room.roomInfo.leftCardNum
- self:setCircleCardLeftPanelView(true,bankerViewId,leftCardNum)
-
- --发牌
- self:createCard(true,app.user.loginInfo.uid,onEnd)
-
- print("ding piao:"..table.tostring(app.room.roomInfo.memberList))
- self.ui.Items.Button_tipai:setVisible(false)
-
- local xiaojiaViewId = app.room:getViewIdBySeatId(app.room.roomInfo.xiaoSeatId)
-
- local toujiaViewId = app.room:getViewIdBySeatId(app.room.roomInfo.nBankSeatId)
-
- self.toolView:showTuoGuan(app.room.roomInfo.hosting==1)
-
- end
- log("2000000000-doushisiRoomView - addCallBack(runGameSendCardResponse)" )
- self:addCallBack(runGameSendCardResponse);
- end
-
- function doushisiRoomView:setFaPaiQiPanelView(bVisible,viewId,leftNum)
- if viewId and leftNum then
- if not self.fapaiqiLeftCard then
- self.fapaiqiLeftCard = {}
- local bgsize = self.ui.Items.ImageView_card_bg:getContentSize()
- local posNum = self.ui.Items.TextBMFont_leftCardNum:getPosition()
- for i = 1,tonumber(leftNum) do
- self.fapaiqiLeftCard[i] = cc.ImageView:createNode()
- self.fapaiqiLeftCard[i]:loadTexture("zp_doushisi/res/ui/zy_fangjian/cardBG.png")
- self.ui.Items.ImageView_card_bg:addChild(self.fapaiqiLeftCard[i])
- self.fapaiqiLeftCard[i]:setPosition(cc.p(bgsize.width/2,bgsize.height/2+i*0.5))
- if i > 36 then
- self.fapaiqiLeftCard[i]:setVisible(false)
- else
- self.ui.Items.TextBMFont_leftCardNum:setPositionY(posNum.y + i*0.5)
- self.ui.Items.ImageView_zhang:setPositionY(posNum.y + i*0.5)
- end
- end
- else
- local posNum = self.ui.Items.TextBMFont_leftCardNum:getPosition()
- for i = #self.fapaiqiLeftCard,leftNum+1,-1 do
- self.fapaiqiLeftCard[i]:removeFromParent()
- self.fapaiqiLeftCard[i] = nil
- if i <= 36 then
- self.ui.Items.TextBMFont_leftCardNum:setPositionY(posNum.y - 0.5)
- self.ui.Items.ImageView_zhang:setPositionY(posNum.y - 0.5)
- end
- end
- end
- self.ui.Items.TextBMFont_leftCardNum:setText(tostring(self.leftNum))
- end
- end
-
-
- -- 发牌
- function doushisiRoomView:recoverHandCards()
-
- local fapaiList = app.room.roomInfo.fapaiList
-
- for round = 1,8 do
- for i = 1,#fapaiList do
- local cardlist = fapaiList[i].list
- if cardlist and cardlist[round] then
- local index = round
- local card = cardlist[index]
- if card then
- local viewId = fapaiList[i].viewId
- local num = fapaiList[i].num
- self:sendOneCardNoAction(card,index,viewId,index == num, num,true)
- end
- end
- end
- end
- end
-
- -- 发一张牌
- function doushisiRoomView:sendOneCardNoAction( card, i, viewId, islast, allCount ,isStart)
- local node = PokerCardNode:new(ZPDef.CardType.CARD_TYPE_HAND)
- node:setScale(DoushisiRoomConfig.CARD_SCALE[viewId])
-
- local startPos = DoushisiRoomConfig.CARD_FAPAI_POS[viewId]
- node:setPosition(startPos)
- node:setCard(card)
- if viewId == 1 or viewId == 2 then
- node:setLocalZOrder(8 - i)
- else
- node:setLocalZOrder(i)
- end
-
- local cardNode = string.format("LayoutMain_%d",viewId)
-
- self.ui.Items[cardNode]:addChild(node)
- --self.ui.Items.Layout_HandCard:addChild(node)
-
- local pt = cc.p(0, 0)
- pt = clone(DoushisiRoomConfig.CARD_START_POS[viewId])
- if viewId == self:getMeViewId() then
- pt.x = CENTER_X
- local midIdx = allCount/2
- if i<=midIdx then--左边
- pt.x = pt.x - (midIdx-i-1)*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
- else--右边
- pt.x = pt.x + (i-midIdx+1)*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
- end
- pt.x = pt.x - DoushisiRoomConfig.CARD_WIDTH/2*DoushisiRoomConfig.CARD_SCALE[viewId]
- elseif viewId == 3 then
- pt.x = pt.x + i*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
- else
- pt.x = pt.x - i*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
- end
-
-
- if viewId == self:getMeViewId() and islast then
- if isStart and allCount == 8 then
- pt.x = pt.x + DoushisiRoomConfig.CARD_WIDTH/2*DoushisiRoomConfig.CARD_SCALE[viewId]
- end
-
- if not isStart then
- pt.x = pt.x + DoushisiRoomConfig.CARD_WIDTH/2*DoushisiRoomConfig.CARD_SCALE[viewId]
- end
- end
-
- table.insert(self._selfCards[viewId], node)
- if viewId == self:getMeViewId() then
- table.insert(self.handCardRoot,node)
- table.insert(self.handCardValueLocal,card)
- end
-
-
- --发牌的时候直接注册点击事件
- self:registerCardTouch(node)
-
- node:setPosition(pt)
-
- return node
- end
-
-
- -- 发牌
- function doushisiRoomView:sendCards()
-
- local fapaiList = app.room.roomInfo.fapaiList
-
- local delay = 0
-
- for round = 1,8 do
- for i = 1,#fapaiList do
- local cardlist = fapaiList[i].list
- if cardlist and cardlist[round] then
- local index = round
- local card = cardlist[index]
- if card then
- local viewId = fapaiList[i].viewId
- local num = fapaiList[i].num
- local ac = cc.Sequence:create(cc.DelayTime:create(delay),cc.CallFunc:create(function()
- self:sendOneCard(card,index,viewId,index == num, num,true)
- end))
- self:runAction(ac)
- delay = delay + 0.02
- end
- end
- end
- end
- end
-
- -- 发一张牌
- function doushisiRoomView:sendOneCard( card, i, viewId, islast, allCount ,isStart)
- local node = PokerCardNode:new(ZPDef.CardType.CARD_TYPE_HAND)
- node:setScale(DoushisiRoomConfig.CARD_SCALE[viewId])
-
- local startPos = DoushisiRoomConfig.CARD_FAPAI_POS[viewId]
- node:setPosition(startPos)
- node:setCard(card)
- if viewId == 1 or viewId == 2 then
- node:setLocalZOrder(8 - i)
- else
- node:setLocalZOrder(i)
- end
-
- local cardNode = string.format("LayoutMain_%d",viewId)
-
- self.ui.Items[cardNode]:addChild(node)
- --self.ui.Items.Layout_HandCard:addChild(node)
-
- local pt = cc.p(0, 0)
- pt = clone(DoushisiRoomConfig.CARD_START_POS[viewId])
- if viewId == self:getMeViewId() then
- pt.x = CENTER_X
- local midIdx = allCount/2
- if i<=midIdx then--左边
- pt.x = pt.x - (midIdx-i-1)*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
- else--右边
- pt.x = pt.x + (i-midIdx+1)*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
- end
- pt.x = pt.x - DoushisiRoomConfig.CARD_WIDTH/2*DoushisiRoomConfig.CARD_SCALE[viewId]
- elseif viewId == 3 then
- pt.x = pt.x + i*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
- else
- pt.x = pt.x - i*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
- end
-
-
- if viewId == self:getMeViewId() and islast then
- if isStart and allCount == 8 then
- pt.x = pt.x + DoushisiRoomConfig.CARD_WIDTH/2*DoushisiRoomConfig.CARD_SCALE[viewId]
- end
-
- if not isStart then
- pt.x = pt.x + DoushisiRoomConfig.CARD_WIDTH/2*DoushisiRoomConfig.CARD_SCALE[viewId]
- end
- end
-
- local ac = nil
-
- ac = cc.Sequence:create(cc.Spawn:create(cc.MoveTo:create(0.05, pt), cc.FadeIn:create(0.1)), cc.CallFunc:create(function ()
- table.insert(self._selfCards[viewId], node)
- if viewId == self:getMeViewId() then
- table.insert(self.handCardRoot,node)
- table.insert(self.handCardValueLocal,card)
- end
- playVoiceGiveCard()
- end), cc.DelayTime:create((i)*0.01))
-
- --发牌的时候直接注册点击事件
- self:registerCardTouch(node)
- node:runAction(ac)
-
- return node
- end
-
-
- function doushisiRoomView:createCard(bShowAnimation,nUserID,onEnd)
- logE("====================doushisiRoomView:createCard()===================");
- local toujiaViewId = app.room:getViewIdBySeatId(app.room.roomInfo.nBankSeatId)
- if bShowAnimation then
- self.ui:runAction(cc.Sequence:create(cc.CallFunc:create(function()
- self:sendCards()
- end),cc.DelayTime:create(0.8),cc.CallFunc:create(function()
- --排序
- --self:RankCard()
- if onEnd then
- onEnd()
- end
- end)))
- else
- self:recoverHandCards()
- --排序
- --self:RankCard()
- self:neatenCard()
- if onEnd then
- onEnd()
- end
- end
- end
-
-
- --注册点击事件
- function doushisiRoomView:registerCardTouch(node)
- local function getPosOO()
- local nodeTouch = self.ui.Items.Layout_Touch;
- local posTouch = nodeTouch:getWorldPosition()
- local poaAnchor = nodeTouch:getAnchorPoint()
- local sizeTouch = nodeTouch:getContentSize();
- local posOO = { x = posTouch.x - sizeTouch.width * poaAnchor.x , y = posTouch.y - sizeTouch.height * poaAnchor.y}
-
- return posOO;
- end
-
- local function onTouchBegan(touch)
- if self.isGodHand then
- return
- end
-
- if not node._canTouch then
- return
- end
- local posOO = getPosOO()
- local localPos = touch:getLocation();
- local pos = cc.p(localPos.x - posOO.x, localPos.y - posOO.y);
-
- self.touchPoker = node
-
- local touchNode = node.imgBg
-
- local value = touchNode.value
-
- --v:setOpacity(0)
-
- if value == 0 then
- return
- end
- logE("88888888-=============onTouchBegan1================")
- logE("88888888-touch value:",value)
- logE("玩家点了"..value)
-
- logE("88888888-card :"..table.tostring(self.handCardValueLocal))
- logE("88888888-=============onTouchBegan2================")
- self.touchPoker = node
-
- if not node:isDoWn() then
- self:setCardNormal()
- local pt = touchNode:getPosition()
- touchNode:setPosition(cc.p(pt.x, pt.y+40))
- self.ui.Items.Button_OutCard:setEnabled(true)
- else
- local value = touchNode.value
-
- if value == nil then
- showTooltip("牌已经操作过!")
- return
- end
-
- if not self.bOutCard then
- self:setCardNormal()
- self.ui.Items.Button_OutCard:setEnabled(false)
- return
- end
-
- self.ui.Items.ImageView_handTempCard:setVisible(false)
-
- touchNode:setOpacity(0)
-
- self:sendOutCard(value)
- logE("玩家出牌:"..value)
- self.bOutCard = false
- self.isGodHand = true;
-
- self.ui.Items.ImageView_handTempCard.value = value
- end
-
- --临时牌
- self.ui.Items.ImageView_handTempCard.value = value
- self.ui.Items.ImageView_handTempCard:setVisible(false)
- self.ui.Items.ImageView_handTempCard:loadTextureFromPlist(PokerUtil.pokerPng(value,ZPDef.CardType.CARD_TYPE_HAND))
- self.ui.Items.ImageView_handTempCard:setPosition(pos)
-
- end
- local function onTouchMove(touch)
- if self.isGodHand then
- return
- end
-
- if not node._canTouch then
- return
- end
-
- local touchNode = node.imgBg
- local posOO = getPosOO()
- local localPos = touch:getLocation();
- local prePos=touch:getPreviousLocation()
- local pos = cc.p(localPos.x - posOO.x, localPos.y - posOO.y);
-
- local pos1 = cc.p(prePos.x - posOO.x, prePos.y - posOO.y)
-
- if self._isMove then
- touchNode:setOpacity(0)
- self.ui.Items.ImageView_handTempCard:setVisible(true)
- self.ui.Items.ImageView_handTempCard:setPosition(localPos)
- return
- end
-
- local x=math.abs(pos.x-pos1.x)
- local y=math.abs(pos.y-pos1.y)
- if x > 5 and y > 5 and (not self._isMove) then
- self._isMove = true
- --touchNode:setOpacity(0)
- --self.ui.Items.ImageView_handTempCard:setVisible(true)
- --self.ui.Items.ImageView_handTempCard:setPosition(pos)
- --touchNode:setPosition(pos)
- end
-
-
- end
- local function onTouchEnd(touch)
- if self.isGodHand then
- return
- end
-
- if not node._canTouch then
- return
- end
- local touchNode = node.imgBg
- logE("88888888-=============onTouchEnd1================")
- if not self.ui.Items.ImageView_handTempCard:isVisible() then
- touchNode:setOpacity(255)
- self.ui.Items.ImageView_handTempCard:setVisible(false)
- return
- end
- self._isMove = false
- self.ui.Items.ImageView_handTempCard:setVisible(false)
- --出牌线
- self:setOutCardLineVisible(false)
- if not touchNode.value then
- return
- end
- touchNode:setOpacity(255)
- --回到原点动画
- self:goBackWithAni(touchNode,0.15)
- logE("88888888-=============onTouchEnd2================")
- end
- local function onTouchCancel(touch)
- if self.isGodHand then
- return
- end
-
- if not node._canTouch then
- return
- end
- local touchNode = node.imgBg
- --self:setColorWhite()
- logE("88888888-=============onTouchCancel 1================")
- --出牌线
- self:setOutCardLineVisible(false)
- if not self.ui.Items.ImageView_handTempCard:isVisible() then
- --showTooltip("cancel 临时牌阻止了事件")
- touchNode:setOpacity(255)
- self.ui.Items.ImageView_handTempCard:setVisible(false)
- return
- end
- self.ui.Items.ImageView_handTempCard:setVisible(false)
-
- if not touchNode.value then
- return
- end
-
- touchNode:setOpacity(255)
- --临时牌
- self.ui.Items.ImageView_handTempCard:setVisible(false)
- local touchPos = touch:getLocation()
-
- --@part:牌取消回来,出牌逻辑的实现
- --判断是否大于出牌点
- if touchPos.y > self.ui.Items.ImageView_line:getPosition().y and self.bOutCard then
- if app.room:isLittleFamily() then
- return
- end
- local value = touchNode.value
- --比牌的时候,在比牌间隔点到了牌,拖出去报错
- if value == nil then
- showTooltip("牌已经操作过!")
- return
- end
-
- --send sender
- touchNode:setOpacity(0)
- self:sendOutCard(value)
- logE("玩家出牌:"..value)
- self.bOutCard = false
- self.isGodHand = true;
-
- self.ui.Items.ImageView_handTempCard.value = value
-
- else
- logE("牌回到原来的位置")
- --回到原点动画
- self:goBackWithAni(touchNode,0.15)
- end
-
- -------------------------------------------------------
- -------------------------------------------------------
- logE("88888888=============onTouchCancel 2================")
- logE("88888888-onTouchCancel :card :"..table.tostring(self.handCardValueLocal))
-
- end
-
- node:addCardTouchEventListener(onTouchBegan,onTouchMove,onTouchEnd,onTouchCancel)
-
- end
-
-
- function doushisiRoomView:setCardNormal()
- self.ui.Items.Button_OutCard:setEnabled(false)
- for k,v in pairs(self.handCardRoot) do
- v:setNormal()
- end
- end
-
- function doushisiRoomView:showOpeation(mainOpCode,card,isQiShou,hasGuo)
- logD("doushisiRoomView showOpeation",mainOpCode)
- self.operationView:setVisible(true)
- self.operationView:setSameParame(self.outCard,self.handCardValueLocal)
- local ret1 = bit32.band(mainOpCode,ZPDef.OpCode.OP_TIAN_HU)
- if ret1 > 0 then
- hasGuo = false
- end
- if self.isBiChi and self.isBiChi == 2 then
- hasGuo = false
- end
- self.operationView:showOperation(mainOpCode,card,isQiShou,hasGuo,self.isTishi)
- --检测是否少牌
- --self:neatenCard(true)--无感知的整理一次手牌
- self:checkCardAndRecover()
- self.isTishi = false
- end
-
- --检测是否少牌,如果少牌则恢复 --目前在抓牌,出牌成功,和显示操作三个地方检测少牌情况
- function doushisiRoomView:checkCardAndRecover()
- end
-
- --玩家出牌操作
- function doushisiRoomView:sendOutCard(nCard)
- if self.isGameOver then
- return
- end
- --直接给用户显示出牌效果,数据删除在出牌成功后,如果出牌失败,出牌效果消失,用户可以重新出牌哦
- self:setOutCardVisible(true,self:getMeViewId(),nCard,true,nil,false)
- end
-
- --弃牌
- function doushisiRoomView:onQiPai(data)
- local function runOnQiPai(onEnd)
- self:hideOperation()
- logE("2000000000-doushisiRoomView onQiPai : "..table.tostring(data.response))
- local response = data.response
- local nUserId = response.nUserId
- local disCard = response.disCard
- local viewId = app.room:getViewIdByUserId(nUserId)
- self:playQiPaiAni(true,disCard,viewId,onEnd)
- end
- log("2000000000-doushisiRoomView - addCallBack(runOnQiPai)")
- self:addCallBack(runOnQiPai)
- end
-
-
- --发牌后偷牌巴牌的操作
- function doushisiRoomView:onUserOperateResponse(data)
- local function runUserOperate(onEnd)
- log("2000000000-doushisiRoomView - (runUserOperate)")
- logE("runUserOperate :"..table.tostring(data.response))
- self.isQiShou = true
- self.isGodHand = true
- if data.response.nUserId == app.room:getMyUserId() then
- if data.response.mainOpCode ~= ZPDef.OpCode.OP_ERROR or data.response.mainOpCode ~= ZPDef.OpCode.OP_ERROR then
- local ishu = data.response.ishu
- local hasGuo = true
- local operationCardlist = {}
- local opeateCode = data.response.mainOpCode
- self.outCard = 0
- if #data.response.BacardList > 0 then
- operationCardlist[ZPDef.OpCode.OP_BA_QI_SHOU] = {}
- for k,v in pairs(data.response.BacardList or {}) do
- table.insert(operationCardlist[ZPDef.OpCode.OP_BA_QI_SHOU],v)
- end
- end
- --操作码
- if #data.response.ToucardList > 0 then
- operationCardlist[ZPDef.OpCode.OP_TOU_QI_SHOU] = {}
- local toulist = {}
- for k,v in pairs(data.response.ToucardList or {}) do
- for _,value in pairs(v.cardlist) do
- table.insert(toulist,value)
- end
- table.insert(operationCardlist[ZPDef.OpCode.OP_TOU_QI_SHOU],toulist)
- toulist = {}
- end
- end
-
- local mainOpCode = data.response.mainOpCode
-
- local retHu = bit32.band(mainOpCode,ZPDef.OpCode.OP_HU)
- local retHu1 = bit32.band(mainOpCode,ZPDef.OpCode.OP_TIAN_HU)
-
-
- if ishu == 1 and self.isQiShou and retHu1 > 0 then
- hasGuo = false
- end
-
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- self.operationLocalCode = opeateCode
- if self.operationLocalCode > 0 then
- self:showOpeation(opeateCode,operationCardlist,self.isQiShou,hasGuo)
- end
- --self:setTotalTuoNum(data.response.totalTuoNum)
- local myViewId = self:getMeViewId()
- self:setGuideView(false)
- self.bOutCard = false
- end
- end
-
- self.ui.Items.ImageView_tou_tip:setVisible(true)
-
- local operations = {}
- --操作码
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- operations[viewId] = {}
- operations[viewId].nUserId = data.response.nUserId
- operations[viewId].isCanOpereate = 1
- self:showDelayTimeTip(operations)
-
- if onEnd then
- onEnd()
- end
- end
-
-
- log("2000000000-doushisiRoomView - addCallBack(runUserOperate)")
- self:addCallBack(runUserOperate);
- end
-
-
- function doushisiRoomView:lockYouPai(list)
- for _,value in ipairs(list or {}) do
- for k,v in pairs(self.handCardRoot) do
- if v:getVal() == value then
- v:setYouIconVis(true)
- v:setCardTouchEnabled(false)
- end
- end
- end
- end
-
-
- function doushisiRoomView:onBroadCastBankerOutCard(data)
- local function runBankerOutCardd(onEnd)
- logE("2000000000-doushisiRoomView runBankerOutCardd :"..table.tostring(data.response))
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- --吃后不能出的牌
- self.isQiShou = false
- if data.response.nUserId == app.room:getMyUserId() then
- self.isGodHand = false
- app.room.roomInfo.disCard = {}
-
- for k,v in ipairs(data.response.disCard or {}) do
- table.insert(app.room.roomInfo.disCard,v)
- end
-
- --[[ for k,v in ipairs(data.response.afterbadisCard or {}) do
- table.insert(app.room.roomInfo.disCard,v)
- end--]]
-
- self:lockYouPai(app.room.roomInfo.disCard)
- self:setGuideView(true)
- self.bOutCard = true
- end
-
- self.ui.Items.ImageView_tou_tip:setVisible(false)
-
- self:setCircleCardLeftPanelView(true,viewId,self.leftNum)
- if onEnd then
- onEnd()
- end
- end
-
- log("2000000000-doushisiRoomView - addCallBack(runBankerOutCardd)")
- self:addCallBack(runBankerOutCardd);
- end
-
-
- --提示报叫
- function doushisiRoomView:onTingCardResult(data)
- local function runTingCardResult(onEnd)
- logE("2000000000-doushisiRoomView runTingCardResult :"..table.tostring(data.response))
- local response = data.response
- local tingCards = response.tingCards
- local nBankerSeatId = app.room.roomInfo.nBankSeatId
- local viewId = app.room:getViewIdBySeatId(nBankerSeatId)
-
- self.isGodHand = true
-
- if viewId == self:getMeViewId() then
- app.room.roomInfo.tingCards = response.tingCards or {}
- else
- app.room.roomInfo.tingCards = {}
- end
-
- if onEnd then
- onEnd()
- end
- local isCanBao = response.canBaoPai
- if isCanBao == 1 then
- self.operationView:showBaoPaiOpView(true)
- end
- end
- log("2000000000-doushisiRoomView - addCallBack(runTingCardResult)")
-
- self:addCallBack(runTingCardResult)
- end
-
-
-
- --爆牌结果
- function doushisiRoomView:onBaoPaiResponese(data)
- local function runBaoPai(onEnd)
- logE("2000000000-doushisiRoomView onBaoPaiResponese :"..table.tostring(data.response))
- local response = data.response
- local uid = response.nUserId
- local viewId = app.room:getViewIdByUserId(uid)
- --玩家选择了爆牌 播放爆牌动画
- if response.optType == 1 then
- self:showOperatorTip(viewId,-55)
- --self.PlayerView:playBaoAnim(viewId)
- self.PlayerView:setPlayerBaoJiaoVisible(viewId,true)
- if uid == app.room:getMyUserId() then
- self.baoJiaoStatus = 1
- self:lockMyHandCards()
- end
- end
-
- if uid == app.room:getMyUserId() then
- self:hideOperation()
- end
-
- self:runAction(cc.Sequence:create(cc.DelayTime:create(0.5),cc.CallFunc:create(function ()
- if onEnd then
- onEnd()
- end
- end)))
- end
- log("2000000000-doushisiRoomView - addCallBack(onBaoPaiResponese)")
- self:addCallBack(runBaoPai)
- end
-
-
- function doushisiRoomView:lockMyHandCards()
- --先把手牌全部锁了
- for k,v in pairs(self.handCardRoot) do
- v:setZheZhaoVis(true)
- v:setCardTouchEnabled(false)
- end
- for _,val in pairs(app.room.roomInfo.tingCards or {}) do
- for _,v in pairs(self.handCardRoot) do
- if v:getVal() == val then
- v:setCardTouchEnabled(true)
- v:setZheZhaoVis(false)
- end
- end
- end
- end
-
-
- --包赔提示
- function doushisiRoomView:onOutCardIsBaoPeiResponse(data)
- local baoPeiCard = data.response.bCard
- local view = import("zp_doushisi.luaScript.Views.Room.doushisiRoomBaoPei"):new(baoPeiCard,0)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
-
-
-
- function doushisiRoomView:reflashHandCards()
-
- --[[ local handCard = self:ChangeDataToVector(self.handCardValueBak)
- local sendCardResult = app.room:rankHandCard(handCard)
- local newCardList
- newCardList = app.room:serverCardToMyCard(sendCardResult)
-
- self.ui.Items.LayoutMain_4:removeAllChildren()
-
- self.handCardRoot = {}
- self.handCardItem = {}
- self.handCardValueLocal = {}
- self.handCardValueBak = {}
-
- local myUserID = app.room:getMyUserId()
-
- app.room.cards[myUserID] = newCardList
-
- self:createCard(false,myUserID,nil)--]]
-
- end
-
-
- --出牌成功
- function doushisiRoomView:onOutCardSuccess(data)
-
- local function runOnOutCardSuccess(onEnd)
- logE("2000000000-doushisiRoomView runOnOutCardSuccess :"..table.tostring(data.response))
- --设置出牌动画隐藏
- self:setGuideView(false)
- --只要出了牌就不是起手操作了
- self.isQiShou = false
-
- local response = data.response
- local nUserId = response.nOutCardUserId
- local card = response.byOutCard
- local operateCode = response.mainOpCode
- local leftHandCardNum = response.leftHandCardNum
- local isBaoPei = response.isBaopei
- local opCardList = response.opCardList
- local pengCardList = response.CanOpPengCard
-
- if isBaoPei == 1 then
- self.isBiChi = 2
- else
- self.isBiChi = 0
- end
-
- local viewId = app.room:getViewIdByUserId(nUserId)
-
-
- self.moPaiViewId = viewId
- --隐藏出牌
- self.bOutCard = false
- --记录真实牌值
- self.outCard = card
- --记录操作码
- self.EatOperationCode = operateCode
-
- self:showDelayTimeTip()
-
- self.PlayerView:setLeftCardNum(viewId,true,leftHandCardNum)
- if viewId == self:getMeViewId() then
- self.myHandCardNums = leftHandCardNum
- end
- --self.PlayerView:setNoOpTime(false,viewId)
- logE("my userid :"..app.room:getMyUserId())
- logE("out card response nUserId:"..nUserId)
-
- local userInfo=app.room:getUserInfo(nUserId)
- if userInfo then
- ZPSound.PlayZPSound(userInfo.sex,card)
- else
- ZPSound.PlayZPSound(1,card)
- end
- local operationCardlist = {}
-
- if operateCode ~= ZPDef.OpCode.OP_CANCEL and operateCode ~= ZPDef.OpCode.OP_ERROR then
- operationCardlist[ZPDef.OpCode.OP_PENG] = {}
- local penglist = {}
- for k,v in pairs(pengCardList or {}) do
-
- for _,val in pairs(v.cardlist or {}) do
- table.insert(penglist,val)
- end
- table.insert(operationCardlist[ZPDef.OpCode.OP_PENG],penglist)
- penglist = {}
- end
-
- operationCardlist[ZPDef.OpCode.OP_HU] = {}
- table.insert(operationCardlist[ZPDef.OpCode.OP_HU],card)
- operationCardlist[ZPDef.OpCode.OP_CHI] = {}
- for k,v in ipairs(opCardList) do
- table.insert(operationCardlist[ZPDef.OpCode.OP_CHI],v)
- end
- end
-
- if nUserId ~= app.room:getMyUserId() then
- if operateCode ~= ZPDef.OpCode.OP_CANCEL and operateCode ~= ZPDef.OpCode.OP_ERROR then
- self:showOpeation(operateCode,operationCardlist,self.isQiShou,true)
- end
- --其他玩家显示
- local lens = table.nums(self._selfCards[viewId])
- if lens > 0 and self._selfCards[viewId][lens] then
- self._selfCards[viewId][lens]:removeFromParent()
- table.remove(self._selfCards[viewId],lens)
- end
- self:setOutCardVisible(true,viewId,card,false,onEnd)
-
- else
- self.isGodHand = true
- local function rankDeletOneCard(card)
- local isEnd = false
- local lens = table.nums(self.handCardRoot)
-
- for i = lens, 1, -1 do
- if self.handCardRoot[i]:getVal() == card then
- self.handCardRoot[i]:removeFromParent()
- table.remove(self.handCardRoot, i)
- isEnd = true
- break
- end
- end
-
- local lens =table.nums(self.handCardValueLocal)
- for i = lens, 1, -1 do
- if self.handCardValueLocal[i] == card then
- table.remove(self.handCardValueLocal,i)
- isEnd = true
- break
- end
- end
- end
-
- if app.room.roomInfo.hosting == 1 and self.touchPoker and not tolua.isnull(self.touchPoker) then
- self.touchPoker.imgBg:setOpacity(255) --把已经在移动的牌还原
- self.touchPoker = nil --托管出牌服务器发什么就出什么,要把移动的牌清空
- end
- --说明:数据校验:弱网棋牌的通病(麻将出牌等一切可以允许玩家自己插牌的游戏,需要注意弱网情况,出牌会出现删错牌)
- --判断该列是否有牌
- if table.nums(self.handCardValueLocal) > 0 then
- --二次校验牌数据是否是出牌数据
- local recordValue = 0
- if self.touchPoker then
- recordValue = self.touchPoker:getVal()
- end
-
- if recordValue == card then
- logE("delete card2 ============= :"..card)
- local lens =table.nums(self.handCardValueLocal)
- for i = lens, 1, -1 do
- if self.handCardValueLocal[i] == card then
- table.remove(self.handCardValueLocal,i)
- isEnd = true
- break
- end
- end
-
- local index = 0
- for i = lens, 1, -1 do
- if self.handCardRoot[i]:getVal() == card and self.handCardRoot[i] == self.touchPoker then
- self.handCardRoot[i]:removeFromParent()
- table.remove(self.handCardRoot, i)
- isEnd = true
- break
- end
- end
- else
- --随机删掉手里那张牌
- rankDeletOneCard(card)
- end
- else
- --随机删掉手里那张牌
- rankDeletOneCard(card)
- end
-
- if app.room.roomInfo.hosting == 1 then
- self.ui.Items.ImageView_handTempCard:setVisible(false) --托管出牌的时候要把自己点击在桌面上的牌清理掉
- self:setOutCardVisible(true,viewId,card,false, function () end)
- end
-
- self:rankDeletOneBakCard(card)
- --self:reflashHandCards()
- self:neatenCard(true)
- if onEnd then
- onEnd()
- end
- --检查是否少牌
- self:checkCardAndRecover()
-
- --设置坨数
- --self:setTotalTuoNum(data.response.totoltuoNum)
- local myViewId = self:getMeViewId()
-
- if viewId == self:getMeViewId() then
- self:unLockYouPai()
- end
-
- if self.baoJiaoStatus == 1 then
- app.room.roomInfo.tingCards = {}
- self:lockMyHandCards()
- end
- end
-
- end
- log("2000000000-doushisiRoomView - addCallBack(runOnOutCardSuccess)")
- self:addCallBack(runOnOutCardSuccess)
- end
-
-
- --整理牌
- function doushisiRoomView:neatenCard(isMoPai)
- self:setCardNormal()
-
- local handcardlist = self.handCardValueLocal
-
- local resulthandData = app.room:rankHandCard(handcardlist)
-
- local lens = table.nums(resulthandData)
-
- for i = 1, lens do
- local pos
- if isMoPai then
- pos = self:getMeCardPosition(i, lens + 1)
- else
- pos = self:getMeCardPosition(i, lens)
- end
- for k,v in pairs(self.handCardRoot) do
- if v:getVal() == resulthandData[i] and not v._hasSet then
- v:setHasSet(true)
- v:setPosition(pos)
- v:setLocalZOrder(i)
- break
- end
- end
- end
-
- for k,v in pairs(self.handCardRoot) do
- v:setHasSet(false)
- end
-
- end
-
-
- function doushisiRoomView:getMeCardPosition(i,allCount)
- local viewId = self:getMeViewId()
- local pt = cc.p(0,0)
- pt = clone(DoushisiRoomConfig.CARD_START_POS[viewId])
- pt.x = CENTER_X
- local midIdx = allCount/2
- if i<=midIdx then--左边
- pt.x = pt.x - (midIdx-i-1)*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
- else--右边
- pt.x = pt.x + (i-midIdx+1)*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
- end
- pt.x = pt.x - DoushisiRoomConfig.CARD_WIDTH/2*DoushisiRoomConfig.CARD_SCALE[viewId]
-
- return pt
- end
-
-
- function doushisiRoomView:doOperation(operationType,viewId,card,onEnd,isChilaiBao)
- if operationType == ZPDef.OpType.OP_TYPE_CHI then
- self:Chi(viewId,card,onEnd)
- if isChilaiBao and isChilaiBao == 1 then
- self:showOperatorTip(viewId,-56)
- else
- self:showOperatorTip(viewId,operationType)
- end
- elseif operationType == ZPDef.OpType.OP_TYPE_PENG then
- self:Peng(viewId,card,onEnd)
- self:showOperatorTip(viewId,operationType)
- elseif operationType == ZPDef.OpType.OP_TYPE_BA then
- self:Ba(viewId,card,onEnd)
- self:showOperatorTip(viewId,operationType)
- elseif operationType == ZPDef.OpType.OP_TYPE_FANPAI_BA then
- self:BaFan(viewId,card,onEnd)
- self:showOperatorTip(viewId,operationType)
- elseif operationType == ZPDef.OpType.OP_TYPE_LAI_PENG then
- self:Peng(viewId,card,onEnd)
- self:showOperatorTip(viewId,operationType)
- elseif operationType == ZPDef.OpType.OP_TYPE_TOU then
- self:Tou(viewId,card,onEnd)
- self:showOperatorTip(viewId,operationType)
- elseif operationType == ZPDef.OpType.OP_TYPE_HU then
- self:showOperatorTip(viewId,operationType)
- end
- end
-
-
- function doushisiRoomView:removeHandByNums(card,nums)
- local nums = nums
- local lens = table.nums(self.handCardRoot)
-
- --判断是否是癞子
- if math.floor(card/16) == 5 then
- card = 0x5e
- end
-
- local isFind = false
- local index = 0
- for i = 1,lens do
- if self.handCardRoot[i]:getVal() == card and nums > 0 then
- nums = nums - 1
- self.handCardRoot[i]:removeFromParent()
- index = i
- isFind = true
- break
- end
- end
-
- if isFind then
- table.remove(self.handCardRoot,index)
- table.remove(self.handCardValueLocal,index)
- end
- end
-
- --用户吃(手动)
- function doushisiRoomView:Chi(viewId,cards,onEnd)
- logD("function do Chi")
- logE("doushisiRoomView chi:",table.tostring(cards))
-
-
- local chilist = {}
-
- --吃的牌放下面
- table.insert(chilist, self.chiCard)
- table.insert(chilist, cards[1])
-
- logE("doushisiRoomView chilist:",chilist)
-
- local nUserID = app.room:getUserIdByViewId(viewId)
-
-
- for k,v in ipairs(chilist) do
- self.opOutCard[viewId]:addGroupCard(v,1)
- end
-
- if viewId == self:getMeViewId() then
- local card = cards[1]
- self:removeHandByNums(card,1)
- self:neatenCard()
- else
- local num = 1
- for i = 1, num do
- local lens = table.nums(self._selfCards[viewId])
- if lens > 0 and self._selfCards[viewId][lens] then
- self._selfCards[viewId][lens]:removeFromParent()
- table.remove(self._selfCards[viewId],lens)
- end
- end
- end
- if onEnd then
- onEnd()
- end
- end
-
-
- --用户碰(手动)
- function doushisiRoomView:Peng(viewId,cards,onEnd)
- logD("function do Peng")
- logE("doushisiRoomView Peng:",table.tostring(cards))
-
- local penglist = {}
- --吃的牌放下面
- table.insert(penglist, self.chiCard)
- for _,v in pairs(cards or {}) do
- table.insert(penglist, v)
- end
-
- for k,v in pairs(penglist or {}) do
- self.opOutCard[viewId]:addGroupCard(v,1)
- end
-
-
- if viewId == self:getMeViewId() then
- for k,v in pairs(cards) do
- self:removeHandByNums(v,1)
- end
- self:neatenCard(true)
- else
- local num = 2
- for i = 1, num do
- local lens = table.nums(self._selfCards[viewId])
- if lens > 0 and self._selfCards[viewId][lens] then
- self._selfCards[viewId][lens]:removeFromParent()
- table.remove(self._selfCards[viewId],lens)
- end
- end
- end
- if onEnd then
- onEnd()
- end
- end
-
-
- --用户偷(手动)
- function doushisiRoomView:Tou(viewId,cards,onEnd)
- logD("function do Tou")
- logE("doushisiRoomView Tou:",table.tostring(cards))
-
- for k,v in pairs(cards or {}) do
- self.opOutCard[viewId]:addGroupCard(v,1)
- end
-
- if viewId == self:getMeViewId() then
- for k,v in pairs(cards) do
- self:removeHandByNums(v,1)
- end
- self:neatenCard(true)
- else
- local num = 3
- for i = 1, num do
- local lens = table.nums(self._selfCards[viewId])
- if lens > 0 and self._selfCards[viewId][lens] then
- self._selfCards[viewId][lens]:removeFromParent()
- table.remove(self._selfCards[viewId],lens)
- end
- end
- end
- if onEnd then
- onEnd()
- end
- end
-
-
- --进牌之后巴(手动)
- function doushisiRoomView:Ba(viewId,cards,onEnd)
- logD("function do Ba")
- logE("doushisiRoomView Ba:",table.tostring(cards))
-
- local operateCode = self.operationSuccessCode
-
- for k,v in pairs(cards or {}) do
- self.opOutCard[viewId]:addBaCard(v,1)
- end
-
- if viewId == self:getMeViewId() then
- for k,v in pairs(cards) do
- self:removeHandByNums(v,1)
- end
- self:neatenCard(true)
- else
- local num = 1
- for i = 1, num do
- local lens = table.nums(self._selfCards[viewId])
- if lens > 0 and self._selfCards[viewId][lens] then
- self._selfCards[viewId][lens]:removeFromParent()
- table.remove(self._selfCards[viewId],lens)
- end
- end
- end
-
- if onEnd then
- onEnd()
- end
- end
-
-
- --翻牌巴(手动)
- function doushisiRoomView:BaFan(viewId,cards,onEnd)
- logD("function do BaFan")
- logE("doushisiRoomView BaFan:",table.tostring(cards))
-
- local operateCode = self.operationSuccessCode
-
- for k,v in pairs(cards or {}) do
- self.opOutCard[viewId]:addBaCard(v,1)
- end
- if onEnd then
- onEnd()
- end
- end
-
-
-
- --起手偷巴操作
- function doushisiRoomView:onUserOperateSuccess(data)
- local function runUserOperateSuccess(onEnd)
- log("2000000000-doushisiRoomView - (runUserOperateSuccess)")
- logE("runUserOperateSuccess :"..table.tostring(data.response))
- local response = data.response
- local nUserId = response.nUserId
- local opType = response.operateCodes
- local opCard = response.opCard
- local totoalTuoNum = response.totalTuoNum
- local leftCardNum = tonumber(response.leftCardNum)
-
- self.operationSuccessCode = opType
-
- local viewId = app.room:getViewIdByUserId(nUserId)
-
- if opType == ZPDef.OpCode.OP_TOU_QI_SHOU or opType == ZPDef.OpCode.OP_TOU_ZHUA then --偷
- self:doOperation(ZPDef.OpType.OP_TYPE_TOU,viewId,opCard,nil)
- elseif opType == ZPDef.OpCode.OP_BA_QI_SHOU or opType == ZPDef.OpCode.OP_BA_ZHUA or opType == ZPDef.OpCode.OP_BA_FAN then
- self:doOperation(ZPDef.OpType.OP_TYPE_BA,viewId,opCard,nil)
- end
-
- if viewId == self:getMeViewId() then
- self:hideOperation()
- end
-
- if viewId ~= 4 then
- self.PlayerView:setLeftCardNum(viewId,true,leftCardNum)
- else
- self.myHandCardNums = leftCardNum
- end
-
- if onEnd then
- onEnd()
- end
- end
-
- log("2000000000-doushisiRoomView - addCallBack(runUserOperateSuccess)")
- self:addCallBack(runUserOperateSuccess);
- end
-
-
- --弃牌动画
- --断线重连的时候,不需要动画
- --[[
- isShowAni:是否展示弃牌动画
- disCard:弃牌
- viewId:视图ID
- isDianPaoPeng:碰胡规则,点炮碰,弃牌要显示透明形态
- ]]
- function doushisiRoomView:playQiPaiAni(isShowAni,disCard,viewId,onEnd,isDianPaoPeng)
- local outCardname = string.format("ImageView_outCardImg_%d",viewId)
- local outCardPoint = string.format("Layout_outCardPoint_%d",viewId)
- local giveupCardname = string.format("Layout_giveUp_%d",viewId)
-
- --牌的图片
- local outCardImg = self.ui.Items[outCardname]
- --牌的图片父节点
- local outCardLayout = self.ui.Items[outCardPoint]
-
- local giveUpLayout = self.qiPaiView[viewId]
-
- --[[ --弃牌的layout
- local giveUpLayout = self.ui.Items[giveupCardname]
- --获取弃牌节点存在的数量
- local count = giveUpLayout:getChildrenCount()
- --创建一张精灵
- local mSprite = cc.ImageView:createNode()
- mSprite:setScale(self.littleCardScale)
- local finalFileName = PokerUtil.pokerPng(disCard,ZPDef.CardType.CARD_TYPE_GROUP_OUT)
- mSprite:loadTextureFromPlist(finalFileName)
- mSprite:setVisible(false)
- mSprite:setAnchorPoint(cc.p(0,0))
- mSprite.value = disCard
- giveUpLayout:addChild(mSprite)--]]
-
-
-
- --[[ local width = mSprite:getContentSize().width * self.littleCardScale;
- local height = mSprite:getContentSize().height* self.littleCardScale;
-
- local getHeightCount = function (count)
- if count >= 6 then
- return math.floor(count/6)
- else
- return 0
- end
- end
-
- local x = 0
-
- x = count % 6
-
- local tarPos
- if viewId == 1 then
- local adjustPos = cc.p(width * x,height * getHeightCount(count))
- tarPos = cc.p(adjustPos.x,0 - adjustPos.y)
- elseif viewId == 2 then
- local adjustPos = cc.p(width * x,getHeightCount(count) * height)
- tarPos = cc.p(adjustPos.x,0 - adjustPos.y)
- elseif viewId == 3 then
- local adjustPos = cc.p(width * x,height * getHeightCount(count))
- tarPos = cc.p(0 + adjustPos.x,0 - adjustPos.y)
- elseif viewId == self:getMeViewId() then
- local adjustPos = cc.p(width * x,height * getHeightCount(count))
- tarPos = cc.p(adjustPos.x,0 - adjustPos.y)
- end
-
- mSprite:setPosition(tarPos)--]]
-
- local tarPos = self.qiPaiView[viewId]:getQiPiaPosition()
- self.qiPaiView[viewId]:addQiPaiCard(disCard,isShowAni)
-
- --动画显示
- if not isShowAni then
- --mSprite:setVisible(true)
- --[[ if isDianPaoPeng and isDianPaoPeng == 1 then
- if self.colorType == ZPDef.ColorType.White then
- mSprite:setColor(cc.c3b(255,223,125))
- else
- mSprite:setColor(cc.c3b(255,226,111))
- end
- end--]]
- else
- local fileName = PokerUtil.pokerPng(disCard,ZPDef.CardType.CARD_TYPE_HAND)
- --弃牌
- local giveSprite = cc.ImageView:createNode()
- giveSprite:loadTextureFromPlist(fileName)
- giveSprite:setScale(self.outCardScale)
- giveUpLayout:addChild(giveSprite)
- giveSprite:setVisible(false)
-
- local spriteSizeWidth = giveSprite:getContentSize().width * self.outCardScale
- local spriteSizeHeight = giveSprite:getContentSize().height * self.outCardScale
- local worldPos = outCardImg:convertToWorldSpace(outCardImg:getPosition())
- local nodePos = giveUpLayout:convertToNodeSpace(worldPos)
- --调整上下2个玩家的坐标和牌的角度
- if viewId == 2 or viewId == 4 then
- --nodePos = cc.p(nodePos.x - spriteSizeWidth,nodePos.y - spriteSizeHeight/2)
- --giveSprite:setEulerRotation(cc.vec3(0,0,90))
- end
- giveSprite:setPosition(nodePos)
-
-
- local mSpawn = cc.Spawn:create(cc.MoveTo:create(self.gameSpeedConfig.QI_PAI_TIME,tarPos),cc.ScaleTo:create(self.gameSpeedConfig.QI_PAI_TIME,self.outCardScale - 0.7))
- giveSprite:runAction(cc.Sequence:create(cc.DelayTime:create(0.3),cc.CallFunc:create(function()
- outCardLayout:setVisible(false)
- giveSprite:setVisible(true)
- end),mSpawn,cc.CallFunc:create(function()
- --mSprite:setVisible(true)
- --[[ if isDianPaoPeng and isDianPaoPeng == 1 then
- if self.colorType == ZPDef.ColorType.White then
- mSprite:setColor(cc.c3b(255,223,125))
- else
- mSprite:setColor(cc.c3b(255,226,111))
- end
- end--]]
- self.qiPaiView[viewId]:showAllQiPaiCard()
- end),cc.RemoveSelf:create()))
-
- --要求弃牌飞到一半,摸牌就开始摸了
- --[[ mSprite:runAction(cc.Sequence:create(cc.DelayTime:create(0.4 + self.gameSpeedConfig.QI_PAI_TIME/2),cc.CallFunc:create(function ()
- if onEnd then
- onEnd()
- end
- end)))--]]
- self.ui:runAction(cc.Sequence:create(cc.DelayTime:create(0.4 + self.gameSpeedConfig.QI_PAI_TIME/2),cc.CallFunc:create(function ()
- if onEnd then
- onEnd()
- end
- end)))
- end
- end
-
-
- --出牌错误
- function doushisiRoomView:onOutCardError(data)
- local function runOnOutCardError(onEnd)
- logE("doushisiRoomView:onOutCardError(), response = ", table.tostring(data.response))
- self.isGodHand = false--出牌错误了,可以操作牌
- --隐藏出牌效果
- self:setOutCardVisible(false)
- --恢复出的那张牌的透明度
- if self.touchPoker then
- self.touchPoker.imgBg:setOpacity(255)
- end
- self.bOutCard = true
- self:neatenCard()
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-doushisiRoomView - addCallBack(runOnOutCardError)")
- self:addCallBack(runOnOutCardError)
- end
-
-
-
- --摸牌
- function doushisiRoomView:onMoPai(data)
- local function runOnMoPai(onEnd)
- logE("doushisiRoomView:runOnMoPai(), response = ", table.tostring(data.response))
- local response = data.response
- local nUserId = response.nUserId
- local turnOverCard = response.turnOverCard
- local code = response.mainOpCode
- local leftCardNum = response.leftCardNum
- --local operations = response.operations
- local isBaopeiChi = response.Baopeichi
- local chiOpCardlist = response.chiOpCardList
- local pengOpCardlist = response.canPengOpCard
-
- if isBaopeiChi == 1 then
- self.isTishi = true
- end
-
- self.isBiChi = isBaopeiChi
-
- local viewId = app.room:getViewIdByUserId(nUserId)
- self.EatOperationCode = code
- self.outCard = turnOverCard
- self.moPaiViewId = viewId
-
- self:showDelayTimeTip()
-
- --更新剩余牌数
- self:playMoPaiAni(leftCardNum,turnOverCard,viewId,code,1,onEnd,false,isBaopeiChi,chiOpCardlist,pengOpCardlist)
-
- if self.bankerBaoPao then
- self.bankerBaoPao = nil
- self:showTiPaiBtn(true)
- --小家不能看牌时,牌堆牌显示剩余张数
- if app.room:isLittleFamily() and (not ZPFuc.getLittleIsCanLookCard()) then
- self:setCircleCardLeftPanelView(true,viewId,19)
- end
- end
- if self:getIsMeUId(nUserId) then
- --检测是否少牌
- self:checkCardAndRecover()
- end
-
- --[[ --结束 一定要等到摸牌动画结束才结束整个摸牌流程
- if onEnd then
- onEnd()
- end--]]
- end
- log("2000000000-doushisiRoomView - addCallBack(runOnMoPai)")
-
- self:addCallBack(runOnMoPai)
- end
-
-
-
- --播放摸牌动画
- --[[
- leftCardNum:剩余牌
- turnOverCard: 摸的牌
- viewId:视图ID
- mainOpCode:操作码
- showCardFlag:是否显示牌 0;不能 1:能
- isNotShowAni:不显示动画
- ]]
- function doushisiRoomView:playMoPaiAni(leftCardNum,turnOverCard,viewId,mainOpCode,showCardFlag,onEnd,isNotShowAni,isBaopeiChi,chiOpCardList,pengOpCardlist)
- self.isMoPaiOperator = true
-
- --重置出牌坐标
- self:resetOutCardPoint()
-
- --图片
- local outCardname = string.format("ImageView_outCardImg_%d",viewId)
- local outCardLayoutName = string.format("Layout_outCardPoint_%d",viewId)
- local mSprite = self.ui.Items[outCardname]
- local srcPos = mSprite:getPosition()
- local fileName = ""
- local fileNameReal = PokerUtil.pokerPng(turnOverCard,ZPDef.CardType.CARD_TYPE_HAND)
-
- self.ui.Items[outCardLayoutName]:setVisible(true)
-
- if viewId == self:getMeViewId() then
- mSprite:loadTextureFromPlist(fileNameReal)
- end
-
- --公谱出牌不串不哨立马亮牌,看到亮牌的听得到牌的音效
- if mainOpCode ~= ZPDef.OpCode.OP_CANCEL and mainOpCode ~= ZPDef.OpCode.OP_ERROR then
- mSprite:loadTextureFromPlist(fileNameReal)
- else
- if showCardFlag == 1 then
- mSprite:loadTextureFromPlist(fileNameReal)
- if not isNotShowAni then
- local nUserId = app.room:getUserIdByViewId(viewId)
- local userInfo=app.room:getUserInfo(nUserId)
- if userInfo then
- if turnOverCard > 0 then
- ZPSound.PlayZPSound(userInfo.sex,turnOverCard)
- end
- end
- end
- else
- mSprite:loadTextureFromPlist(fileName)
- end
- end
-
- self:changeOutCardLight(true)
-
- local function callback()
- local operationCardlist = {}
-
- if mainOpCode ~= ZPDef.OpCode.OP_CANCEL and mainOpCode ~= ZPDef.OpCode.OP_ERROR then
- operationCardlist[ZPDef.OpCode.OP_PENG] = {}
- local penglist = {}
- for k,v in pairs(pengOpCardlist or {}) do
-
- for _,val in pairs(v.cardlist or {}) do
- table.insert(penglist,val)
- end
- table.insert(operationCardlist[ZPDef.OpCode.OP_PENG],penglist)
- penglist = {}
- end
-
- operationCardlist[ZPDef.OpCode.OP_BA_FAN] = {}
- table.insert(operationCardlist[ZPDef.OpCode.OP_BA_FAN],turnOverCard)
-
- operationCardlist[ZPDef.OpCode.OP_HU] = {}
- table.insert(operationCardlist[ZPDef.OpCode.OP_HU],turnOverCard)
- operationCardlist[ZPDef.OpCode.OP_CHI] = {}
- for k,v in ipairs(chiOpCardList or {}) do
- table.insert(operationCardlist[ZPDef.OpCode.OP_CHI],v)
- end
- end
- if mainOpCode ~= ZPDef.OpCode.OP_CANCEL and mainOpCode ~= ZPDef.OpCode.OP_ERROR then
- self.EatOperationCode = mainOpCode
- self:showOpeation(mainOpCode,operationCardlist,self.isQiShou,true)
- end
- end
-
- if isNotShowAni then
- mSprite:setPosition(srcPos)
- callback()
- if onEnd then
- onEnd()
- end
- return
- else
- --local outCardLightName = string.format("ImageView_outCardLight_%d",viewId)
- --self.ui.Items[outCardLightName]:setVisible(false)
- mSprite:setScale(0)
-
- if showCardFlag ~= 1 then
- mSprite:loadTextureFromPlist(fileName)
-
- --起始坐标调整和角度,扫为横的出来
- if viewId == self:getMeViewId() then
- mSprite:setEulerRotation(cc.vec3(0,0,0))
- beginPos = cc.p(srcPos.x,srcPos.y + 200)
- elseif viewId == 1 then
- mSprite:setEulerRotation(cc.vec3(0,0,-90))
- beginPos = cc.p(srcPos.x - 200 ,srcPos.y)
- elseif viewId == 2 then
- mSprite:setEulerRotation(cc.vec3(0,0,0))
- beginPos = cc.p(srcPos.x,srcPos.y - 100)
- elseif viewId == 3 then
- mSprite:setEulerRotation(cc.vec3(0,0,-90))
- beginPos = cc.p(srcPos.x + 200 ,srcPos.y-50)
- end
-
- mSprite:setPosition(beginPos)
-
- --目标调整、角度
- if viewId == 1 then
- srcPos = cc.p(srcPos.x + 250,srcPos.y)
- elseif viewId == 2 then
- srcPos = cc.p(srcPos.x,srcPos.y+50)
- elseif viewId == 3 then
- srcPos = cc.p(srcPos.x - 250,srcPos.y-50)
- elseif viewId == 4 then
- srcPos = cc.p(srcPos.x,srcPos.y-100)
- end
-
- mSprite:setScale(1)
- mSprite:runAction(cc.Sequence:create(cc.MoveTo:create(0.3,srcPos),cc.CallFunc:create(function ()
- --self.ui.Items[outCardLightName]:setVisible(true)
- end),cc.CallFunc:create(function()
- --恢复原来的角度
- if viewId == self:getMeViewId() then
- mSprite:setEulerRotation(cc.vec3(0,0,90))
- elseif viewId == 1 then
- mSprite:setEulerRotation(cc.vec3(0,0,0))
- elseif viewId == 2 then
- mSprite:setEulerRotation(cc.vec3(0,0,90))
- elseif viewId == 3 then
- mSprite:setEulerRotation(cc.vec3(0,0,0))
- end
- self.ui.Items[outCardLayoutName]:setVisible(false)
- self:setCircleCardLeftPanelView(true,viewId,leftCardNum)
- callback()
- if onEnd then
- onEnd()
- end
- end)))
- else
- if mainOpCode ~= ZPDef.OpCode.OP_CANCEL and mainOpCode ~= ZPDef.OpCode.OP_ERROR then
- local nUserId = app.room:getUserIdByViewId(viewId)
- local userInfo=app.room:getUserInfo(nUserId)
- if userInfo then
- ZPSound.PlayZPSound(userInfo.sex,turnOverCard)
- end
- end
- --播放摸牌动画(这里最好用出牌器的坐标进行转换,暂时这样调整吧)
- if viewId == self:getMeViewId() then
- beginPos = cc.p(srcPos.x,srcPos.y + 200)
- elseif viewId == 1 then
- beginPos = cc.p(srcPos.x - 300 ,srcPos.y)
- elseif viewId == 2 then
- beginPos = cc.p(srcPos.x ,srcPos.y - 200)
- elseif viewId == 3 then
- beginPos = cc.p(srcPos.x + 300 ,srcPos.y)
- end
-
- mSprite:setPosition(beginPos)
- local mSpawn = cc.Spawn:create(cc.ScaleTo:create(self.gameSpeedConfig.MO_PAI_TIME,1.0),cc.MoveTo:create(self.gameSpeedConfig.MO_PAI_TIME,srcPos))
- mSprite:runAction(cc.Sequence:create(mSpawn,cc.CallFunc:create(function ()
- --self.ui.Items[outCardLightName]:setVisible(true)
- --显示指示器
- self:setCircleCardLeftPanelView(true,viewId,leftCardNum)
- end),cc.DelayTime:create(0.15),cc.CallFunc:create(function()
- callback()
- if onEnd then
- onEnd()
- end
- end)))
- end
- end
- end
-
-
-
- -- 操作成功
- function doushisiRoomView:onOperationCodeSuccess(data)
- local function runOnOperationSuccess(onEnd)
- log("2000000000-doushisiRoomView - (runOnOperationSuccess)")
- self:hideOperation()
-
- logE("doushisiRoomView:onOperationCodeSuccess :"..table.tostring(data.response))
- local response = data.response
- local nUserID = response.nUserId
- local cards = response.card
- local tablecard = response.tableCard
- local bIsOutCard = response.isShouldOutCard > 0
- local operateCodes = response.operateCodes
- local weaveCardList = response.weaveCardList
- local playerList = response.playerList
- local maxWeave = table.nums(weaveCardList)
- local leftHandCardNum = response.leftHandCardNum
- local isChilaiBao = response.isChilaiBao
-
- self.isBaopei = isChilaiBao
- --local isMoPaiOrId = -1
- --app.room.roomInfo.huType = response.huType
-
- --点炮胡时,表示为点炮用户
- app.room.roomInfo.dianPaoSeatId = response.dianPaoSeatId
-
- --碰胡规则
- if maxWeave > 0 then
- --isMoPaiOrId = weaveCardList[maxWeave].seatId
- end
-
- local cardlist = {}
-
- for k,v in pairs(cards) do
- table.insert(cardlist,v)
- end
-
- local card = 0
-
- if table.nums(cardlist) == 1 then
- card = cardlist[1]
- end
-
-
- --记录操作成功
- self.operationSuccessCode = operateCodes
- self.outCard = card
- self.chiCard = tablecard
-
- --视图ID
- local viewId = app.room:getViewIdByUserId(nUserID)
-
-
- self.PlayerView:setLeftCardNum(viewId,true,leftHandCardNum)
- if viewId == self:getMeViewId() then
- self.myHandCardNums = leftHandCardNum
- end
- --self.PlayerView:setNoOpTime(false,viewId)
- if bIsOutCard then
- for k,v in pairs(app.room.roomInfo.memberList) do
- local operations = {}
- operations[viewId] = {}
- operations[viewId].nUserId = v.nUserId
- operations[viewId].isCanOpereate = 0
- self:showDelayTimeTip(operations)
- end
- end
- local operations = {}
- operations[viewId] = {}
- operations[viewId].nUserId = nUserID
- operations[viewId].isCanOpereate = bIsOutCard and 1 or 0
- self:showDelayTimeTip(operations)
-
-
- --隐藏handTemp
- if viewId == self:getMeViewId() then
- self.isGodHand = true
- --出牌动画 setGuideView延迟了0.5
- self:runAction(cc.Sequence:create(cc.DelayTime:create(0.5),cc.CallFunc:create(function ()
- self:setColorWhite()
- if operateCodes == 0 then--点击过的时候设置可以点牌
- --self.isGodHand = false
- end
- end)))
- self.ui.Items.ImageView_handTempCard:setVisible(false)
- end
-
- --显示指示器
- if bIsOutCard and operateCodes ~= 0 then
- self:setCircleCardLeftPanelView(true,viewId,self.leftNum)
- end
-
- --隐藏操作层
- self:setOperatorPanelView(false,nil)
-
- --判断自己是否需要出牌
- if bIsOutCard and viewId == self:getMeViewId()
- and operateCodes ~= 0
- and operateCodes ~= ZPDef.OpCode.OP_HU then
- self:runAction(cc.Sequence:create(cc.DelayTime:create(0.5),cc.CallFunc:create(function ()
- self:setGuideView(true)
- end)))
- self.bOutCard = true
- end
-
- if self.isTianHu and viewId == self:getMeViewId() then
- self.isTianHu = false
- self:setGuideView(true)
- self.bOutCard = true
- end
-
- --隐藏吃牌层
- self.operationView:setEatCardView(false)
-
- --执行操作
- local code = operateCodes
- logE("doushisiRoomView:onOperationCodeSuccess nOperationCode:"..code)
- local operations = ZPFuc.getZPOperationType(code,false,false)
- local operationType = operations[1]
-
- --体验:等待0.5秒结束
- if operationType ~= ZPDef.OpType.OP_TYPE_HU and operationType ~= ZPDef.OpType.OP_TYPE_CANCEL and operationType ~= nil then
- --吃碰操作
- --隐藏出牌层
- self:setOutCardVisible(false)
- self:doOperation(operationType,viewId,cardlist,onEnd,isChilaiBao)
- elseif operationType == ZPDef.OpType.OP_TYPE_HU then
- --胡牌操作
- --1.隐藏引导出牌动画2.显示胡了哪张牌,3.播放胡牌特效
- self:setGuideView(false)
- local imgName = string.format("ImageView_outCardImg_%d",self.moPaiViewId)
- local mSprite = self.ui.Items[imgName]
- if self.outCard ~= 0 then
- local fileName = PokerUtil.pokerPng(self.outCard,ZPDef.CardType.CARD_TYPE_HAND)
- mSprite:loadTextureFromPlist(fileName)
- end
-
- if operateCodes ~= 0 then
- if onEnd then
- onEnd()
- end
- end
- else
- --self:showOperatorTip(viewId,ZPDef.OpType.OP_TYPE_CANCEL)
- --过
- self:doOperation(ZPDef.OpType.OP_TYPE_CANCEL,viewId,card,nil)
- if onEnd then
- onEnd()
- end
- end
- end
- log("2000000000-doushisiRoomView - addCallBack(runOnOperationSuccess)")
-
- self:addCallBack(runOnOperationSuccess)
- end
-
- function doushisiRoomView:unLockYouPai()
- for k,v in pairs(self.handCardRoot) do
- v:setYouIconVis(false)
- v:setCardTouchEnabled(true)
- end
- end
-
-
-
- function doushisiRoomView:onBroadCastUserGetCard(data)
-
- local function runUserGetCard(onEnd)
- log("2000000000-doushisiRoomView - (runUserGetCard)")
- logE("runUserGetCard :"..table.tostring(data.response))
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- local leftcardNum = data.response.leftCardNum
- local isHouZhua = data.response.isHouZhuaCard
- local mocard = data.response.moCard
-
- local function callback()
- if data.response.nUserId == app.room:getMyUserId() then
- --进牌后解锁油牌
- --如果报叫了则不能解锁
- --先刷新一遍手牌,存在上一轮摸了牌无操作也没出牌的情况
- --self:neatenCard()
- self:unLockYouPai()
- app.room.roomInfo.disCard = {}
- local moValue = data.response.moCard
- self.outCard = 0 --进牌的时候点过可以发0
- self.moValue = moValue
-
- local lens = table.nums(self.handCardRoot)
- local moSepAction = cc.Sequence:create(cc.CallFunc:create(function()
- self:neatenCard(true)
- local node = self:sendOneCard(moValue,lens+1,viewId,true,lens+1,false)
- self.isGodHand = true --播放动画的时候不能点击手牌
- end),
- cc.DelayTime:create(0.2),
- cc.CallFunc:create(function()
- --self.isGodHand = false
- if self.baoJiaoStatus == 1 then
- app.room.roomInfo.tingCards = {}
- table.insert(app.room.roomInfo.tingCards,moValue)
- self:lockMyHandCards()
- end
- if onEnd then
- onEnd()
- end
- end))
-
- self:runAction(moSepAction)
- else
- local moValue = data.response.moCard
- local lens = table.nums(self._selfCards[viewId])
- self:sendOneCard(moValue,lens+1,viewId,true,lens+1,false)
- if onEnd then
- onEnd()
- end
- end
- end
-
-
- local HOUZHUA_TAG = 100
- if isHouZhua == 1 then
- local function call_func()
- self:playMoPaiAni(leftCardNum,mocard,viewId,0,1,nil,false)
- local name = string.format("ImageView_outCardImg_%d",viewId)
- local img = self.ui.Items[name]
- local size = img:getContentSize()
- --后抓精灵
- local mSprite = cc.ImageView:createNode()
- mSprite:loadTexture("zp_doushisi/res/ui/zy_fangjian/btn_effect/effect/houzhua.png")
- img:addChild(mSprite)
- mSprite:setTag(HOUZHUA_TAG)
- mSprite:setPosition(cc.p(size.width/2,size.height/2))
- mSprite:setScale(0.8)
- end
-
- local seq = cc.Sequence:create(cc.CallFunc:create(call_func),cc.DelayTime:create(1.5),cc.CallFunc:create(function()
- self:setOutCardVisible(false)
- local name = string.format("ImageView_outCardImg_%d",viewId)
- local img = self.ui.Items[name]
- for i,child in pairs(img:getChildren()) do
- local tag = child:getTag()
- if tag == HOUZHUA_TAG then
- child:removeFromParent()
- end
- end
- callback()
- end))
-
- self.ui:runAction(seq)
- else
- callback()
- end
-
- local leftCard = data.response.tableCardNum
- self:setCircleCardLeftPanelView(true,viewId,leftCard)
-
- self.PlayerView:setLeftCardNum(viewId,true,leftcardNum)
-
- if viewId == self:getMeViewId() then
- self.myHandCardNums = leftcardNum
- end
-
-
- end
-
- log("2000000000-doushisiRoomView - addCallBack(runUserGetCard)")
- self:addCallBack(runUserGetCard);
- end
-
-
- function doushisiRoomView:onUserGetCardOperteResponse(data)
- local function runonUserGetCardOperte(onEnd)
- log("2000000000-doushisiRoomView - (runonUserGetCardOperte)")
- logE("runonUserGetCardOperte :"..table.tostring(data.response))
- if data.response.nUserId == app.room:getMyUserId() then
- if data.response.mainOpCode ~= ZPDef.OpCode.OP_ERROR then
- self.isGodHand = true
- local operationCardlist = {}
- local opeateCode = data.response.mainOpCode
- local ishu = data.response.ishu
- local hasGuo = true
- self.outCard = 0
- if #data.response.BacardList > 0 then
- operationCardlist[ZPDef.OpCode.OP_BA_ZHUA] = {}
- for k,v in pairs(data.response.BacardList or {}) do
- table.insert(operationCardlist[ZPDef.OpCode.OP_BA_ZHUA],v)
- end
- end
- --操作码
- if #data.response.ToucardList > 0 then
- operationCardlist[ZPDef.OpCode.OP_TOU_ZHUA] = {}
- local toulist = {}
- for k,v in pairs(data.response.ToucardList or {}) do
- for _,value in pairs(v.cardlist) do
- table.insert(toulist,value)
- end
- table.insert(operationCardlist[ZPDef.OpCode.OP_TOU_ZHUA],toulist)
- toulist = {}
- end
- end
-
-
- if ishu == 1 and self.isQiShou then
- hasGuo = false
- end
-
- if not self.isQiShou and ishu == 1 then
- operationCardlist[ZPDef.OpCode.OP_HU] = {}
- table.insert(operationCardlist[ZPDef.OpCode.OP_HU],self.moValue)
- end
-
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- self.operationLocalCode = opeateCode
- if self.operationLocalCode > 0 then
- self:showOpeation(opeateCode,operationCardlist,self.isQiShou,hasGuo)
- self:setGuideView(false)
- self.bOutCard = false
- end
-
- end
- end
-
- local operations = {}
- --操作码
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- operations[viewId] = {}
- operations[viewId].nUserId = data.response.nUserId
- operations[viewId].isCanOpereate = 1
- self:showDelayTimeTip(operations)
-
- if onEnd then
- onEnd()
- end
- end
-
-
- log("2000000000-doushisiRoomView - addCallBack(runonUserGetCardOperte)")
- self:addCallBack(runonUserGetCardOperte);
- end
-
-
- -- 小局结算
- function doushisiRoomView:onGameXiaoJuResponse(data)
- local function runGameXiaoJuResponse(onEnd)
- self:hideOperation()
- self.ui.Items.Button_tipai:setVisible(false)
- self.PlayerView:stopAndHideBaoAnim()
- self.PlayerView:hideLeftCard()
- self.ui.Items.ImageView_tou_tip:setVisible(false)
- --显示所有底牌
- local response = data.response;
-
- --标记单局结束
- self.isGameOver = true
- --禁止出牌
- self.bOutCard = false
-
- local roomInfo = app.room.roomInfo
- --结束原因
- roomInfo.stopFlag = response.stopFlag
- --赢家uid, -1则下面6个字段是无用
- roomInfo.winUserId = response.winUserId
- --点炮胡时,表示为点炮用户
- roomInfo.dianPaoUserId = response.dianPaoUserId
- --胡的类型(如天胡、地胡 ,自摸胡等)
- roomInfo.huType = response.huTypes
- --多少个玩家
- roomInfo.playList = response.playList
- --底牌信息
- roomInfo.dipaiList = response.dipaiList
- --胡牌牌值
- roomInfo.huCard = response.huCard
- --是否大局结束,结束是1
- roomInfo.isGameOver = response.isGameOver
- --胡牌信息
- roomInfo.hupaiInfo = response.hupaiInfo
- --是否自摸胡
- roomInfo.isZiMoHu = response.isZiMoHu
-
- local function showChaPai()
- runDelay(1, function ()
- if not tolua.isnull(self.xiaojuView) then --如果小结算已经被移除,说明此时已经游戏游戏开始了或者结束了,则查牌界面也不用显示了
- self:setLiangPaiVisible(true)
- self.xiaojuView:setVisible(true)
- end
- end)
- end
-
- local isSomebodyHuPai = false
- for i,v in pairs(roomInfo.hupaiInfo) do
- local viewId = app.room:getViewIdByUserId(v.huPaiUid)
- roomInfo.dianPaoUserId = v.dianPaoUid
- roomInfo.baopeiUserid = app.room:getUserIdBySeatId(v.BaoPeiUid)
- roomInfo.fourNormolNum = v.fourNormolNum
- roomInfo.threeNormolNum = v.threeNormolNum
- roomInfo.huCard = v.huCard
- self.PlayerView:setPlayerHuXi(v.huPaiHuShu)
- roomInfo.huType = v.huTypes
- self:playHuEffect(viewId,showChaPai)
-
- isSomebodyHuPai = true
- end
- --所有的暗偎默认亮起一张
- --self:showLastAnWeiPai()
-
- --完成底牌展示
- self.xiaojuChaPaiView:showDiPai()
-
- --如果大局结算了 并且不是正常结束
- if roomInfo.isGameOver == 1 and not isSomebodyHuPai then
- showChaPai()
- end
-
- --完成手牌展示
- for k,v in pairs(roomInfo.playList) do
- local cardData = app.room:serverCardToMyCard(v.handCard)
- if not roomInfo.memberList[v.nUserId] then
- roomInfo.memberList[v.nUserId] = {}
- end
- roomInfo.memberList[v.nUserId].cardList = {}
- roomInfo.memberList[v.nUserId].cardList = cardData
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- end
- self.xiaojuChaPaiView:liangShouPai(false)
-
-
- for k,v in pairs(roomInfo.memberList or {}) do
- local cardData = v.cardList
- local viewId = app.room:getViewIdByUserId(k)
- if viewId == 1 or viewId == 2 then
- cardData = {}
- local lens = table.nums(v.cardList)
- local list = v.cardList
-
- for i = 1,lens do
- cardData[i] = table.remove(list,#list)
- end
- end
-
- if viewId ~= self:getMeViewId() then
- if self._selfCards[viewId] then
- local lens = table.nums(cardData)
- local lens1 = table.nums(self._selfCards[viewId])
- for i = 1, lens do
- if self._selfCards[viewId][i] then
- self._selfCards[viewId][i]:setCard(cardData[i])
- end
- end
- end
- end
- end
-
- --玩家分数
- for k,v in pairs(roomInfo.playList) do
- local viewId = app.room:getViewIdByUserId(k)
- local nScore = v.nTotalMoney
- local memberInfo = app.room.roomInfo.memberList[k]
-
- --[[roomInfo.memberList[v.nUserId].nPlayerFlag = 0--]]
- memberInfo.nTotalMoney = nScore
- self.PlayerView:setPlayerScore(viewId,nScore)
- end
-
-
- --结束原因表现
- if roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_HUANG_ZHUANG or (not isSomebodyHuPai and roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_TUOGUAN_DISMISS) then
- showChaPai()
- --播放黄庄动画
- local userInfo=app.room:getUserInfo(app.user.loginInfo.uid)
- if userInfo then
- ZPSound.PlayHuangZhuang(userInfo.sex)
- end
- self.xiaojuChaPaiView:PlayHuangZhuangAni(true)
- elseif roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_LONG_NOT_END then
- -- showConfirmDialog("游戏长久未打完,超过房间存在时间,本局结束",function()
- -- logE("超时回到大厅")
- -- self:runAction(cc.Sequence:create(cc.DelayTime:create(1.0),cc.CallFunc:create(function ()
- -- --房间号
- -- local roomid = app.room.roomInfo.nShowTableId
- -- --app:gotoView(import("luaScript.Views.Main.MainView"):new(app.gameId, roomid))
- -- gotoMainView(app.gameId,roomid)
- -- end)))
- -- end,nil)
- end
-
- local function nextCallBackFun()
- self:resetGameData()
- app.room.roomInfo.tingCards = {}
- end
-
- local function showAllJieSuan()
- if self.RoomCountAllViewUI then
- if not self.RoomCountAllViewUI:isVisible() then
- self.RoomCountAllViewUI:playAni()
- end
- self.RoomCountAllViewUI:setVisible(true)
- self:showGameOverAward()
- end
- end
-
- if app.room.roomInfo.isGameOver == 0 then
- self.xiaojuView = doushisiRoomXiaoJuView:new(nextCallBackFun,false)
- else
- self.xiaojuView = doushisiRoomXiaoJuView:new(showAllJieSuan,false)
- end
-
- self:addChild(self.xiaojuView)
- self.xiaojuView:setVisible(false)
- --结束
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-doushisiRoomView - addCallBack(runGameXiaoJuResponse)" )
- self:addCallBack(runGameXiaoJuResponse);
- end
-
-
- -- 大局结算
- function doushisiRoomView:onGameDaJuResponse(data)
- app.club_php:dispatchEvent({name = GAME_EVENT.CLUB_BACK_ROOM})
- local function runGameDaJuResponse(onEnd)
- local response = data.response.playList
- -- 打开结算
- local view = ZPRoomCountAllView:new(response,data.response.endTime);
- view:setAnchorPoint(cc.p(0.5, 0.5));
- local visibleSize = getVisibleSize()
- view:setPosition(cc.p(visibleSize.width/2,visibleSize.height/2))
- self:addChild(view);
-
- self.RoomCountAllViewUI = view;
-
- app.room:dispatchEvent({name = GAME_EVENT.DISSMISS_CLOSE});
-
- if true then
- view:playAni()
- view:setVisible(false);
- else
- log("2000000000-onGameDaJuResponse --------- yichangjiesu ")
- --结算直接播放动画
- view:playAni()
- self:showGameOverAward()
- end
-
-
-
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-ZPRoomView - addCallBack(runGameDaJuResponse)")
- self:addCallBack(runGameDaJuResponse);
- end
-
-
- function doushisiRoomView:onQiangBaResponese(data)
- local function runQiangBa(onEnd)
- log("2000000000-doushisiRoomView - addCallBack(onQiangBaResponese)" )
- local response = data.response
- local nUserId = response.nUserId
- local Card = response.nCard
- local code = response.mainOpCode
-
- local viewId = app.room:getViewIdByUserId(nUserId)
-
- local operationCardlist = {}
-
- operationCardlist[ZPDef.OpCode.OP_HU] = {}
- table.insert(operationCardlist[ZPDef.OpCode.OP_HU],Card)
-
- if code > 0 then
- self:showOpeation(code,operationCardlist,false,true)
- end
-
- if self:getIsMeUId(nUserId) then
- --检测是否少牌
- self:checkCardAndRecover()
- end
-
- --结束
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-doushisiRoomView - addCallBack(runQiangBa)")
-
- self:addCallBack(runQiangBa)
- end
-
- ---
- -- 托管通知
- -- @param data
- -- @return
- --
- function doushisiRoomView:onHostingRequest( data )
- local response = data.response
- if response.nUserId == app.user.loginInfo.uid then
- if response.status == 1 then --托管状态
- self.toolView:showTuoGuan(true)
- elseif response.status == 0 then--取消托管状态
- self.toolView:showTuoGuan(false)
- end
- end
- local isTuoGuan = response.status == 1;
- local viewId = app.room:getViewIdByUserId(response.nUserId)
- self.PlayerView:showTuoGuanByViewId(viewId,isTuoGuan)
- end
-
-
- --游戏消息
- function doushisiRoomView:bindGameMessage()
- doushisiRoomView.super.bindGameMessage(self)
- --起手操作提示
- self:bindEvent(app.room , "onUserOperateResponse", handler(self , self.onUserOperateResponse));
- --起手操作成功
- self:bindEvent(app.room , "onBroadCastQiShouOperate", handler(self , self.onUserOperateSuccess));
- --广播玩家进牌
- self:bindEvent(app.room , "onBroadCastUserGetCard", handler(self , self.onBroadCastUserGetCard));
- --广播头家出牌
- self:bindEvent(app.room , "onBroadCastBankerOutCard", handler(self , self.onBroadCastBankerOutCard));
- --通知打出的牌可能包赔
- self:bindEvent(app.room , "onOutCardIsBaoPeiResponse", handler(self , self.onOutCardIsBaoPeiResponse));
- --通知进牌后操作提示
- self:bindEvent(app.room , "onUserGetCardOperteResponse", handler(self , self.onUserGetCardOperteResponse));
- --刷新手牌
- --self:bindEvent(app.room , "onReflashHandcardsResponese" , handler(self , self.onReflashHandcardsResponese));
- --抢巴操作通知
- self:bindEvent(app.room , "onQiangBaResponese" , handler(self , self.onQiangBaResponese));
- --切换视图
- --self:bindEvent(app , ZPDef.ZPEvent.ChangeViewType, handler(self, self.changeViewType))
- --过巴操作
- --self:bindEvent(app.room, "onGuoBaResponse", handler(self, self.onGuoBaResponse))
- -- 托管
- self:bindEvent(app.room , ZPDef.ZPEvent.HostingRequest, handler(self, self.onHostingRequest))
- end
-
- function doushisiRoomView:resetGameData()
- logE("===========重置游戏数据===============")
- self.handCardRoot = {}
- self.handCardValueLocal = {}
- self.handCardValueBak = {}
- self:setOutCardLineVisible(false)
- self:setWetChatVisible(false)
- self:setBtnSitDownVisible(false)
- self:setOutCardVisible(false)
- self:setOperatorPanelView(false)
- self:setGuideView(false)
- self:setHandTempCardVisible(false)
- self:setCircleCardLeftPanelView(false)
- self:setLiangPaiVisible(false)
- self:setTingCardViewVisible(false)
- self:setDingPiaoVisible(false)
- self:setLayoutScoreTipVisible(false)
- if self.PlayerView then
- self.PlayerView:setReadyStateVisible(false)
- self.PlayerView:setBankerVisible()
- self.PlayerView:setOperatorTipVisible(false)
- self.PlayerView:setAllClockVisible(false)
- self.PlayerView:hideLeftCard()
- end
-
- --隐藏工具界面 详情
- if self.toolView.ui.Items.ImageView_Rule_bg then
- self.toolView.ui.Items.ImageView_Rule_bg:setVisible(false)
- end
- --隐藏操作吃界面
- self.operationView:setAllEatView(false)
-
-
- self.ui.Items.TextBMFont_leftCardNum:setPosition(self.leftCardNumPos)
- self.ui.Items.ImageView_zhang:setPositionY(self.leftCardNumPos.y)
-
- --操作码
- self.operationLocalCode = 0
- self.isMoPaiOperator = false
- self.isGameOver = false
- self.isTianHu = false
- self.isGodHand = false
- --听牌重置
- self.isNoCardTingPai = false
- self.tingCardLocal = {}
- self.tableHuXiList = {}
- --弃牌
- self.qiPaiList = {}
- --发牌器
- self.ui.Items.ImageView_card_bg:removeAllChildren()
- self.fapaiqiLeftCard = nil
- self.ui.Items.TextBMFont_leftCardNum:setText("0")
- --庄家爆牌标志
- self.bankerBaoPao = nil
- --移除所有的牌局
-
- for i = 1,ZPDef.GameMaxPlayer do
- local layoutNode = string.format("ImageView_outCardImg_%d",i)
- self.ui.Items[layoutNode]:removeAllChildren()
- end
-
- for i = 1,ZPDef.GameMaxPlayer do
- local layoutNode = string.format("LayoutMain_%d",i)
- self.ui.Items[layoutNode]:removeAllChildren()
- end
- self.ui.Items.Layout_Player_HuEffect:removeAllChildren()
- self:clearXJChaPaiView()
-
- for i = 1, ZPDef.GameMaxPlayer do
- --[[ local giveupName = string.format("Layout_giveUp_%d",i)
- local weaveCardName = string.format("Layout_player1Table_%d",i)--]]
- --重置开招次数
- self.playerZhao[i] = 0
- --弃牌数组
- self.qiPaiList[i] = {}
- --[[ self.ui.Items[weaveCardName]:removeAllChildren()
- self.ui.Items[giveupName]:removeAllChildren()--]]
- end
- self.PlayerView:setHuXizero()
-
- if self.xiaojuView then
- self.xiaojuView:removeFromParent()
- self.xiaojuView = nil
- end
-
- if self.xiaojuChaPaiView then
- self.xiaojuChaPaiView:setVisible(false)
- end
-
- for i = 1, ZPDef.GameMaxPlayer do
- if self._selfCards[i] then
- self._selfCards[i] = {}
- end
- end
-
- for i = 1, #self.handCardRoot do
- self.handCardRoot[i]:removeFromParent()
- end
-
-
- for i = 1, ZPDef.GameMaxPlayer do
- self.qiPaiView[i]:reset()
- end
-
- for i = 1, ZPDef.GameMaxPlayer do
- self.opOutCard[i]:reset()
- end
-
- --停止一些动画
- self.ui:stopAllActions()
-
- self.isQiShou = true
- self.moValue = 0
- self.isBiChi = 0
- self.handCardItem = {}
-
- self.PlayerView:hideBaoJiao()
- self.baoJiaoStatus = 0
- self.isTishi = false
- self.moLieshu = 0
- self.myHandCardNums = 0
- self.touchPoker = nil
- end
-
-
-
- --胡牌特效
- function doushisiRoomView:playHuEffect(viewId,onEnd,isRecontect)
- logE("doushisiRoomView playHuEffect",app.room.roomInfo.huType,viewId)
- local nUserID = app.room:getUserIdByViewId(viewId)
- if (app.room.roomInfo.huType and app.room.roomInfo.huType >= 0) and (app.room.roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_NORMAL) then
- local userInfo=app.room:getUserInfo(nUserID)
- if userInfo then
- ZPSound.PlayOperateSound(userInfo.sex,4)
- --if ZPFuc.isZiMo(app.room.roomInfo.huType) then
- --ZPSound.PlayOperateSound(userInfo.sex,11)
- --else
- --ZPSound.PlayOperateSound(userInfo.sex,4)
- --end
- end
- end
-
- local name = string.format("Layout_outCardPoint_%d",viewId)
- local mLayout = self.ui.Items[name]
-
- local huEffectUI = loadUI("zp_base/res/ui/ui_fangjian/zipai_ui_effectHu.ui")
- local pos = mLayout:getPosition()
-
- if viewId == self:getMeViewId() then
- local centerPos = cc.Director:getInstance():getVisibleSize()
- local pos = cc.p(centerPos.width/2,centerPos.height/2 - 70)
- huEffectUI:setPosition(pos)
- elseif viewId == 1 then
- huEffectUI:setPosition(cc.pAdd(pos,cc.p(90,-30)))
- elseif viewId == 2 then
- huEffectUI:setPosition(cc.pAdd(pos,cc.p(0,20)))
- elseif viewId == 3 then
- huEffectUI:setPosition(cc.pAdd(pos,cc.p(-70,-30)))
- end
-
- self.ui.Items.Layout_Player_HuEffect:addChild(huEffectUI,2)
-
- local pPos = cc.p(0,0)
- for k,v in pairs(self.playerPos) do
- if k == viewId then
- --pPos = v.headPos
- if viewId == 2 then
- pPos.y = v.headPos.y + 25
- pPos.x = v.headPos.x
- elseif viewId == 1 then
- pPos.y = v.headPos.y + 15
- pPos.x = v.headPos.x
- elseif viewId == 3 then
- pPos.y = v.headPos.y + 15
- pPos.x = v.headPos.x
- elseif viewId == 4 then
- pPos.y = v.headPos.y + 15
- pPos.x = v.headPos.x
- end
- end
- end
-
- local mSpawn = cc.Spawn:create(cc.MoveTo:create(0.5,pPos),cc.ScaleTo:create(0.3,0.5))
-
- huEffectUI:runAction(cc.Sequence:create(cc.DelayTime:create(0.5),mSpawn))
-
- --动画展现
- if app.room.roomInfo.huType and app.room.roomInfo.huType >= 0 then
- local name = ""
- local bankerViewId = app.room:getViewIdBySeatId(app.room.roomInfo.nBankSeatId)
- local nWinerId = app.room.roomInfo.winUserId
- local winerViewId = app.room:getViewIdByUserId(nWinerId)
- if app.room.roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_HUANG_ZHUANG then--app.room.roomInfo.huType == 0 and
- name = "zp_room_chapai_jiao.png"--显示叫(表示听牌了)
- --elseif ZPFuc.isZiMo(app.room.roomInfo.huType) then
- --name = "zp_room_chapai_zimo.png"
- else
- name = "zp_room_chapai_hu.png"--string.format(ZPDef.TipFile.HU,app.room.roomInfo.huType)
- end
- huEffectUI.Items.ImageView_huType:loadTextureFromPlist(name)
- end
- isRecontect = true--不显示动画
- if isRecontect then
- huEffectUI.Items.ImageView_Light:setVisible(false)
- huEffectUI.Items.ImageView_Point:setVisible(false)
- huEffectUI.Items.ImageView_Coin:setVisible(false)
- self:showPaoImage()
- self:runAction(cc.Sequence:create(cc.DelayTime:create(0.8),cc.CallFunc:create(function ()
- if onEnd then
- onEnd()
- end
- end)))
- return
- end
- local mSpawn1 = cc.Spawn:create(cc.ScaleTo:create(0.3,1.0),cc.RotateBy:create(2,-120*6))
- huEffectUI.Items.ImageView_Point:runAction(mSpawn1)
-
- local mSpawn2 = cc.Spawn:create(cc.ScaleTo:create(0.3,1.0),cc.RotateBy:create(2,120*6))
- huEffectUI.Items.ImageView_Light:runAction(mSpawn2)
-
- huEffectUI.Items.ImageView_Coin:setScale(0)
- local mSeq1 = cc.Sequence:create(cc.ScaleTo:create(0.3,1))
- huEffectUI.Items.ImageView_Coin:runAction(mSeq1)
-
- huEffectUI.Items.ImageView_huType:setScale(2)
- huEffectUI.Items.ImageView_huType:setOpacity(0)
- local mSeq2 = cc.Sequence:create(cc.DelayTime:create(0.6),cc.FadeIn:create(0),cc.ScaleTo:create(0.2,1.0))
- huEffectUI.Items.ImageView_huType:runAction(mSeq2)
-
- huEffectUI:runAction(cc.Sequence:create(cc.DelayTime:create(2.2),cc.CallFunc:create(function()
- huEffectUI.Items.ImageView_Light:setVisible(false)
- huEffectUI.Items.ImageView_Point:setVisible(false)
- huEffectUI.Items.ImageView_Coin:setVisible(false)
- self:showPaoImage()
- if onEnd then
- onEnd()
- end
- end)))
- end
-
-
- --点炮显示
- function doushisiRoomView:showPaoImage()
- if app.room.roomInfo.dianPaoUserId and app.room.roomInfo.dianPaoUserId >= 0 then
- local dianPaoViewId = app.room:getViewIdByUserId(app.room.roomInfo.dianPaoUserId)
- local name = string.format("ImageView_outCardImg_%d",dianPaoViewId)
- local img = self.ui.Items[name]
- local size = img:getContentSize()
- --点炮精灵
- local mSprite = cc.ImageView:createNode()
- mSprite:loadTextureFromPlist("zp_room_chapai_dianpao.png")
- img:addChild(mSprite)
- mSprite:setPosition(cc.p(size.width/2,size.height/2))
- end
- end
-
-
- function doushisiRoomView:onClickOpBtn(data)
- --[[ self.isGodHand = true
- --防止一直卡住的情况
- local seq = cc.Sequence:create(cc.DelayTime:create(2.0),cc.CallFunc:create(function ()
- self.isGodHand = false
- end))
- self:runAction(seq)--]]
- end
-
- function doushisiRoomView:setTingCardViewVisible(bVisible,tingCards)
- end
-
-
- function doushisiRoomView:showTingPaiView(touchcCard)
- end
-
- function doushisiRoomView:hideOperation()
- self.operationView:hideSelf()
- end
-
- function doushisiRoomView:setColorWhite()
-
- end
-
- return doushisiRoomView
|