local ZPDef = ZPFramework.ZPImport("zp_base.luaScript.ZPDef") local ZPFuc = ZPFramework.ZPImport("zp_base.luaScript.ZPFunctions") local ZPSound = ZPFramework.ZPImport("zp_base.luaScript.ZPSound") local ZPMessage = ZPFramework.ZPImport("zp_base.luaScript.Protocol.ZPMessage") 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 ZPRoomXiaoJuView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomXiaoJuView") local ZPRoomOperationView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomOperationView") local ZPRoomCard=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomCard") local ZPRoomCountAllView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomCountAllView") local ZPRoomPiaoFenView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomPiaoFenView") local ZPRoomSettingView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomSettingView") local ZPRoomQuickStartView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomQuickStartView") local ZPWanFa=ZPFramework.ImportWanFa("luaScript.SubGameDefine.ZiPai.ZPWanFa") local ZPRoomView = ZPFramework.ZPFrameworkClassImprot("zp_base.luaScript.Views.Room.ZPRoomView") local hejiangRoomView = class("hejiangRoomView", ZPRoomView) function hejiangRoomView:ctor() hejiangRoomView.super.ctor(self) end function hejiangRoomView:onEnter() hejiangRoomView.super.onEnter(self) end function hejiangRoomView:setTableImg(idx) local name = string.format("zp_hejiang/res/ui/zy_fangjian/bg/hj_fangjian_di_%d.jpg",idx) --桌布 self.ui.Items.ImageView_bg:loadTexture(name) --[[ if idx == 1 or idx == 4 then self.ui.Items.Text_JuShu:setColor(cc.c3b(109,69,32)) elseif idx == 2 or idx == 3 then self.ui.Items.Text_JuShu:setColor(cc.c3b(9,74,49)) end--]] self:initLogo(idx); local cacheGameBgPic = "gameBgPicture"..(ZPDef.GameID or app.gameId) saveUserInfo(cacheGameBgPic,idx) end --- -- 初始化房间水印 -- @return -- --[[function hejiangRoomView:initLogo(idx) local config = getSubGameConfig(ZPDef.GameID or app.gameId) or {} local logoName = config.logo or string.format("zp_hejiang/res/ui/zy_fangjian/bg/hj_fangjian_watermark_%d.png", idx) self.ui.Items.ImageView_Logo:loadTexture(logoName) if config.isShowLogo == false then self.ui.Items.ImageView_Logo:setVisible(false) end end--]] --更新房间基础数据 function hejiangRoomView:updateRoomBaseData() --初始化背景 local ZiPaigameBgPicture = "gameBgPicture"..(ZPDef.GameID or app.gameId) local idx2 = tonumber(loadUserInfo(ZiPaigameBgPicture)) or 1 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 hejiangRoomView:showDelayTimeTip(operations) if operations then for k,v in pairs(operations) do local viewId = app.room:getViewIdByUserId(v.nUserId) local isVisible = v.isCanOpereate == 1 self.PlayerView:showArrowByViewId(viewId,isVisible,tonumber(v.time)) end end end function hejiangRoomView: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) local roomInfo = app.room.roomInfo; --显示庄家 self:updateBanker() self:showOwner() 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; --有人发起解散时才显示解散界面 if v.nDisbandStatus == 1 then isDismiss = true uid = k end end self.PlayerView:setXiaoJiaFlagVis(true) --有人发起解散时才显示解散界面 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 for k,v in pairs(roomInfo.tuoGuanInfo or {}) do local aiStatus = v.aiStatus; local nUserID = v.nUserID; local viewId = app.room:getViewIdByUserId(nUserID) local isTuoGuan = aiStatus == 1; if viewId == self:getMeViewId() then if isTuoGuan then self:showTuoGuan(true) self.isTuoGuan = true else self:showTuoGuan(false) self.isTuoGuan = false end end self.PlayerView:showTuoGuanByViewId(viewId,isTuoGuan) 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 --游戏为停止或开始状态 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 = ZPRoomXiaoJuView:new(nextCallBackFun,true) self:addChild(self.xiaojuView) --播放黄庄动画 if roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_HUANG_ZHUANG then self.xiaojuChaPaiView:PlayHuangZhuangAni(false) end self.xiaojuView:setVisible(false) 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) then self.PlayerView:playBaoAnim(viewId) end local hushu = 0 --恢复组合牌 for key,value in pairsByKeys(v.tableWeaveCard) do local list,operationType = ZPFuc.getZPCardList(value.card,value.type) local isShow = true local card = value.opcard hushu = hushu + value.hushu --记录真实数据 --过滤:碰胡和偎胡,坎提胡,坎跑胡 的组合牌不显示,这些组合牌在self:liangShouPai()里后面插回手里 if ZPDef.ReconnectState.GAME_STATUS_ROUND_OVER == roomInfo.nStatus or ZPDef.ReconnectState.GAME_STATUS_GAME_OVER == roomInfo.nStatus then if roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_NORMAL then local nUserId = roomInfo.winUserId local viewId = app.room:getViewIdByUserId(nUserId) local huCard = roomInfo.huCard --不等于赢家的ID,组合牌就全部显示,赢家的需要判断 if nUserId == k then if huType == ZPDef.ReconnectHuType.WEI_HU and operationType == ZPDef.OpType.OP_TYPE_MINGWEI and huCard == card then isShow = false elseif huType == ZPDef.ReconnectHuType.WEI_HU and operationType == ZPDef.OpType.OP_TYPE_ANWEI and huCard == card then isShow = false elseif huType == ZPDef.ReconnectHuType.PENG_HU and operationType == ZPDef.OpType.OP_TYPE_PENG and huCard == card then isShow = false elseif huType == ZPDef.ReconnectHuType.KAN_TI_HU and operationType == ZPDef.OpType.OP_TYPE_TI and huCard == card then isShow = false elseif huType == ZPDef.ReconnectHuType.KAN_PAO_HU and operationType == ZPDef.OpType.OP_TYPE_PAO and huCard == card then isShow = false end end end end --对于要显示的牌,除了一些普通的牌需要展示外,特殊的有:偎提胡,偎跑胡,碰跑胡,这个时候,组合牌还是显示偎,偎,跑的原先模样 if isShow then if ZPDef.ReconnectState.GAME_STATUS_ROUND_OVER == roomInfo.nStatus or ZPDef.ReconnectState.GAME_STATUS_GAME_OVER == roomInfo.nStatus then if roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_NORMAL or roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_HU_DIRTY then local nUserId = roomInfo.winUserId local viewId = app.room:getViewIdByUserId(nUserId) --如果赢的是当前的人组合牌需要稍微处理下 if nUserId == k then local huCard = roomInfo.huCard if operationType == ZPDef.OpType.OP_TYPE_TI and huCard == card and huType == ZPDef.ReconnectHuType.WEI_TI_HU then --偎提胡(结算亮一张偎牌,这里处理为明偎) operationType = ZPDef.OpType.OP_TYPE_MINGWEI elseif operationType == ZPDef.OpType.OP_TYPE_PAO and huCard == card and huType == ZPDef.ReconnectHuType.PENG_PAO_HU then --碰跑胡 operationType = ZPDef.OpType.OP_TYPE_PENG elseif operationType == ZPDef.OpType.OP_TYPE_PAO and huCard == card and huType == ZPDef.ReconnectHuType.WEI_PAO_HU then --偎跑胡(结算亮一张偎牌,这里处理为明偎) operationType = ZPDef.OpType.OP_TYPE_MINGWEI end end end end list = ZPFuc.getOpCardFirstList(operationType,list,card) --上面吃或不吃不要用if else因为还可能都不成立 local isMoPaiOrId = value.seatId self:recontactDoOperation(operationType,viewId,list,card,isMoPaiOrId) end end self.tableHuXiList[viewId] = hushu self.PlayerView:setPlayerHuXi(viewId,hushu) --self.PlayerView:setPlayerHuXi("油:"..tostring(hushu)) end self:getLocalHuShu() for i = 1, 4 do local tt = self.qiPaiList[i] end local function showReconectDelayTip() for k,v in pairs(app.room.roomInfo.delayPlayer) do local operations = {} local viewId = app.room:getViewIdByUserId(v.uid) operations[viewId] = {} operations[viewId].nUserId = v.uid operations[viewId].time = v.DelayOptTime operations[viewId].isCanOpereate = v.DelayOptTime > 0 and 1 or 0 self:showDelayTimeTip(operations) end end --恢复弃牌 for k,v in pairs(roomInfo.arrayTableInfo) do local viewId = app.room:getViewIdByUserId(v.nUserId) local qiList = self.qiPaiList[viewId] for key,value in pairs(v.desertedArea) do local card = value.card local maxQi = table.nums(qiList) if maxQi > 0 then --染色弃牌 local isInQiList = false for qiK,qiCard in pairs(qiList) do if qiCard == value.card then --染色弃牌 self:playQiPaiAni(false,value.card,viewId,nil,true) isInQiList = true qiList[qiK] = nil break end end if not isInQiList then self:playQiPaiAni(false,value.card,viewId,nil,false) end else --普通弃牌 self:playQiPaiAni(false,value.card,viewId,nil,false) end 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.LeftCard and v.nUserId then local viewId = app.room:getViewIdByUserId(v.nUserId) self.PlayerView:setLeftCardNum(viewId,true,tonumber(extIf.LeftCard)) end end end end --状态显示 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 self:playHuEffect(winerViewId,nil,true) --self:setLayoutScoreTipVisible(true,playerList,false,nil,true) end end 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_AFTER_OUTCARD == 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) --记录真实数据 self.outCard = nCard self.EatOperationCode = operateCode self.moPaiViewId = viewId --显示剩余牌 self:setCircleCardLeftPanelView(true,viewId,diPaiMax) if ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_TIAN_HU == roomInfo.nStatus then --标记天胡 self.isTianHu = true if viewId == self:getMeViewId() then self:showOpeation(ZPDef.OpCode.OP_HU,viewId) end elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_AFTER_OUTCARD == roomInfo.nStatus then --是否已经操作过 0表示没有,非0表示已经提交了操作 if operateCode ~= ZPDef.OpCode.OP_CANCEL and roomInfo.isSubmitOp == 0 then self:showOpeation(operateCode) self:setOutCardVisible(true,viewId,nCard,false,nil,true) elseif roomInfo.isSubmitOp == 1 or roomInfo.isSubmitOp == 0 then self:setOutCardVisible(true,viewId,nCard,false,nil,true) --playVoiceCardValue(nCard,nUserId) elseif roomInfo.isSubmitOp == 2 then --比牌不显示出牌或者摸牌 self.operationView:touchEatOneCardCallBack(true) end elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_AFTER_TURN_OVER == roomInfo.nStatus then if roomInfo.isSubmitOp == 1 then operateCode = 0 self:playMoPaiAni(diPaiMax,nCard,viewId,operateCode,roomInfo.showCardFlag,nil,true) elseif roomInfo.isSubmitOp == 0 then self:playMoPaiAni(diPaiMax,nCard,viewId,operateCode,roomInfo.showCardFlag,nil,true) elseif roomInfo.isSubmitOp == 2 then --比牌不显示出牌或者摸牌 self.operationView:touchEatOneCardCallBack(true) end end showReconectDelayTip() elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OUT_CARDS == roomInfo.nStatus then --等待玩家出牌中 --显示底牌 local viewId = app.room:getViewIdBySeatId(roomInfo.showCardSeatId) --显示剩余牌 self:setCircleCardLeftPanelView(true,viewId,diPaiMax) if viewId == self:getMeViewId() then self:setGuideView(true) self.bOutCard = true end showReconectDelayTip() elseif ZPDef.ReconnectState.GAME_STATUS_AUTO_DISCSRD == roomInfo.nStatus then --玩家自动弃牌中 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 --等待玩家爆牌中 --爆牌中 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) --等待爆牌状态 if v.nBaoPaiStatus == 1 and k == app.user.loginInfo.uid then self.operationView:showBaoPaiOpView(true) end end showReconectDelayTip() end if onEnd then onEnd() end end log("2000000000-ZPRoomView - self:addCallBack(runOnGameReconnection)" ) self:addCallBack(runOnGameReconnection) else --未开局正常坐下这里会进来 for k,v in pairs(roomInfo.memberList) 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) do local viewId = app.room:getViewIdByUserId(k) local nOffLineState = v.nOnlineStatus --显示离线 self.PlayerView:setPlayerOffLine(nOffLineState ~= 1,viewId) end end end function hejiangRoomView:resetGameData() logE("===========重置游戏数据===============") self.handCardRoot = {} 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() self.PlayerView:setArrowStateVisible() 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.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 --移除所有的牌局 self.ui.Items.LayoutMain_4:removeAllChildren() 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) --移除胡牌的时候点炮 local outCardImgName = string.format("ImageView_outCardLight_%d",i) --重置开招次数 self.playerZhao[i] = 0 --弃牌数组 self.qiPaiList[i] = {} self.ui.Items[weaveCardName]:removeAllChildren() self.ui.Items[giveupName]:removeAllChildren() self.ui.Items[outCardImgName]: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 --停止一些动画 self.ui:stopAllActions() end return hejiangRoomView