|
- local ZPDef = ZPFramework.ZPImport("zp_base.luaScript.ZPDef")
- local ZPMessage = ZPFramework.ZPImport("zp_base.luaScript.Protocol.ZPMessage")
- local ZPRoomView = ZPFramework.ZPFrameworkClassImprot("zp_base.luaScript.Views.Room.ZPRoomView")
- local ZPFuc = ZPFramework.ZPImport("zp_base.luaScript.ZPFunctions")
- local ChangPaiRoomCard=ZPFramework.ZPImport("zp_changpai.luaScript.Views.Room.changpaiRoomCard")
- local changpaiRoomSettingView=ZPFramework.ZPImport("zp_changpai.luaScript.Views.Room.changpaiRoomSettingView")
- 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 changpaiRoomXiaoJuView=ZPFramework.ZPImport("zp_changpai.luaScript.Views.Room.changpaiRoomXiaoJuView")
- local ChangpaiRoomOperationView=ZPFramework.ZPImport("zp_changpai.luaScript.Views.Room.changpaiRoomOperationView")
- local ChangpaiCard = ZPFramework.ZPImport("zp_changpai.luaScript.Views.Room.changpaiCard")
- local ZPRoomQuickStartView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomQuickStartView")
- local ZPWanFa=ZPFramework.ImportWanFa("luaScript.SubGameDefine.ZiPai.ZPWanFa")
- local ZPSound = ZPFramework.ZPImport("zp_base.luaScript.ZPSound")
- local ZPRoomCountAllView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomCountAllView")
-
- --每张牌的点数 用于排序
- local tempCardVlue ={
- [17] = 2, --11
- [18] = 3, --12
- [49] = 4, --31
- [34] = 4, --22
- [20] = 5, --14
- [50] = 5, --32
- [21] = 6, --15
- [36] = 6, --24
- [51] = 6, --33
- [22] = 7, --16
- [82] = 7, --52
- [52] = 7, --34
- [38] = 8, --26
- [53] = 8, --35
- [68] = 8, --44
- [54] = 9, --36
- [84] = 9, --54
- [70] = 10, --46
- [85] = 10, --55
- [86] = 11, --56
- [102] = 12, --66
- }
-
-
- local changpaiRoomView = class("changpaiRoomView", ZPRoomView)
-
- function changpaiRoomView:ctor()
- changpaiRoomView.super.ctor(self)
-
- --是否是起手操作的标志
- self.isQiShou = true
- --扇形最大列数
- self.lieShuMax = 8
- --最大行数
- self.hangShuMax = 5
- --操作牌数组
- self.opOutCard = {}
- --摸牌
- self.moValue = 0
- --要吃的那张牌
- self.chiCard = 0
- --是否包赔
- self.isBaopei = 0
- --是否是必吃的牌
- self.isBiChi = 0 --是否必吃
- --点击过后是否需要提示包赔
- self.isTishi = false
- --弃牌的缩放大小
- self.littleCardScale = 0.9
- --报叫的状态
- self.baoJiaoStatus = 0
-
- self.isTouchOpOutCard = false
-
-
-
- self.lieshulist[1] = {5}
- self.lieshulist[2] = {4,5}
- self.lieshulist[3] = {4,5,6}
- self.lieshulist[4] = {3,4,5,6}
- self.lieshulist[5] = {3,4,5,6,7}
- self.lieshulist[6] = {2,3,4,5,6,7}
- self.lieshulist[7] = {2,3,4,5,6,7,8}
- self.lieshulist[8] = {1,2,3,4,5,6,7,8}
- self.lieshulist[9] = {1,2,3,4,5,6,7,8,9}
-
- self.lieshuBlanklist[1] = {1,2,3,4,6,7,8,9}
- self.lieshuBlanklist[2] = {1,2,3,6,7,8,9}
- self.lieshuBlanklist[3] = {1,2,3,7,8,9}
- self.lieshuBlanklist[4] = {1,2,7,8,9}
- self.lieshuBlanklist[5] = {1,2,8,9}
- self.lieshuBlanklist[6] = {1,8,9}
- self.lieshuBlanklist[7] = {1,9}
- self.lieshuBlanklist[8] = {9}
- self.lieshuBlanklist[9] = {}
-
-
- --初始化牌颜色
- local cacheColor = "cardColor"..(ZPDef.GameID or app.gameId)
- self.colorType = tonumber(loadUserInfo(cacheColor)) or ZPDef.ColorType.White
-
-
- local cacheGameViewType = "gameViewType"..(ZPDef.GameID or app.gameId)
-
- self.desktopType = loadUserInfo(cacheGameViewType) or ZPDef.DesktopType.ThreeD
-
- if not self.desktopType or self.desktopType == "" then
- self.desktopType=ZPDef.DesktopType.ThreeD
- end
-
- self.outCardScale = 0.88
-
-
- self.moLieshu = 0
-
- self.myHandCardNums = 0
-
- end
-
- function changpaiRoomView:loadRoomUI()
- local ui = loadUI("zp_changpai/res/ui/ui_fangjian/changpai_ui_fangjian.ui");
- self.ui = ui;
- self:addChild(ui);
- end
-
- function changpaiRoomView:onEnter()
- changpaiRoomView.super.onEnter(self)
- self.ui.Items.ImageView_mytuoshu:setVisible(false)
-
- self.ui.Items.Layout_Touch:registerClick(handler(self,self.touchOutCard))
-
- end
-
-
- function changpaiRoomView:touchOutCard()
- local cardNum = table.nums(self.handCardItem)
-
- if self.isRecordStart then
- return
- end
- if cardNum <= 0 then
- return
- else
- self:setColorWhite()
- end
-
- end
-
-
- function changpaiRoomView:initBaseNode()
- --自己的出生坐标,视图是4
- self:initMySelfCardPos()
- self.scorePosList = {}
- --坐标记录
- self.srcOutCardPosList = {}
- 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
-
- self.ui.Items.ImageView_tou_tip:setVisible(false)
- end
-
- --[[function changpaiRoomView:changeOutCardScale()
-
-
- --坐标记录
- self.srcOutCardPosList = {}
- 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
- end--]]
-
- function changpaiRoomView:initMySelfCardPos()
- self.boxPosList4 = {}
- local weaveCardPos4 = self.ui.Items.Layout_StartPos:getPosition()
- --最后一列要固定所以加了一列 8+1 形式
- local tempLieshu = self.lieShuMax + 1
- for i = 1, tempLieshu do
- --矩形3
- self.boxPosList4[i] = cc.p(weaveCardPos4.x + 98 * (i - 1) - 100, weaveCardPos4.y)--手牌间隙改这里
- end
- end
-
-
- -- 设置房间信息
- function changpaiRoomView: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)
- if v.name == "封顶" then
- if tostring(v.value[1]) == "不封顶" then
- text:setString(tostring(v.value[1]))
- else
- text:setString(tostring(v.value[1]..v.name))
- end
- elseif v.name == "超番加底" then
- text:setString(tostring(v.value[1]))
- else
- text:setString(tostring(v.value[1]))
- end
- self.ui.Items.ListView:addChild(text)
- end
- self.ui.Items.ListView:jumpToTopOnSizeChanged();
- end
-
- function changpaiRoomView:loadTextureCache()
- changpaiRoomView.super.loadTextureCache(self)
-
- ZPFuc.loadSpriteFromFile("zp_changpai/res/ui/zy_fangjian/cards/changpai_group_out_type1.plist")
- ZPFuc.loadSpriteFromFile("zp_changpai/res/ui/zy_fangjian/cards/changpai_group_out_type2.plist")
- ZPFuc.loadSpriteFromFile("zp_changpai/res/ui/zy_fangjian/cards/changpai_handCard_type1.plist")
- ZPFuc.loadSpriteFromFile("zp_changpai/res/ui/zy_fangjian/cards/changpai_handCard_type2.plist")
- ZPFuc.loadSpriteFromFile("zp_changpai/res/ui/zy_fangjian/cards/changpai_quitCard_type1.plist")
- ZPFuc.loadSpriteFromFile("zp_changpai/res/ui/zy_fangjian/cards/changpai_quitCard_type2.plist")
- ZPFuc.loadSpriteFromFile("zp_changpai/res/ui/zy_fangjian/cards/changpai_smallCard_type1.plist")
- ZPFuc.loadSpriteFromFile("zp_changpai/res/ui/zy_fangjian/cards/changpai_smallCard_type2.plist")
-
- end
-
-
- function changpaiRoomView:initGameButton()
- --出牌按钮
- self.ui.Items.Button_OutCard:registerClick(function()
- local k = self.ui.Items.ImageView_handTempCard.cIdx
- local value = self.ui.Items.ImageView_handTempCard.value
- --send sender
- self.isGodHand = true;
- self.handCardItem[k]:setOpacity(0)
- self:setColorWhite()
- self:sendOutCard(value)
- self.bOutCard = false
- end)
- self.canClick = true
- --提牌按钮
- self.ui.Items.Button_tipai:registerClick(function()
- if not self.canClick then
- return
- end
-
- self.canClick = false
-
- runDelay(3,function()
- self.canClick = true
- end)
- self:requestFlashHandCard()
- end)
- --暂时屏蔽提牌功能
- self:showTiPaiBtn(true)
-
- --点击空白
- self.ui.Items.Layout_Touch:registerClick(nil,function()
- --隐藏工具界面 详情
- 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 changpaiRoomView:setTableImg(idx)
- --如果界面是3D 但是桌布为2d时 则需要同步回来
- if self.desktopType == ZPDef.DesktopType.ThreeD then
- if idx >= 4 then
- idx = idx - 3
- end
- else
- if idx <= 3 then
- idx = idx + 3
- end
- end
-
- local name = string.format("zp_changpai/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 changpaiRoomView:changeOutCardLight(isMoPai)
- local colorType = ZPDef.ColorType.YELLOW
- for i = 1 ,ZPDef.GameMaxPlayer do
- local outCardLightName = string.format("ImageView_outCardLight_%d",i)
- local light = self.ui.Items[outCardLightName]
- local fileName
- if isMoPai then
- fileName = string.format(ZPDef.LightType.BLUE, colorType)
- else
- fileName = string.format(ZPDef.LightType.YELLOW, colorType)
- end
- light:loadTexture(fileName)
- end
- end
-
-
- function changpaiRoomView:setFaPaiQiPanelView(bVisible,viewId,leftNum)
- if viewId and leftNum then
- self.ui.Items.TextBMFont_leftCardNum:setText(tostring(self.leftNum))
- end
- end
-
-
- --更新房间基础数据
- function changpaiRoomView:updateRoomBaseData()
- --初始化背景
- local ZiPaigameBgPicture = "gameBgPicture"..(ZPDef.GameID or app.gameId)
- local idx2 = tonumber(loadUserInfo(ZiPaigameBgPicture)) or 2
- self:setTableImg(idx2)
-
- --初始化牌颜色
- local cacheColor = "cardColor"..(ZPDef.GameID or app.gameId)
- self.colorType = tonumber(loadUserInfo(cacheColor)) or ZPDef.ColorType.White
-
- 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(app.room:getActualPlayerNum() < 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
-
- --显示弃牌界面
- for i = 1,ZPDef.GameMaxPlayer do
- local name = string.format("Layout_tuopai_%d",i)
- self.ui.Items[name]:setVisible(false)
-
- local imgGiveUp = self.ui.Items["ImageView_giveUp_" .. i]
- local layoutGiveUp = self.ui.Items["Layout_giveUp_" .. i]
- local onTouchBegan = function ()
- layoutGiveUp:setScale(1.7)
- end
-
- local onTouchMove = function ()
-
- end
-
- local onTouchEnd = function ()
- layoutGiveUp:setScale(1.0)
- end
-
- local onTouchCancel = function ()
- layoutGiveUp:setScale(1.0)
- end
- imgGiveUp:setTouchEnabled(true)
- imgGiveUp:registerTouchEvent(onTouchBegan,onTouchMove,onTouchEnd,onTouchCancel)
- end
-
- end
-
- function changpaiRoomView:initToolLayer()
- --人物头像层
- self.PlayerView = ZPRoomPlayerView:new()
- self.ui.Items.Layout_Player:addChild(self.PlayerView)
-
- --操作界面(吃碰杠胡)
- self.operationView = ChangpaiRoomOperationView:new()
- --self.operationView:setVisible(false)
- self.ui.Items.Layout_Tool:addChild(self.operationView)
-
- 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.toolView = ZPRoomToolView:new()
- self.ui.Items.Layout_Tool:addChild(self.toolView)
-
- -- 小局查牌界面
- 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 changpaiRoomView: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 changpaiRoomView:showOwner()
- self.PlayerView:setOwnerVisible()
-
- --只显示当前的庄家座位号 不显示房主
- local nBankerSeatId = app.room.roomInfo.nRoomOwnedUid
- local viewId = app.room:getViewIdBySeatId(nBankerSeatId)
- --self.PlayerView:setPlayerBankerVisible(viewId,true)
- end
-
-
- --显示小家
- function changpaiRoomView:showXiaojia()
- self.PlayerView:hideXiaoJia()
- --只显示当前的庄家座位号
- local nBankerSeatId = app.room.roomInfo.xiaoSeatId
- local viewId = app.room:getViewIdBySeatId(nBankerSeatId)
- self.PlayerView:setPlayerXiaoJiaVisible(viewId,true)
- end
-
-
-
- --断线重连
- function changpaiRoomView:recontactDoOperation(operationType,viewId,list,optype,isMoPaiOrId)
- local mType = ZPDef.CardType.CARD_TYPE_GROUP_OUT
-
- --[[
- if viewId == 1 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_1
- elseif viewId == 2 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_4
- elseif viewId == 3 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_3
- elseif viewId == 4 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_4
- end
- ]]
-
-
- if optype == ZPDef.SendCardType.TOU_THREE_SAME or optype == ZPDef.SendCardType.CHI_PAI_PENG then
- for k,v in ipairs(list) do
- self:createOpOutcard(viewId,mType,v,3)
- end
- elseif optype == ZPDef.SendCardType.BA_FOUR_SAME then
- for k,v in ipairs(list) do
- self:createOpOutcard(viewId,mType,v,4)
- end
- elseif optype == ZPDef.SendCardType.TWO_SUM_CHI then
- for k,v in ipairs(list) do
- self:createOpOutcard(viewId,mType,v,1)
- end
- end
-
- end
-
-
- function changpaiRoomView: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: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
- --self.PlayerView:setXiaoJiaFlagVis(true)
-
- local actualNum = app.room:getActualPlayerNum()
- --显示弃牌界面
- for i = 1,ZPDef.GameMaxPlayer do
- if i == 2 and actualNum == 3 then
- elseif (i == 1 or i == 3) and actualNum == 2 then
- else
- local name = string.format("Layout_tuopai_%d",i)
- self.ui.Items[name]:setVisible(true)
- 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.fourHongNum = hv.fourHongNum
- app.room.roomInfo.threeHongNum = hv.threeHongNum
- 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 = changpaiRoomXiaoJuView: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(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) 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 list,operationType = ZPFuc.getZPCardList(value.card,value.type)
- local isShow = true
- local card = value.opcard
- local optype = value.type
- hushu = hushu + value.hushu
-
- list = value.card
-
- --上面吃或不吃不要用if else因为还可能都不成立
- local isMoPaiOrId = value.seatId
- --创建桌面操作牌
- self:recontactDoOperation(operationType,viewId,list,optype,isMoPaiOrId)
- 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
- --self:getLocalHuShu()
-
- for i = 1, 4 do
- local tt = self.qiPaiList[i]
- end
-
- --恢复弃牌
- for k,v in pairs(roomInfo.arrayTableInfo) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- local qiList = self.qiPaiList[viewId] or {}
- 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.HuShu and v.nUserId then
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- self.PlayerView:setPlayerTuoShu(viewId,extIf.HuShu)
- end
- end
- end
- end
-
- --吃后巴后油牌
- if app.room.roomInfo.disCard then
- self:lockYouPai(app.room.roomInfo.disCard)
- end
-
-
- --self:setTotalTuoNum(app.room.roomInfo.totalTuoNum)
- local myViewId = self:getMeViewId()
- self.PlayerView:setPlayerTuoShu(myViewId,app.room.roomInfo.totalTuoNum)
-
- --状态显示
- 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)
- --self:setLayoutScoreTipVisible(true,playerList,false,nil,true)
-
- end
- end
-
- --显示坨数
- for k,v in pairs(roomInfo.arrayTableInfo) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- local tuoNum = v.totalTuoNum
- self.PlayerView:setPlayerTuoShu(viewId,tuoNum)
- 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_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
-
- local curOpView = app.room:getViewIdBySeatId(curOpeateid)
-
- local operationCardlist = {}
- local opeateCode = 0
- if #roomInfo.startOpList.BacardList > 0 then
- operationCardlist[roomInfo.startOpList.BaoperateCode] = {}
- for k,v in ipairs(roomInfo.startOpList.BacardList) do
- table.insert(operationCardlist[roomInfo.startOpList.BaoperateCode],v)
- end
- opeateCode = getNumOr(opeateCode,roomInfo.startOpList.BaoperateCode)
- end
- --操作码
- if #roomInfo.startOpList.ToucardList > 0 then
- operationCardlist[roomInfo.startOpList.TouoperateCode] = {}
- for k,v in ipairs(roomInfo.startOpList.ToucardList) do
- table.insert(operationCardlist[roomInfo.startOpList.TouoperateCode],v)
- end
- opeateCode = getNumOr(opeateCode,roomInfo.startOpList.TouoperateCode)
- end
- --标记天胡
- -- if roomInfo.startOpList.ishu == 1 then
- --opeateCode = ZPDef.OpCode.OP_HU
- --end
-
- local retHu = bit32.band(roomInfo.mainOpCode,ZPDef.OpCode.OP_HU)
- local retHu1 = bit32.band(roomInfo.mainOpCode,ZPDef.OpCode.OP_TIAN_HU)
-
- if retHu > 0 then
- opeateCode = getNumOr(opeateCode,ZPDef.OpCode.OP_HU)
- elseif retHu1 > 0 then
- opeateCode = ZPDef.OpCode.OP_TIAN_HU
- hasGuo = false
- self.isTianHu = true
- end
-
- if curOpView == self:getMeViewId() then
- if opeateCode > 0 then
- self:showOperation(opeateCode,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
- local operationCardlist = {}
- local opeateCode = 0
- if #roomInfo.startOpList.BacardList > 0 then
- operationCardlist[roomInfo.startOpList.BaoperateCode] = {}
- for k,v in ipairs(roomInfo.startOpList.BacardList) do
- table.insert(operationCardlist[roomInfo.startOpList.BaoperateCode],v)
- end
- opeateCode = getNumOr(opeateCode,roomInfo.startOpList.BaoperateCode)
- end
- --操作码
- if #roomInfo.startOpList.ToucardList > 0 then
- operationCardlist[roomInfo.startOpList.TouoperateCode] = {}
- for k,v in ipairs(roomInfo.startOpList.ToucardList) do
- table.insert(operationCardlist[roomInfo.startOpList.TouoperateCode],v)
- end
- opeateCode = getNumOr(opeateCode,roomInfo.startOpList.TouoperateCode)
- end
-
- if roomInfo.startOpList.ishu == 1 then
- opeateCode = getNumOr(opeateCode,ZPDef.OpCode.OP_HU)
- operationCardlist[ZPDef.OpCode.OP_HU] = {}
- table.insert(operationCardlist[ZPDef.OpCode.OP_HU],0) --自摸的时候发0
- end
-
- if opeateCode > 0 then
- self:showOperation(opeateCode,operationCardlist,self.isQiShou,true) --天胡没有过
- end
- elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_AFTER_OUTCARD == roomInfo.nStatus then
- --是否已经操作过 0表示没有,非0表示已经提交了操作
- self.isQiShou = false
- 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] = {}
- table.insert(opCardList[ZPDef.OpCode.OP_PENG],nCard)
- opCardList[ZPDef.OpCode.OP_CHI] = {}
- for k,v in ipairs(roomInfo.chiPaiList) do
- table.insert(opCardList[ZPDef.OpCode.OP_CHI],v)
- end
- self:showOperation(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)
- --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 --自己摸牌翻牌
- opCardList[ZPDef.OpCode.OP_HU] = {}
- table.insert(opCardList[ZPDef.OpCode.OP_HU],nCard)
- opCardList[ZPDef.OpCode.OP_BA_FAN] = {}
- table.insert(opCardList[ZPDef.OpCode.OP_BA_FAN],nCard)
- opCardList[ZPDef.OpCode.OP_PENG] = {}
- table.insert(opCardList[ZPDef.OpCode.OP_PENG],nCard)
- opCardList[ZPDef.OpCode.OP_CHI] = {}
- for k,v in ipairs(roomInfo.chiPaiList) do
- table.insert(opCardList[ZPDef.OpCode.OP_CHI],v)
- end
- 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)
- 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:showOperation(operateCode,opCardList,self.isQiShou,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
- local viewId = app.room:getViewIdBySeatId(roomInfo.showCardSeatId)
- --显示剩余牌
- self:setCircleCardLeftPanelView(true,viewId,diPaiMax)
- if viewId == self:getMeViewId() then
- self:setGuideView(true)
- self.bOutCard = true
- end
- elseif ZPDef.ReconnectState.GAME_STATUS_AUTO_DISCSRD == roomInfo.nStatus then --玩家自动弃牌中
- self.isQiShou = false
- 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)
- 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
- end
- end
-
-
- --提示报叫
- function changpaiRoomView:onTingCardResult(data)
- local function runTingCardResult(onEnd)
- log("2000000000-changpaiRoomView - (runTingCardResult)")
- local response = data.response
- local tingCards = response.tingCards
- local nBankerSeatId = app.room.roomInfo.nBankSeatId
- local viewId = app.room:getViewIdBySeatId(nBankerSeatId)
-
- 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-changpaiRoomView - addCallBack(runTingCardResult)")
-
- self:addCallBack(runTingCardResult)
- end
-
- --爆牌结果
- function changpaiRoomView:onBaoPaiResponese(data)
- local function runBaoPai(onEnd)
- log("2000000000-ZPRoomView - (runBaoPai)")
- 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
- self:addCallBack(runBaoPai)
- end
-
- function changpaiRoomView:lockMyHandCards()
- --先把手牌全部锁了
- for col = self.lieShuMax,1,-1 do --列数
- for row = self.hangShuMax,1,-1 do --行数
- self.handCardRoot[col].imgList[row].isKan = true
- self.handCardRoot[col].imgList[row]:setTouchEnabled(false)
- self.handCardRoot[col].imgList[row]:setColor(cc.c3b(125,125,125))
- end
- end
- --根据服务器发来的牌解锁
- for k,v in pairs(app.room.roomInfo.tingCards) do
- for col = self.lieShuMax,1,-1 do --列数
- for row = self.hangShuMax,1,-1 do --行数
- local cardValue = self.handCardRoot[col].imgList[row].value
- if v == cardValue then
- self.handCardRoot[col].imgList[row].isKan = false
- self.handCardRoot[col].imgList[row]:setTouchEnabled(true)
- self.handCardRoot[col].imgList[row]:setColor(cc.c3b(255,255,255))
- end
-
- end
- end
- end
-
- end
-
-
- -- 立即开始
- function changpaiRoomView:onQuickStartResponse(event)
- log("2000000000-ZPRoomView - 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 changpaiRoomView:onGameStartResponse()
-
- local function runGameStartResponse(onEnd)
- log("2000000000-ZPRoomView - runGameStartResponse()" )
-
- local actualNum = app.room:getActualPlayerNum()
- --显示弃牌界面
- for i = 1,ZPDef.GameMaxPlayer do
- if i == 2 and actualNum == 3 then
- elseif (i == 1 or i == 3) and actualNum == 2 then
- else
- local name = string.format("Layout_tuopai_%d",i)
- self.ui.Items[name]:setVisible(true)
- end
- end
- --重置玩家数据
- 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()
- --[[ if app.room.roomInfo.xiaoSeatId and app.room.roomInfo.xiaoSeatId >= 0 and app.room:getActualPlayerNum()==4 then
- app.room:updateUserSeateShowId()
- --self.PlayerView:setXiaoJiaFlagVis(true)
- elseif app.room:getActualPlayerNum()==3 then
- app.room:updateUserSeateShowId()
- end
- ]]
-
- 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:setOutCardVisible(true,fanViewId,fanCard,false,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))
-
- self.ui:runAction(seq)
-
-
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-ZPRoomView - addCallBack(runGameStartResponse)" )
- self:addCallBack(runGameStartResponse);
- end
-
- --@parm:手牌列表
- function changpaiRoomView:getLocalHuShu(list)
- return 0
- end
-
-
- function changpaiRoomView:onGameSendCardResponse()
- local function runGameSendCardResponse(onEnd)
- self.PlayerView:stopAndHideBaoAnim()
- log("2000000000-ZPRoomView - runGameSendCardResponse()" )
- if self.taiPaiTimer then
- cc.Director:getInstance():getScheduler():unscheduleScriptEntry(self.taiPaiTimer)
- end
-
- --显示指示器
- local bankerViewId = app.room:getViewIdBySeatId(app.room.roomInfo.nBankSeatId)
- local leftCardNum = 38
- if app.room:getActualPlayerNum() == 4 then--and GameFunctions.getCurFangShu() == 0
- leftCardNum = 33
- end
- 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(true)
-
- local xiaojiaViewId = app.room:getViewIdBySeatId(app.room.roomInfo.xiaoSeatId)
-
- local toujiaViewId = app.room:getViewIdBySeatId(app.room.roomInfo.nBankSeatId)
-
- self.myHandCardNums = 15
-
- for i = 1,ZPDef.GameMaxPlayer do
- if app.room:getActualPlayerNum() == 4 then
- if i == xiaojiaViewId and i ~= self:getMeViewId() then
- self.PlayerView:setLeftCardNum(i,true,5)
- elseif i == toujiaViewId and i ~= self:getMeViewId() then
- self.PlayerView:setLeftCardNum(i,true,16)
- else
- self.PlayerView:setLeftCardNum(i,true,15)
- end
- else
- if i == toujiaViewId and i ~= self:getMeViewId() then
- self.PlayerView:setLeftCardNum(i,true,16)
- elseif i ~= 2 then
- self.PlayerView:setLeftCardNum(i,true,15)
- end
- end
- end
-
- --保存自己手牌张数
- for i = 1,ZPDef.GameMaxPlayer do
- if app.room:getActualPlayerNum() == 4 then
- if i == xiaojiaViewId and i == self:getMeViewId() then
- self.myHandCardNums = 5
- elseif i == toujiaViewId and i == self:getMeViewId() then
- self.myHandCardNums = 16
- end
- else
- if i == toujiaViewId and i == self:getMeViewId() then
- self.myHandCardNums = 16
- end
- end
- end
-
-
- --self:setTotalTuoNum(app.room.roomInfo.totalTuoNum)
- local myViewId = self:getMeViewId()
- self.PlayerView:setPlayerTuoShu(myViewId,app.room.roomInfo.totalTuoNum)
-
- self.toolView:showTuoGuan(app.room.roomInfo.hosting==1)
-
- end
- log("2000000000-ZPRoomView - addCallBack(runGameSendCardResponse)" )
- self:addCallBack(runGameSendCardResponse);
- end
-
- function changpaiRoomView:createCard(bShowAnimation,nUserID,onEnd)
- logE("====================RoomView:createCard()===================");
-
- local cardList = app.room.cards[nUserID]
- if not cardList or table.nums(cardList) <= 0 then
- --重连当自己没有手牌且有7方门子
- if onEnd then
- onEnd()
- end
- return
- end
- local lieshuMax = table.nums(cardList)
- local RankCardList = {}
- local colList = self.lieshulist[lieshuMax]
- local blankList = self.lieshuBlanklist[lieshuMax]
-
- local wuIndex = 0
- local youIndex = 0
-
- --最后一列要固定所以加了一列 8+1 形式
- local tempLieshu = self.lieShuMax + 1
- --重新调整
- for k = 1,tempLieshu do
- if not cardList[k] then
- cardList[k] = {}
- end
- if table.nums(cardList[k]) <= 0 then
- wuIndex = wuIndex + 1
- local blankIndex = blankList[wuIndex] -- 1,10
- if blankIndex then
- RankCardList[blankIndex] = {}
- end
- else
- youIndex = youIndex + 1
- local index = colList[youIndex] -- 2,3,4,5,6,7,8,9
- RankCardList[index] = cardList[k]
- end
- end
-
- cardList = {}
- cardList = RankCardList
- logE("createCard Rank ok :"..table.tostring(cardList))
-
- local index = 1
- --不管有无数据,默认创建10列数据
- for i = 1,tempLieshu do
- local value = cardList[i] or {}
- local isKan = self:getCurrentColIsKan(value)
- local card = ChangPaiRoomCard:new(value,ZPDef.CardType.CARD_TYPE_HAND,i,isKan,false,self.colorType)
- local pos = self.boxPosList4[i]
- card.ui:setPosition(pos)
- self.ui.Items.LayoutMain_4:addChild(card.ui,1)
- --数据记录
- self.handCardRoot[i] = card
- self.handCardValueLocal[i] = value
- self.handCardValueBak[i] = clone(value)
-
- if i == 9 then
- self.handCardItem[index] = card.imgList[1] --最后第九列只能是摸牌 要注册点击事件
- break
- end
- --存储所有的单牌节点Image
- for k = 1 ,self.hangShuMax do
- self.handCardItem[index] = card.imgList[k]
- index = index + 1
- end
- end
-
- logE("create card finish self.handCardValueLocal : "..table.tostring(self.handCardValueLocal))
-
- if bShowAnimation then
- --发牌动画(10*0.1+ 0.15 = 1.15miao)
- for k,v in ipairs(self.handCardRoot) do
- if v.ui:isVisible() then
- v.ui:setVisible(false)
- local spawnTime = 0.3
- local mSpawn = cc.Spawn:create(cc.FadeIn:create(spawnTime),cc.CallFunc:create(function ()
- v.ui:setVisible(true)
- --播放发牌声音
- if k < table.nums(self.handCardRoot) - 4 then
- playVoiceGiveCard()
- end
- end))
- v.ui:runAction(cc.Sequence:create(cc.DelayTime:create(k * 0.05),mSpawn,cc.DelayTime:create(k * 0.05),cc.CallFunc:create(function()
- if k == self:getVisibleCardLayoutNum() then
-
- --排序
- self:RankCard()
- --注册点击
- self:registerCardTouch()
- if onEnd then
- onEnd()
- end
- end
- end)))
- end
- end
- else
- --注册点击
- self:registerCardTouch()
- --排序
- self:RankCard()
- if onEnd then
- onEnd()
- end
- end
-
-
-
- if app.room.roomInfo.disCard then
- local num = table.nums(app.room.roomInfo.disCard)
-
- if num > 0 then
- self:lockYouPai(app.room.roomInfo.disCard)
- end
- end
-
- if self.baoJiaoStatus == 1 then
- --[[ app.room.roomInfo.tingCards = {}
- table.insert(app.room.roomInfo.tingCards,self.moValue)--]]
- self:lockMyHandCards()
- end
- end
-
- -- 广播桌子上所有玩家庄家起手操作
- function changpaiRoomView:onBankerOutCard(data)
- local function runOnBankerOutCard(onEnd)
- log("2000000000-ZPRoomView - (runOnBankerOutCard)")
- logE("onBankerOutCard :"..table.tostring(data.response))
- if data.response.nUserId == app.room:getMyUserId() then
- if data.response.IsShouldOutCard > 0 then
- self:setGuideView(true)
- self.bOutCard = true
- end
- if data.response.mainOpCode ~= ZPDef.OpCode.OP_CANCEL then
- --操作码
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- self.operationLocalCode = data.response.mainOpCode
- self:showOperation(data.response.mainOpCode,viewId)
- self:setGuideView(false)
- self.bOutCard = false
- self.isTianHu = true
- 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-changpaiRoomView - addCallBack(runOnBankerOutCard)")
- self:addCallBack(runOnBankerOutCard);
- end
-
- --发牌后偷牌巴牌的操作
- function changpaiRoomView:onUserOperateResponse(data)
- local function runUserOperate(onEnd)
- log("2000000000-changpaiRoomView - (runUserOperate)")
- logE("runUserOperate :"..table.tostring(data.response))
- self.isQiShou = true
- if data.response.nUserId == app.room:getMyUserId() then
- if data.response.TouoperateCode ~= ZPDef.OpCode.OP_ERROR or data.response.BaoperateCode ~= ZPDef.OpCode.OP_ERROR then
- local ishu = data.response.ishu
- local hasGuo = true
- local operationCardlist = {}
- local opeateCode = 0
- self.outCard = 0
- if #data.response.BacardList > 0 then
- operationCardlist[data.response.BaoperateCode] = data.response.BacardList
- opeateCode = getNumOr(opeateCode,data.response.BaoperateCode)
- end
- --操作码
- if #data.response.ToucardList > 0 then
- operationCardlist[data.response.TouoperateCode] = data.response.ToucardList
- opeateCode = getNumOr(opeateCode,data.response.TouoperateCode)
- 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 then
- if retHu > 0 then
- opeateCode = getNumOr(opeateCode,ZPDef.OpCode.OP_HU)
- else
- opeateCode = ZPDef.OpCode.OP_TIAN_HU
- end
- end
-
- if ishu == 1 and self.isQiShou and opeateCode == ZPDef.OpCode.OP_TIAN_HU then
- hasGuo = false
- end
-
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- self.operationLocalCode = opeateCode
- if self.operationLocalCode > 0 then
- self:showOperation(opeateCode,operationCardlist,self.isQiShou,hasGuo)
- end
- --self:setTotalTuoNum(data.response.totalTuoNum)
- local myViewId = self:getMeViewId()
- self.PlayerView:setPlayerTuoShu(myViewId,data.response.totalTuoNum)
- 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-changpaiRoomView - addCallBack(runUserOperate)")
- self:addCallBack(runUserOperate);
- end
-
- --起手偷巴操作
- function changpaiRoomView:onUserOperateSuccess(data)
- local function runUserOperateSuccess(onEnd)
- log("2000000000-changpaiRoomView - (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)
-
- local mType = 4
-
- if viewId == 1 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_1
- elseif viewId == 2 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_4
- elseif viewId == 3 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_3
- elseif viewId == 4 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_4
- end
-
- 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:setTotalTuoNum(totoalTuoNum)
- --self:reflashHandCards()
- self.PlayerView:setPlayerTuoShu(viewId,totoalTuoNum)
- self:hideOperation()
- else
- self.PlayerView:setPlayerTuoShu(viewId,response.otherTuoNum)
- end
-
- if viewId ~= 4 then
- self.PlayerView:setLeftCardNum(viewId,true,leftCardNum)
- else
- self.myHandCardNums = leftCardNum
- end
-
- if onEnd then
- onEnd()
- end
- end
-
- log("2000000000-changpaiRoomView - addCallBack(runUserOperateSuccess)")
- self:addCallBack(runUserOperateSuccess);
- end
-
-
- function changpaiRoomView:removeHandByNums(card,nums)
- local nums = nums
- local tempLieshu = self.lieShuMax + 1
- for col = tempLieshu,1,-1 do --列数
- for row = self.hangShuMax,1,-1 do --行数
- local tempCard = self.handCardRoot[col].imgList[row].value
- if tempCard and card == tempCard and nums > 0 then
- table.remove(self.handCardValueLocal[col],row)
- self:rankDeletOneBakCard(card)
- --单张图片的值归nil
- self.handCardRoot[col].imgList[row].value = nil
- self.handCardRoot[col].imgList[row].isKan = false
- --单个图片隐藏
- self.handCardRoot[col].imgList[row]:setVisible(false)
- self.handCardRoot[col].imgList[row]:setColor(cc.c3b(255,255,255))
- nums = nums - 1
- end
- end
- end
- end
-
-
- function changpaiRoomView:cleanOpOutCard(viewId,card)
- if viewId then
- if self.opOutCard[viewId] then
- local index = 0
- local isfind = false
- local tempCardValue = {}
- for k,v in pairs(self.opOutCard[viewId]) do
- v:removeFromParent()
- if v.value == card and not isfind then
- index = tonumber(k)
- isfind = true
- end
- table.insert(tempCardValue,v.value)
- end
-
- self.opOutCard[viewId] = {}
-
- local mType = ZPDef.CardType.CARD_TYPE_GROUP_OUT
- --[[
- if viewId == 1 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_1
- elseif viewId == 2 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_4
- elseif viewId == 3 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_3
- elseif viewId == 4 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_4
- end
- ]]
-
- table.insert(tempCardValue,index,card)
-
- for k,v in pairs(tempCardValue) do
- self:createOpOutcard(viewId,mType,v,1)
- end
- end
- else
- for i = 1,ZPDef.GameMaxPlayer do
- if self.opOutCard[i] then
- for k,v in pairs(self.opOutCard[i]) do
- v:removeFromParent()
- end
- self.opOutCard[i] = {}
- else
- self.opOutCard[i] = {}
- end
- end
- end
- end
-
-
- function changpaiRoomView:createOpOutcard(viewId,mType,value,nums)
- local opLayout = string.format("Layout_groupCard_%d",viewId)
- local position = self.ui.Items[opLayout]:getPosition()
-
-
-
- local function onTouchBegan(touch)
- log("---changpaiRoomView onTouchBegan ---")
-
- if self.isTouchOpOutCard then
- return
- end
-
- self.isTouchOpOutCard = true
-
- local touchPos = touch:getLocation();
-
- local viewId = -1
-
- for i = 1, 4 do
- for k, v in ipairs(self.opOutCard[i] or {}) do
- local mSprite = v
- --local posNode = mSprite:convertToNodeSpace(touchPos);
- local width = mSprite:getContentSize().width
- local height = mSprite:getContentSize().height
- --不可以用getWorldPosition(),因为会出现旋转后,可点区域会停留在原来的地方。
- local x = mSprite:getPosition().x -width/2
- local y = mSprite:getPosition().y -height/2
- local tempWidth = width+50
- local tempHight = height+50
- local mRect = cc.Rectangle:new(x,y,tempWidth,tempHight)
- if mRect:contains(touchPos.x,touchPos.y) then
- viewId = v.viewId
- log("要放大的视图为:", viewId)
- end
- end
- end
-
- if viewId and viewId > -1 then
- local index = 1
-
- local colNum = ZPDef.OpOutCardNum[viewId]
- local colMax = math.modf(index/colNum)
-
- for k,v in ipairs(self.opOutCard[viewId]) do
- v:setScale(0.7)
- local pos = v:getPosition()
- if index > colNum then
- colMax = colMax + 1
- end
- index = index % colNum
- if index == 0 then
- index = colNum
- end
- --local opCardSize = cc.size(81,106)
- local endpos = cc.p(0,0)
-
- if self.desktopType == ZPDef.DesktopType.ThreeD then
- if viewId == 1 then
- endpos.x = pos.x + 7*index
- endpos.y = pos.y - index*20
- if colMax > 0 then
- endpos.x = endpos.x - colMax*20
- end
- elseif viewId == 2 then
- endpos.x = pos.x + index*15
- endpos.y = pos.y
- if colMax > 0 then
- endpos.y = endpos.y + colMax*25
- end
- elseif viewId == 3 then
- endpos.x = pos.x - 7*index
- endpos.y = pos.y - index*20
- if colMax > 0 then
- endpos.x = endpos.x + colMax*20
- end
- elseif viewId == 4 then
- endpos.x = pos.x + index*15
- endpos.y = pos.y
- if colMax > 0 then
- endpos.y = endpos.y - colMax*25
- end
- end
- else
- if viewId == 1 then
- endpos.x = pos.x
- endpos.y = pos.y - index*20
- if colMax > 0 then
- endpos.x = endpos.x - colMax*25
- end
- elseif viewId == 2 then
- endpos.x = pos.x + index*15
- endpos.y = pos.y
- if colMax > 0 then
- endpos.y = endpos.y + colMax*25
- end
- elseif viewId == 3 then
- endpos.x = pos.x
- endpos.y = pos.y - index*20
- if colMax > 0 then
- endpos.x = endpos.x + colMax*25
- end
- elseif viewId == 4 then
- endpos.x = pos.x + index*15
- endpos.y = pos.y
- if colMax > 0 then
- endpos.y = endpos.y - colMax*25
- end
- end
- end
-
- v:setPosition(endpos)
- index = index + 1
- end
- end
-
- return true
- end
-
- local function onTouchMove()
- log("---changpaiRoomView onTouchMove ---")
- return true
- end
-
- local function onTouchEnd()
- log("---changpaiRoomView onTouchEnd ---")
- self:restoreOpOutCard()
- return true
- end
-
- local function onTouchCancel()
- log("---changpaiRoomView onTouchCancel ---")
- self:restoreOpOutCard()
- end
-
- for i = 1,nums do
- local changpai = ChangpaiCard:new(value,mType,viewId,self.colorType,self.desktopType)
-
- if self.opOutCard[viewId] and table.nums(self.opOutCard[viewId]) > 0 then
- local colNum = ZPDef.OpOutCardNum[viewId]
- local opcardNum = #self.opOutCard[viewId]
- local colMax = math.modf(opcardNum/colNum)
- local orderX = position.x
- local orderY = position.y
- local offsetX = ZPDef.OpOutCardOffset[self.desktopType][viewId].x
- local offsetY = ZPDef.OpOutCardOffset[self.desktopType][viewId].y
- local offsetSpace = ZPDef.opOutCardSpace[self.desktopType][viewId]
-
- if viewId == 1 then
- if colMax > 0 then
- orderX = orderX - offsetSpace*colMax
- end
- orderX = orderX + offsetX*opcardNum
- orderY = orderY - (opcardNum%colNum)*offsetY
- elseif viewId == 2 then
- if colMax > 0 then
- orderY = orderY + offsetY*colMax
- end
- orderX = orderX + (opcardNum%colNum)*offsetX
- elseif viewId == 3 then
- if colMax > 0 then
- orderX = orderX + offsetSpace*colMax
- end
- orderX = orderX - offsetX*opcardNum
- orderY = orderY - (opcardNum%colNum)*offsetY
- elseif viewId == 4 then
- if colMax > 0 then
- orderY = orderY - offsetY*colMax
- end
- orderX = orderX + (opcardNum%colNum)*offsetX
- end
-
- changpai:setPosition(cc.p(orderX,orderY))
-
- else
- self.opOutCard[viewId] = {}
- changpai:setPosition(position)
- end
-
- table.insert(self.opOutCard[viewId],changpai)
- changpai:setTouchEnabled(true)
- changpai:registerTouchEvent(onTouchBegan,onTouchMove,onTouchEnd,onTouchCancel)
- local Zoreder = 100
- if viewId == 3 then
- Zoreder = 99
- else
- Zoreder = viewId * 100
- end
- self.ui.Items.Layout_HandCard:addChild(changpai,Zoreder)
- end
-
- end
-
-
- function changpaiRoomView:restoreOpOutCard()
- for viewId = 1, 4 do
- if self.opOutCard[viewId] then
- local index = 0
- local isfind = false
- local tempCardValue = {}
- for k,v in pairs(self.opOutCard[viewId]) do
- v:removeFromParent()
- table.insert(tempCardValue,v.value)
- end
-
- self.opOutCard[viewId] = {}
-
- local mType = ZPDef.CardType.CARD_TYPE_GROUP_OUT
-
- for k,v in pairs(tempCardValue) do
- self:createOpOutcard(viewId,mType,v,1)
- end
- end
- end
-
- self.isTouchOpOutCard = false
- end
-
- function changpaiRoomView:onGetHandcardsResponese(event)
-
- end
-
-
- --刷新手牌
- function changpaiRoomView:onReflashHandcardsResponese(event)
- local function runUserReflashHandcard(onEnd)
- log("2000000000-changpaiRoomView - onReflashHandcardsResponese()" )
-
- logD("onReflashHandcardsResponese self.handCardValueBak---",table.tostring(self.handCardValueBak));
- logD("onReflashHandcardsResponese self.handCardValueLocal---",table.tostring(self.handCardValueLocal));
- --uploadLogs("reflashhandcard2")
-
- self.ui.Items.LayoutMain_4:removeAllChildren()
- self.handCardRoot = {}
- self.handCardItem = {}
- self.handCardValueLocal = {}
- self.handCardValueBak = {}
- local myUserID = app.room:getMyUserId()
- self:createCard(false,myUserID,onEnd)
- end
-
- log("2000000000-changpaiRoomView - addCallBack(runUserReflashHandcard)")
- self:addCallBack(runUserReflashHandcard);
- end
-
-
-
- --解锁
- function changpaiRoomView:unLockYouPai()
- --根据服务器发来的牌解锁
- local tempLieshu = self.lieShuMax + 1
- for col = 1, tempLieshu do
- for row = 1,self.hangShuMax do
- self.handCardRoot[col].imgList[row].isKan = false
- self.handCardRoot[col].imgList[row]:setTouchEnabled(true)
- self.handCardRoot[col].imgList[row]:setColor(cc.c3b(255,255,255))
- end
- end
- end
-
-
- function changpaiRoomView:onBroadCastUserGetCard(data)
-
- local function runUserGetCard(onEnd)
- log("2000000000-changpaiRoomView - (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 moSepAction = cc.Sequence:create(cc.CallFunc:create(function()
- self:setMoCardVisible(true,moValue)
- self.isGodHand = true --播放动画的时候不能点击手牌
- end),
- cc.DelayTime:create(0.5),
- cc.CallFunc:create(function()
- self:setMoCardsPos()
- self.isGodHand = false
- if onEnd then
- onEnd()
- end
- end))
-
- self:runAction(moSepAction)
- local myViewId = self:getMeViewId()
- self.PlayerView:setPlayerTuoShu(myViewId,data.response.totoltuoNum)
-
- else
- 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_outCardLight_%d",viewId)
- local img = self.ui.Items[name]
- local size = img:getContentSize()
- --后抓精灵
- local mSprite = cc.ImageView:createNode()
- mSprite:loadTexture("zp_changpai/res/ui/zy_fangjian/btn_effect/effect/houzhua.png")
- img:addChild(mSprite)
- mSprite:setTag(HOUZHUA_TAG)
- if viewId == 2 then
- mSprite:setEulerRotation(cc.vec3(0,0,-90))
- end
- mSprite:setPosition(cc.p(size.width/2,size.height/2))
- mSprite:setScale(0.4)
- 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_outCardLight_%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-changpaiRoomView - addCallBack(runUserGetCard)")
- self:addCallBack(runUserGetCard);
- end
-
- --[[
- function changpaiRoomView:reflashHandCards()
- local card = self.moValue
- local isfind = false
- if card and card > 0 then
- for col = 1,self.lieShuMax do --列数
- for row = self.hangShuMax,1,-1 do --行数
- local temp = self.handCardRoot[col]
- local tempCard = self.handCardRoot[col].imgList[row].value
- if tempCard == card and not isfind then --牌堆未填满的状态
-
- --单张图片的值
- self.handCardRoot[col].imgList[row].value = nil
- self.handCardRoot[col].imgList[row].isKan = false
- --单个图片先隐藏
- self.handCardRoot[col].imgList[row]:setVisible(false)
- self.handCardRoot[col].imgList[row]:setColor(cc.c3b(255,255,255))
- --先把该张牌从前面牌堆删除
- table.remove(self.handCardValueLocal[col],row)
-
- --数据备份
- table.remove(self.handCardValueBak[col],row)
- self:rankDeletOneBakCard(card)
-
- isfind = true
- end
- end
- end
-
- if isfind then
-
- self:neatenCard(true)
-
- self:setMoCardVisible(true,card)
-
- end
- end
- end
- ]]
-
- function changpaiRoomView:setMoCardsPos()
-
- if self:checkMopaiVis() then
- log("changpaiRoomView setMoCardsPos",self.moValue)
-
- local moMaxIndex =self.moLieshu
-
- local card = self.moValue
-
- table.remove(self.handCardValueLocal[moMaxIndex],1)
-
- self:rankDeletOneBakCard(card)
- --单张图片的值归nil
- self.handCardRoot[moMaxIndex].imgList[1].value = nil
- self.handCardRoot[moMaxIndex].imgList[1].isKan = false
- --单个图片隐藏
- self.handCardRoot[moMaxIndex].imgList[1]:setVisible(false)
- self.handCardRoot[moMaxIndex].imgList[1]:setColor(cc.c3b(255,255,255))
-
- --找到牌的位置
- local firstCol,firstRow = self:findCardPos(card)
- log("--changpaiRoomView tobe--",firstCol,firstRow)
- local node = self.handCardRoot[firstCol].imgList[firstRow]
- node:loadTextureFromPlist(ZPFuc.getZPCardImgByValue(card,ZPDef.CardType.CARD_TYPE_HAND,self.colorType))
- node.value = card
- node.isKan = false
-
- self:restoreCardUiPos()
-
- self.handCardValueLocal[firstCol][firstRow] = card
- table.insert(self.handCardValueBak[firstCol],card)
- node:setVisible(true)
- end
-
- --保证牌已经摸进来了再锁牌
- if self.baoJiaoStatus == 1 then
- app.room.roomInfo.tingCards = {}
- table.insert(app.room.roomInfo.tingCards,self.moValue)
- self:lockMyHandCards()
- end
- end
-
- --还原每列的位置
- function changpaiRoomView:restoreCardUiPos()
-
- local tempLieshu = self.lieShuMax + 1
- for i = 1,tempLieshu do
- local card = self.handCardRoot[i]
- local pos = self.boxPosList4[i]
- card.ui:setPosition(pos)
- end
- end
-
-
- function changpaiRoomView:checkMopaiVis()
- --local moMaxIndex = self:getMoCardLieMax()
-
- --[[ if self.moLieshu > 0 then
- logD("changpaiRoomView checkMopaiVis",self.moLieshu)
- local node = self.handCardRoot[self.moLieshu].imgList[1]
- if node and node:isVisible() and self.moValue > 0 and node.value == self.moValue then
- return true
- end
- end--]]
-
-
- return true
- end
-
-
- function changpaiRoomView:setMoCardVisible(bisVsible,card)
- --local moPos = self:getMoCardPos()
- local moMaxIndex =self:getMoCardLieMax()
- self.moLieshu = moMaxIndex
- if bisVsible and self.moValue and self.moValue > 0 then
- local colUI = self.handCardRoot[moMaxIndex]
- local posUI = cc.p(0,0)
- posUI.x = colUI.ui:getPosition().x + 10
- colUI.ui:setPositionX(posUI.x)
- colUI.imgList[1].value = card
- local fileName = ZPFuc.getZPCardImgByValue(card,ZPDef.CardType.CARD_TYPE_HAND,self.colorType)
- colUI.imgList[1]:loadTextureFromPlist(fileName)
- colUI.imgList[1]:setVisible(true)
-
- table.insert(self.handCardValueLocal[moMaxIndex],card)
- --数据备份
- table.insert(self.handCardValueBak[moMaxIndex],card)
- end
- end
-
- --锁住吃后不能出的牌
- function changpaiRoomView:lockYouPai(youlist)
- --根据服务器发来的牌解锁
- for k,v in pairs(youlist) do
- local tempLieshu = self.lieShuMax + 1
- for col = tempLieshu,1,-1 do --列数
- for row = self.hangShuMax,1,-1 do --行数
- local cardValue = self.handCardRoot[col].imgList[row].value
- if v == cardValue and not self.handCardRoot[col].imgList[row].isKan then --防止锁两次
- self.handCardRoot[col].imgList[row].isKan = true
- self.handCardRoot[col].imgList[row]:setTouchEnabled(false)
- self.handCardRoot[col].imgList[row]:setColor(cc.c3b(125,125,125))
- end
-
- end
- end
- end
- end
-
- --通知玩家家出牌
- function changpaiRoomView:onBroadCastBankerOutCard(data)
- local function runBankerOutCardd(onEnd)
- log("2000000000-changpaiRoomView - (runBankerOutCardd)")
- logE("runBankerOutCardd :"..table.tostring(data.response))
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- --吃后不能出的牌
- self.isQiShou = false
- if data.response.nUserId == app.room:getMyUserId() then
- 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-changpaiRoomView - addCallBack(runBankerOutCardd)")
- self:addCallBack(runBankerOutCardd);
- end
-
- --过巴锁牌
- function changpaiRoomView:onGuoBaResponse(data)
- log("2000000000-changpaiRoomView - addCallBack(onGuoBaResponse)")
- local function runGuoBa(onEnd)
- logE("runBankerOutCardd :"..table.tostring(data.response))
-
- if data.response.nUserId == app.room:getMyUserId() then
- app.room.roomInfo.disCard = {}
-
- for k,v in ipairs(data.response.disCard or {}) do
- table.insert(app.room.roomInfo.disCard,v)
- end
-
- self:lockYouPai(app.room.roomInfo.disCard)
- end
-
- --结束
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-changpaiRoomView - addCallBack(runGuoBa)")
-
- self:addCallBack(runGuoBa)
- end
-
- --包赔提示
- function changpaiRoomView:onOutCardIsBaoPeiResponse(data)
- local baoPeiCard = data.response.bCard
- local view = import("zp_changpai.luaScript.Views.Room.changpaiRoomBaoPei"):new(baoPeiCard,0)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
-
-
- --出牌成功
- function changpaiRoomView:onOutCardSuccess(data)
- logE("changpaiRoomView:onOutCardSuccess(), response = ", table.tostring(data.response))
- local function runOnOutCardSuccess(onEnd)
- log("2000000000-changpaiRoomView - runOnOutCardSuccess")
- --设置出牌动画隐藏
- 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
-
- 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] = {}
- table.insert(operationCardlist[ZPDef.OpCode.OP_PENG],card)
- 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:showOperation(operateCode,operationCardlist,self.isQiShou,true)
- end
- --其他玩家显示
- self:setOutCardVisible(true,viewId,card,false,onEnd)
- else
- self.isGodHand = true
- local function rankDeletOneCard(card)
- local isEnd = false
- --倒叙遍历1-10列
- local tempLieshu = self.lieShuMax + 1
- for col = tempLieshu,1,-1 do --列数
- for row = self.hangShuMax,1,-1 do --行数
- if card == self.handCardRoot[col].imgList[row].value then --判断值是否相等
- logE("delete card1 ============= :"..card)
- table.remove(self.handCardValueLocal[col],row)
- --单张图片的值归nil
- self.handCardRoot[col].imgList[row].value = nil
- self.handCardRoot[col].imgList[row].isKan = false
- --单个图片隐藏
- self.handCardRoot[col].imgList[row]:setOpacity(255)
- self.handCardRoot[col].imgList[row]:setVisible(false)
- isEnd = true
- break
- end
- end
- if isEnd then
- break
- end
- end
- end
- local index = self.ui.Items.ImageView_handTempCard.index
- local lieshu = self.ui.Items.ImageView_handTempCard.lieshu
- local row = self.ui.Items.ImageView_handTempCard.hangshu --self:getRowByIndex(index)
- --说明:数据校验:弱网棋牌的通病(麻将出牌等一切可以允许玩家自己插牌的游戏,需要注意弱网情况,出牌会出现删错牌)
- --判断该列是否有牌
- if self.handCardValueLocal[lieshu] ~= nil and table.nums(self.handCardValueLocal[lieshu]) > 0 then
- --二次校验牌数据是否是出牌数据
- local recordValue = self.handCardRoot[lieshu].imgList[row].value
- if recordValue == card then
- logE("delete card2 ============= :"..card)
- table.remove(self.handCardValueLocal[lieshu],row)
- --数据干掉
- self.handCardRoot[lieshu].imgList[row].value = nil
- self.handCardRoot[lieshu].imgList[row].isKan = false
- --视图处理
- self.handCardRoot[lieshu].imgList[row]:setOpacity(255)
- self.handCardRoot[lieshu].imgList[row]:setVisible(false)
- 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()
- self.PlayerView:setPlayerTuoShu(myViewId,data.response.totoltuoNum)
-
- if viewId == self:getMeViewId() then
- self:reflashHandCards()
- end
-
- if self.baoJiaoStatus == 1 then
- app.room.roomInfo.tingCards = {}
- self:lockMyHandCards()
- end
- end
-
- end
- log("2000000000-changpaiRoomView - addCallBack(runOnOutCardSuccess)")
- self:addCallBack(runOnOutCardSuccess)
- end
-
-
- -- 操作成功
- function changpaiRoomView:onOperationCodeSuccess(data)
- local function runOnOperationSuccess(onEnd)
- log("2000000000-changpaiRoomView - (runOnOperationSuccess)")
- self:hideOperation()
-
- logE("changpaiRoomView:onOperationCodeSuccess :"..table.tostring(data.response))
- local response = data.response
- local nUserID = response.nUserId
- local card = 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 totalHuShu = response.totalHuShu
- 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
-
- --记录操作成功
- self.operationSuccessCode = operateCodes
- self.outCard = card
- self.chiCard = tablecard
-
- --视图ID
- local viewId = app.room:getViewIdByUserId(nUserID)
-
-
-
- if nUserID == app.room:getMyUserId() then
- --self:setTotalTuoNum(totalHuShu)
- self.PlayerView:setPlayerTuoShu(viewId,totalHuShu)
- else
- self.PlayerView:setPlayerTuoShu(viewId,response.otherTuoNum)
- end
- self.tableHuXiList[viewId] = totalHuShu
- self.PlayerView:setPlayerHuXi(viewId,totalHuShu)
- 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("changpaiRoomView: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,card,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 = ZPFuc.getZPCardImgByValue(self.outCard,ZPDef.CardType.CARD_TYPE_HAND,self.colorType)
- mSprite:loadTextureFromPlist(fileName)
- end
-
- if coperateCodes ~= 0 then
- self:runAction(cc.Sequence:create(cc.DelayTime:create(0),cc.CallFunc:create(function ()
- self:setLayoutScoreTipVisible(true,playerList,false,onEnd,true)
- app.room.roomInfo.winUserId = nUserID
- --self:playHuEffect(viewId,onEnd)
- if self.leftNum and not self.isTianHu and card ~= 0 and app.room.roomInfo.dianPaoSeatId == -1 and viewId == self.moPaiViewId then
- self:playMoPaiAni(self.leftNum,card,viewId,0,1,nil,true)
- end
- if onEnd then
- onEnd()
- end
- 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-changpaiRoomView - addCallBack(runOnOperationSuccess)")
-
- self:addCallBack(runOnOperationSuccess)
- end
-
-
- --多维数组转 一维数组
- function changpaiRoomView:ChangeDataToVector(data)
- local tt = {}
- local tempLieshu = self.lieShuMax + 1
- for i = 1, tempLieshu do
- for j = 1, #data[i] do ---因为理了牌之后本地牌值的数组和保存的数组可能会不一致,保存的数组的一列长度可能会大于行数,所以要判断数组的长度
- if data[i][j] then
- table.insert(tt,data[i][j])
- end
- end
- end
- return tt
- end
-
- function changpaiRoomView: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 changpaiRoomView:Chi(viewId,card,onEnd)
- logD("function do Chi")
- logE("changpaiRoomView chi:",card)
-
-
- local chilist = {}
-
- --吃的牌放下面
-
-
- table.insert(chilist, self.chiCard)
- table.insert(chilist, card)
-
-
- logE("changpaiRoomView chilist:",chilist)
-
- local nUserID = app.room:getUserIdByViewId(viewId)
- local mType = ZPDef.CardType.CARD_TYPE_GROUP_OUT
-
- --[[
- if viewId == 1 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_1
- elseif viewId == 2 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_4
- elseif viewId == 3 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_3
- elseif viewId == 4 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_4
- end
- ]]
-
-
- for k,v in ipairs(chilist) do
- self:createOpOutcard(viewId,mType,v,1)
- end
-
- if viewId == self:getMeViewId() then
- self:removeHandByNums(card,1)
- self:neatenCard(true)
- end
- if onEnd then
- onEnd()
- end
- end
-
-
- --用户碰(手动)
- function changpaiRoomView:Peng(viewId,card,onEnd)
- logD("function do Peng")
- logE("changpaiRoomView Peng:",card)
-
- local nUserID = app.room:getUserIdByViewId(viewId)
- local mType = ZPDef.CardType.CARD_TYPE_GROUP_OUT
-
- --[[
- if viewId == 1 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_1
- elseif viewId == 2 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_4
- elseif viewId == 3 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_3
- elseif viewId == 4 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_4
- end
- ]]
-
-
- self:createOpOutcard(viewId,mType,card,3)
-
- if viewId == self:getMeViewId() then
- self:removeHandByNums(card,2)
- self:neatenCard(true)
- end
- if onEnd then
- onEnd()
- end
- end
-
-
- --用户偷(手动)
- function changpaiRoomView:Tou(viewId,card,onEnd)
- logD("function do Tou")
- logE("changpaiRoomView Tou:",card)
-
- local nUserID = app.room:getUserIdByViewId(viewId)
- local mType = ZPDef.CardType.CARD_TYPE_GROUP_OUT
-
- --[[
- if viewId == 1 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_1
- elseif viewId == 2 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_4
- elseif viewId == 3 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_3
- elseif viewId == 4 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_4
- end
- ]]
-
-
- self:createOpOutcard(viewId,mType,card,3)
-
- if viewId == self:getMeViewId() then
- self:removeHandByNums(card,3)
- self:neatenCard(true)
- end
- local list = self.handCardValueLocal
- if onEnd then
- onEnd()
- end
- end
-
-
- --用户巴(手动)
- function changpaiRoomView:Ba(viewId,card,onEnd)
- logD("function do Ba")
- logE("changpaiRoomView Ba:",card)
-
- local nUserID = app.room:getUserIdByViewId(viewId)
- local mType = ZPDef.CardType.CARD_TYPE_GROUP_OUT
-
- local operateCode = self.operationSuccessCode
-
- --[[
- if viewId == 1 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_1
- elseif viewId == 2 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_4
- elseif viewId == 3 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_3
- elseif viewId == 4 then
- mType = ZPDef.CardType.CARD_TYPE_OPCARD_4
- end
- ]]
-
-
- self:cleanOpOutCard(viewId,card)
- --self:createOpOutcard(viewId,mType,card,1)
- if viewId == self:getMeViewId() then
- self:removeHandByNums(card,1)
- self:neatenCard(true)
- end
-
- if onEnd then
- onEnd()
- end
- end
-
-
- function changpaiRoomView:doOperation(operationType,viewId,card,onEnd)
- if operationType == ZPDef.OpType.OP_TYPE_CHI then
- self:Chi(viewId,card,onEnd)
- self:showOperatorTip(viewId,operationType)
- 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_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 changpaiRoomView:showOperatorTip(viewId,mType)
- if self.isBaopei and self.isBaopei == 1 and mType == ZPDef.OpType.OP_TYPE_CHI then
- mType = -56 --吃后包赔
- end
- self.PlayerView:showOperatorTip(viewId,mType)
- end
-
- --弃牌动画
- --断线重连的时候,不需要动画
- --[[
- isShowAni:是否展示弃牌动画
- disCard:弃牌
- viewId:视图ID
- isDianPaoPeng:碰胡规则,点炮碰,弃牌要显示透明形态
- ]]
- function changpaiRoomView: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)
-
- if self.colorType == ZPDef.ColorType.YELLOW then
- self.littleCardScale = 0.9
- else
- self.littleCardScale = 0.9
- end
-
- --牌的图片
- local outCardImg = self.ui.Items[outCardname]
- --牌的图片父节点
- local outCardLayout = self.ui.Items[outCardPoint]
-
- --弃牌的layout
- local giveUpLayout = self.ui.Items[giveupCardname]
- --获取弃牌节点存在的数量
- local count = giveUpLayout:getChildrenCount()
- --创建一张精灵
- local mSprite = cc.ImageView:createNode()
- mSprite:setScale(self.littleCardScale)
- local finalFileName = ZPFuc.getZPCardImgByValue(disCard,ZPDef.CardType.CARD_TYPE_SMALL,self.colorType)
- mSprite:loadTextureFromPlist(finalFileName)
- mSprite:setScale(0.45)
- mSprite:setVisible(false)
- mSprite:setAnchorPoint(cc.p(0,0))
- mSprite.value = disCard
- giveUpLayout:addChild(mSprite)
-
- local width = mSprite:getContentSize().width*0.5 * self.littleCardScale;
- local height = mSprite:getContentSize().height*0.5* self.littleCardScale;
-
- local getHeightCount = function (count)
- local num = 6
- if viewId == 2 then
- num = 9
- elseif viewId == self:getMeViewId() then
- num = 7
- end
- if count >= num then
- return math.floor(count / num)
- else
- return 0
- end
- end
-
- local x = 0
-
- if viewId == 2 then
- x = count % 9
- elseif viewId == self:getMeViewId() then
- x = count % 7
- else
- x = count % 6
- end
-
- 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)
-
- --动画显示
- 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 = ZPFuc.getZPCardImgByValue(disCard,ZPDef.CardType.CARD_TYPE_HAND,self.colorType)
- --弃牌
- 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
- 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)))
- end
- end
-
-
- function changpaiRoomView:onUserGetCardOperteResponse(data)
- local function runonUserGetCardOperte(onEnd)
- log("2000000000-changpaiRoomView - (runonUserGetCardOperte)")
- logE("runonUserGetCardOperte :"..table.tostring(data.response))
- if data.response.nUserId == app.room:getMyUserId() then
- if data.response.TouoperateCode ~= ZPDef.OpCode.OP_ERROR or data.response.BaoperateCode ~= ZPDef.OpCode.OP_ERROR then
- local operationCardlist = {}
- local opeateCode = 0
- local ishu = data.response.ishu
- local hasGuo = true
- self.outCard = 0
- if #data.response.BacardList > 0 then
- operationCardlist[data.response.BaoperateCode] = data.response.BacardList
- opeateCode = getNumOr(opeateCode,data.response.BaoperateCode)
- end
- --操作码
- if #data.response.ToucardList > 0 then
- operationCardlist[data.response.TouoperateCode] = data.response.ToucardList
- opeateCode = getNumOr(opeateCode,data.response.TouoperateCode)
- end
-
- if ishu == 1 then
- opeateCode = getNumOr(opeateCode,ZPDef.OpCode.OP_HU)
- 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:showOperation(opeateCode,operationCardlist,self.isQiShou,hasGuo)
- self:setGuideView(false)
- self.bOutCard = false
- end
- --self:setTotalTuoNum(data.response.totalTuoNum)
-
- self.PlayerView:setPlayerTuoShu(viewId,data.response.totalTuoNum)
- 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-changpaiRoomView - addCallBack(runonUserGetCardOperte)")
- self:addCallBack(runonUserGetCardOperte);
- end
-
- function changpaiRoomView:playMoPaiAni(leftCardNum,turnOverCard,viewId,mainOpCode,showCardFlag,onEnd,isNotShowAni,isBaopeiChi,chiOpCardList)
- 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 = ZPFuc.getZPCardImgByValue(0xfa,ZPDef.CardType.CARD_TYPE_HAND,self.colorType)
- local fileNameReal = ZPFuc.getZPCardImgByValue(turnOverCard,ZPDef.CardType.CARD_TYPE_HAND,self.colorType)
-
- 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] = {}
- table.insert(operationCardlist[ZPDef.OpCode.OP_PENG],turnOverCard)
- 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:showOperation(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 changpaiRoomView:onMoPai(data)
- local function runOnMoPai(onEnd)
- 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
-
- 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)
-
- 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-ZPRoomView - addCallBack(runOnMoPai)")
-
- self:addCallBack(runOnMoPai)
- end
-
-
- -- 小局结算
- function changpaiRoomView: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()
- self:setLiangPaiVisible(true)
- 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.fourHongNum = v.fourHongNum
- roomInfo.threeHongNum = v.threeHongNum
- 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()
-
- --完成手牌展示
- 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 tuoNum = v.totalTuoNum
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- self.PlayerView:setPlayerTuoShu(viewId,tuoNum)
- --[[logE("XiaoJu nUserID:"..v.nUserId)
- logE("XiaoJu cardList:"..table.tostring(cardData))--]]
- end
- self.xiaojuChaPaiView:liangShouPai(false)
-
- --玩家分数
- 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 = changpaiRoomXiaoJuView:new(nextCallBackFun,false,self.colorType)
- else
- self.xiaojuView = changpaiRoomXiaoJuView:new(showAllJieSuan,false,self.colorType)
- end
-
- self:addChild(self.xiaojuView)
- self.xiaojuView:setVisible(false)
- --结束
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-changpaiRoomView - addCallBack(runGameXiaoJuResponse)" )
- self:addCallBack(runGameXiaoJuResponse);
- end
-
-
- function changpaiRoomView:onQiangBaResponese(data)
- log("2000000000-changpaiRoomView - addCallBack(onQiangBaResponese)" )
- local function runQiangBa(onEnd)
- 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:showOperation(code,operationCardlist,false,true)
- end
-
- if self:getIsMeUId(nUserId) then
- --检测是否少牌
- self:checkCardAndRecover()
- end
-
- --结束
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-ZPRoomView - addCallBack(runQiangBa)")
-
- self:addCallBack(runQiangBa)
- end
-
- --弃牌
- function changpaiRoomView:onQiPai(data)
- changpaiRoomView.super.onQiPai(self, data)
- local function runOnQiPai(onEnd)
- self:hideOperation()
- --结束
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-changpaiRoomView - addCallBack(runOnQiPai)")
- self:addCallBack(runOnQiPai)
- end
-
-
- --游戏消息
- function changpaiRoomView:bindGameMessage()
- changpaiRoomView.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 changpaiRoomView:changeViewType(event)
-
- if event and event.desktopType and self.desktopType~=event.desktopType then
- self.desktopType=event.desktopType
- end
-
- if event and event.colorType and self.desktopType~=event.colorType then
- self.colorType=event.colorType
- self:initMySelfCardPos()
-
- if self.xiaojuChaPaiView then
- self.xiaojuChaPaiView:setCardColorType(event.colorType)
- end
- end
-
- self:loadTextureCache()
-
- self.ui:sendMsg(app.room,ZPDef.ZPEvent.GetTableInfo)
-
- end
-
- function changpaiRoomView:showOperation(mainOpCode,viewId,card,hasGuo)
- self.operationView:setVisible(true)
- self.operationView:setSameParame(self.outCard,self.handCardValueLocal)
- local ret1 = bit32.band(mainOpCode,ZPDef.OpCode.OP_HU)
- if ret1 > 0 and self.baoJiaoStatus == 1 then
- hasGuo = false
- end
- if self.isBiChi and self.isBiChi == 2 then
- hasGuo = false
- end
- self.operationView:showOperation(mainOpCode,viewId,card,hasGuo,self.isTishi,self.colorType)
- --检测是否少牌
- --self:neatenCard(true)--无感知的整理一次手牌
- self:checkCardAndRecover()
- self.isTishi = false
- end
-
- function changpaiRoomView:hideOperation()
- self.operationView:hideSelf()
- end
-
- --判断列数是否是砍牌
- function changpaiRoomView:getCurrentColIsKan(list)
- local isKan = false
- if list[1] and list[2] and list[3] then
- if list[1] == list[2] and list[2] == list[3] then
- isKan = true
- end
- end
- return false
- end
- --判断列数是否是龙
- function changpaiRoomView:getCurrentColIsLong(list)
- local isLong = false
- if list[1] and list[2] and list[3] and list[4] then
- if list[1] == list[2] and list[2] == list[3] and list[3] == list[4] then
- isLong = true
- end
- end
- return false
- end
-
-
- function changpaiRoomView:resetGameData()
- changpaiRoomView.super.resetGameData(self)
- self.isQiShou = true
- self.moValue = 0
- for i = 1,ZPDef.GameMaxPlayer do
- self.PlayerView:setPlayerTuoShu(i, 0)
- end
- self.isBiChi = 0
- --self:setTotalTuoNum(0)
- self.handCardItem = {}
- self:cleanOpOutCard()
- self.PlayerView:hideBaoJiao()
- self.baoJiaoStatus = 0
- self.isTishi = false
- self.moLieshu = 0
- self.myHandCardNums = 0
- end
-
-
- --设置总坨数
- --[[
- function changpaiRoomView:setTotalTuoNum(num)
- self.ui.Items.Text_tuoNum:setText(tostring(num))
- end
- ]]
-
-
-
- --隐藏出牌点
- function changpaiRoomView: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 = ZPFuc.getZPCardImgByValue(card,ZPDef.CardType.CARD_TYPE_HAND,self.colorType)
- 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("changpaiRoomView:setOutCardVisible"..table.tostring(request))
- self.ui:sendMsg(app.room, "sendOutCard", request, function(status, response)
- logE("changpaiRoomView sendOutCard() response = ", table.tostring(response))
- end)
- end
- if onEnd then
- onEnd()
- end
- end))
- mSprite:runAction(seq)
- end
- end
-
-
- function changpaiRoomView:getMoCardPos()
- local showColNum = self:getVisibleCardLayoutNum()
- local orederPos = cc.p(900,-80)
- if showColNum == 0 then
- return orederPos
- end
- if showColNum <= self.lieShuMax then
- --根据当前存在的列数获取一个枚举列表,让手牌的列数重新旋转到指定新的列数
- local list = self.lieshulist[showColNum]
- local youIndex = 0
-
- for k = 1,self.lieShuMax do
- if #self.handCardValueLocal[k] > 0 then
- youIndex = youIndex + 1
- end
- end
-
- local index = list[youIndex] + 1 -- 3 4 5 6 7 8 摸牌的位置要和手牌隔开
-
- local tarPos = self.boxPosList4[index]
- orederPos.x = tarPos.x + 10
- orederPos.y = tarPos.y
- end
-
- return orederPos
- end
-
-
- function changpaiRoomView:getMoCardLieMax()
- local showColNum = self:getVisibleCardLayoutNum()
- logD("changpaiRoomView getMoCardLieMax",showColNum)
- if showColNum == 0 then
- return 5
- end
- local tempLieshu = self.lieShuMax + 1
- if showColNum <= tempLieshu then
- --根据当前存在的列数获取一个枚举列表,让手牌的列数重新旋转到指定新的列数
- local list = self.lieshulist[showColNum]
- local youIndex = 0
-
- for k = 1,self.lieShuMax do
- if #self.handCardValueLocal[k] > 0 then
- youIndex = youIndex + 1
- end
- end
-
- local index = list[youIndex] + 1 -- 3 4 5 6 7 8 摸牌的位置要和手牌隔开
-
- return index
-
- end
-
- return 5
- end
-
-
- function changpaiRoomView:setColorWhite()
- if app.room:isLittleFamily() and not ZPFuc.getLittleIsCanLookCard() then
- return
- end
- self.ui.Items.Button_OutCard:setEnabled(false)
- local tempLieshu = self.lieShuMax + 1
- for col = 1, tempLieshu do
- for row = 1,self.hangShuMax do
- if not self.handCardRoot[col].imgList[row].isKan then
- self.handCardRoot[col].imgList[row]:setColor(cc.c3b(255,255,255))
- end
- end
- end
- end
-
-
- function changpaiRoomView:requestFlashHandCard()
- local request = ZPMessage.ReflashHandCard:new()
- request.isFflash = 1
- logE("reflashHandCard:"..table.tostring(request))
- self.ui:sendMsg(app.room, "reflashHandCard", request, function(status, response)
- logE("changpaiRoomView reflashHandCard() response = ", table.tostring(response))
- end)
- end
-
-
- --检测是否少牌,如果少牌则恢复 --目前在抓牌,出牌成功,和显示操作三个地方检测少牌情况
- function changpaiRoomView:checkCardAndRecover()
- --当前的手牌数
- local curCardNum = 0
- --当前显示的手牌数
- local curShowNum = 0
- --实际手牌数
- local factCardNum = 0
- --计算当前手牌数
- for i,cards in pairs(self.handCardValueLocal) do
- for j,card in pairs(cards) do
- if card and card > 0 then
- curCardNum = curCardNum + 1
- end
- end
- end
- --计算当前显示的手牌数
- local tempLieshu = self.lieShuMax + 1
- for i = 1,tempLieshu do
- if self.handCardRoot[i].ui:isVisible() then
- for j = 1,self.hangShuMax do
- if self.handCardRoot[i].imgList[j]:isVisible() and self.handCardRoot[i].imgList[j]:getOpacity() == 255
- and self.handCardRoot[i].imgList[j].value then
- curShowNum = curShowNum + 1
- end
- end
- end
- end
- --计算备份数据的手牌数(以这个数据为准)
- for i,cards in pairs(self.handCardValueBak) do
- for j,card in pairs(cards) do
- if card and card > 0 then
- factCardNum = factCardNum + 1
- end
- end
- end
- logD("checkCardAndRecover curCardNum="..curCardNum.." curShowNum="..curShowNum.." factCardNum="..factCardNum)
- if curCardNum ~= factCardNum or curShowNum ~= factCardNum then
- print("checkCardAndRecover curCardNum="..curCardNum.." curShowNum="..curShowNum.." factCardNum="..factCardNum)
- logD("checkCardAndRecover self.handCardValueBak---",table.tostring(self.handCardValueBak));
- logD("checkCardAndRecover self.handCardValueLocal---",table.tostring(self.handCardValueLocal));
- --self:onTransferCard(self.handCardValueBak)
- self:requestFlashHandCard()
- --uploadLogs("changpaipaishaopai")
- end
- end
-
-
- --如果牌正在掉落的时候,不允许操作!
- --落牌检测
- function changpaiRoomView:downCard()
- if app.room:isLittleFamily() and (not ZPFuc.getLittleIsCanLookCard()) then
- return
- end
- --是否需要掉落
- local bDown = false
- local temphangshu = self.hangShuMax - 1
- for i = 1,self.lieShuMax do
- if self.handCardRoot[i].ui:isVisible() then
- for j = 1, temphangshu do
- for k = j+1,self.hangShuMax do
- if not self.handCardRoot[i].imgList[j]:isVisible() and self.handCardRoot[i].imgList[k]:isVisible() then
- --底部
- local firstValue = self.handCardRoot[i].imgList[j].value
- --顶部
- local secondeValue = self.handCardRoot[i].imgList[k].value
-
- --插入
- --数据交换
- local tempValue = nil
- tempValue = self.handCardRoot[i].imgList[j].value
- self.handCardRoot[i].imgList[j].value = self.handCardRoot[i].imgList[k].value
- self.handCardRoot[i].imgList[k].value = tempValue
-
-
- --换底数据
- --[[local tempHuanDi = nil
- tempHuanDi = self.handCardRoot[i].imgList[j].isHuanDi
- self.handCardRoot[i].imgList[j].isHuanDi = self.handCardRoot[i].imgList[k].isHuanDi
- self.handCardRoot[i].imgList[k].isHuanDi = tempHuanDi--]]
- --ui交换
- self.handCardRoot[i].imgList[k]:setVisible(false)
- local fileName = ZPFuc.getZPCardImgByValue(self.handCardRoot[i].imgList[j].value,ZPDef.CardType.CARD_TYPE_HAND,self.colorType)
- self.handCardRoot[i].imgList[j]:loadTextureFromPlist(fileName)
- self.handCardRoot[i].imgList[j]:setVisible(true)
-
- --听牌标签
- local visibleA = self.handCardRoot[i].imgList[j]:getChildren()[1]:isVisible()
- local visibleB = self.handCardRoot[i].imgList[k]:getChildren()[1]:isVisible()
- self.handCardRoot[i].imgList[j]:getChildren()[1]:setVisible(visibleB)
- self.handCardRoot[i].imgList[k]:getChildren()[1]:setVisible(visibleA)
-
- --落牌动画
- local lieshu = self.ui.Items.ImageView_handTempCard.lieshu
- local value = self.ui.Items.ImageView_handTempCard.value
- --if self.handCardRoot[i].imgList[j].value == value and i == lieshu then
- -- self:goBackWithAni(self.handCardRoot[i].imgList[j])
- --else
- local recordPos = self.handCardRoot[i].imgList[j]:getParent():getPosition()
- self.handCardRoot[i].imgList[j]:getParent():setPosition(self.handCardRoot[i].imgList[k]:getParent():getPosition())
- local act = cc.MoveTo:create(self.gameSpeedConfig.OPCARDTIME,recordPos)
- --self.handCardRoot[i].imgList[j]:getParent():stopAllActions()
- self.handCardRoot[i].imgList[j]:getParent():runAction(act)
- --end
-
- bDown = true
- end
- end
- end
- end
- end
- --判断是否有掉落
- if not bDown then
- self.isGodHand = false
- else
- local seq = cc.Sequence:create(cc.DelayTime:create(0.25),cc.CallFunc:create(function ()
- self.isGodHand = false
- end))
- self.ui:runAction(seq)
- end
- end
-
-
- --整理牌
- function changpaiRoomView:neatenCard(isNotShowAni)
- --logE("neatenCard -------- ", debug.traceback())
-
- --摆放摸牌
- --self:reflashHandCards()
- --是否短暂屏蔽点击牌事件
- self:downCard()
- self:RankCard(isNotShowAni)
- self:unLockYouPai()
- if app.room.roomInfo.disCard then
- local num = table.nums(app.room.roomInfo.disCard)
-
- if num > 0 then
- self:lockYouPai(app.room.roomInfo.disCard)
- end
- end
- if self.baoJiaoStatus == 1 then
- self:lockMyHandCards()
- end
- end
-
-
- --注册点击事件
- function changpaiRoomView:registerCardTouch()
- 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
-
- --触摸
- for k,v in ipairs(self.handCardItem) do
- local function onTouchBegan(touch)
- --[[if app.room:isLittleFamily() then
- --showTooltip("小家禁止操作")
- return
- end--]]
- if self.isGodHand then
- --showTooltip("禁止操作")
- return
- end
- local posOO = getPosOO()
- local localPos = touch:getLocation();
- local pos = cc.p(localPos.x - posOO.x, localPos.y - posOO.y);
-
- local lieshu = v.lieshu
- local hangshu = v.hangshu
- local value = v.value
- local isKan = v.isKan
- if isKan then
- --showTooltip("坎牌不可移动")
- return
- end
-
- self.handCardRoot[lieshu].ui:setVisible(true)
-
- if value == nil then
- return
- end
- --playZiPaiSelectCardVoice()
- logE("88888888-=============onTouchBegan1================")
- logE("88888888-isKan:")
- logE(isKan)
- logE("88888888-touch lieshu:",lieshu)
- logE("88888888-touch hangshu:",hangshu)
- logE("88888888-touch value:",value)
- if value - 16 > 0 then
- logE("玩家点了"..lieshu.."列"..hangshu.."行的大"..value - 16)
- else
- logE("玩家点了"..lieshu.."列"..hangshu.."行的小"..value)
- end
- if isKan then
- logE("该牌为坎牌")
- else
- logE("该牌不是坎牌")
- end
- logE("88888888-card :"..table.tostring(self.handCardValueLocal))
- logE("88888888-=============onTouchBegan2================")
- v:setOpacity(0)
- if self.ui.Items.ImageView_handTempCard.cIdx ~= k then
- self:setColorWhite()
- v:setColor(ZPDef.ColorConfig.TOUCH_CARD_COLOR)
- self.ui.Items.Button_OutCard:setEnabled(true)
- elseif self.ui.Items.ImageView_handTempCard.cIdx == k then
- if v:getColor().r == ZPDef.ColorConfig.TOUCH_CARD_COLOR.r and v:getColor().g == ZPDef.ColorConfig.TOUCH_CARD_COLOR.g and v:getColor().b == ZPDef.ColorConfig.TOUCH_CARD_COLOR.b then
- --self:setColorWhite()
- --self.ui.Items.Button_OutCard:setEnabled(false)
-
- if v.value == nil then
- showTooltip("牌已经操作过!")
- return
- end
-
- if not self.bOutCard then
- self:setColorWhite()
- self.ui.Items.Button_OutCard:setEnabled(false)
- return
- end
-
- self.ui.Items.ImageView_handTempCard:setVisible(false)
-
- v:setOpacity(0)
- self:sendOutCard(v.value)
- logE("玩家出牌:"..v.value)
- self.bOutCard = false
- self.isGodHand = true;
- --记录数据
- local lieshu = v.lieshu
- local hangshu = v.hangshu
- local value = v.value
-
- self.ui.Items.ImageView_handTempCard.lieshu = lieshu
- self.ui.Items.ImageView_handTempCard.hangshu = hangshu
- self.ui.Items.ImageView_handTempCard.value = value
- self.ui.Items.ImageView_handTempCard.index = k
- return
- else
- v:setColor(ZPDef.ColorConfig.TOUCH_CARD_COLOR)
- self.ui.Items.Button_OutCard:setEnabled(true)
- end
- end
-
- self:showTingPaiView(v.value)
-
- --出牌线
- self:setOutCardLineVisible(true)
-
- --临时牌
- self.ui.Items.ImageView_handTempCard.cIdx = k
- self.ui.Items.ImageView_handTempCard.lieshu = lieshu
- self.ui.Items.ImageView_handTempCard.hangshu = hangshu
- self.ui.Items.ImageView_handTempCard.value = value
- self.ui.Items.ImageView_handTempCard.index = k
- self.ui.Items.ImageView_handTempCard:setVisible(true)
- self.ui.Items.ImageView_handTempCard:loadTextureFromPlist(ZPFuc.getZPCardImgByValue(value,ZPDef.CardType.CARD_TYPE_HAND,self.colorType))
- self.ui.Items.ImageView_handTempCard:setPosition(pos)
- end
- local function onTouchMove(touch)
- if self.isGodHand then
- --showTooltip("end 禁止操作")
- return
- end
- local posOO = getPosOO()
- local localPos = touch:getLocation();
- local pos = cc.p(localPos.x - posOO.x, localPos.y - posOO.y);
- self.ui.Items.ImageView_handTempCard:setPosition(pos)
- end
- local function onTouchEnd(touch)
- if self.isGodHand then
- --showTooltip("end 禁止操作")
- return
- end
- logE("88888888-=============onTouchEnd1================")
- if not self.ui.Items.ImageView_handTempCard:isVisible() then
- --showTooltip("End 临时牌阻止了事件")
- v:setOpacity(255)
- self.ui.Items.ImageView_handTempCard:setVisible(false)
- return
- end
- self.ui.Items.ImageView_handTempCard:setVisible(false)
- --出牌线
- self:setOutCardLineVisible(false)
- if v.isKan then
- return
- end
- if not v.value then
- return
- end
- v:setOpacity(255)
- --回到原点动画
- self:goBackWithAni(v,0.15)
- logE("88888888-=============onTouchEnd2================")
- end
- local function onTouchCancel(touch)
- if self.isGodHand then
- --showTooltip("禁止操作")
- return
- end
- self:setColorWhite()
- logE("88888888-=============onTouchCancel 1================")
- --出牌线
- self:setOutCardLineVisible(false)
- if not self.ui.Items.ImageView_handTempCard:isVisible() then
- --showTooltip("cancel 临时牌阻止了事件")
- v:setOpacity(255)
- self.ui.Items.ImageView_handTempCard:setVisible(false)
- return
- end
- self.ui.Items.ImageView_handTempCard:setVisible(false)
-
- if v.isKan then
- return
- end
- if not v.value then
- return
- end
-
- v:setOpacity(255)
- --临时牌
- self.ui.Items.ImageView_handTempCard:setVisible(false)
- local touchPos = touch:getLocation()
- -------------------------------------------------------
- -------------------------------------------------------
- local hitCount = 0
- local hitItem = {}
- for i = #self.handCardItem - 1,1,-1 do
- local mSprite = self.handCardItem[i]
- local posNode = mSprite:convertToNodeSpace(touchPos);
- local width = mSprite:getContentSize().width
- local height = mSprite:getContentSize().height
- --不可以用getWorldPosition(),因为会出现旋转后,可点区域会停留在原来的地方。
- local x = mSprite:getPosition().x
- local y = mSprite:getPosition().y
- local mRect = cc.Rectangle:new(x,y,width,height)
- if mRect:contains(posNode.x,posNode.y) then
- hitCount = hitCount + 1
- hitItem[hitCount] = mSprite
- break
- --[[--干掉for循环
- if hitCount == 3 then
- break
- end--]]
- end
- end
-
- --处理多层点击穿透:如果是3个,取第三个,如果是2个,取第二个,如果是一个,取第一个
- local curItem = hitItem[#hitItem]
- if curItem then
- logE("cancel hitCount :"..hitCount)
- if curItem.value == nil then
- logE("88888888-=============curItem.value == nil 1================")
- logE("88888888-=============执行牌插入,插入位置为空的================")
- --牌插入逻辑:
- --数组数据更新
- local curLieShu = hitItem[#hitItem].lieshu
- local curHangShu = hitItem[#hitItem].hangshu
- local value = hitItem[#hitItem].value
-
- logE("88888888-self.handCardValueLocal[v.lieshu]:"..table.tostring(self.handCardValueLocal[v.lieshu]))
- logE("88888888-self.handCardValueLocal[curLieShu]:"..table.tostring(self.handCardValueLocal[curLieShu]))
-
- --行数
- local row = v.hangshu
- local lieshu = v.lieshu
-
- logE("88888888-touch row :"..row)
- logE("88888888-touch lieshu :"..lieshu)
- --原来的数据删除
- --if self.handCardRoot[lieshu].imgList[row].value == v.value then
- table.remove(self.handCardValueLocal[lieshu],row)
- --end
-
- --在新的数据列里插入新的值
- for i = 1,self.hangShuMax do
- if self.handCardRoot[curLieShu].imgList[i].value == nil then
- table.insert(self.handCardValueLocal[curLieShu],v.value)
- break
- end
- end
-
- --数据交换
- local tempValue = nil
- tempValue = v.value
- v.value = hitItem[#hitItem].value
- hitItem[#hitItem].value = tempValue
-
- --ui更新
- self.ui.Items.ImageView_handTempCard:setVisible(true)
- v:setVisible(false)
- local function callback()
- self.ui.Items.ImageView_handTempCard:setVisible(false)
- local cardvalue = hitItem[#hitItem].value or tempValue
- if cardvalue then
- local fileName = ZPFuc.getZPCardImgByValue(cardvalue,ZPDef.CardType.CARD_TYPE_HAND,self.colorType)
- hitItem[#hitItem]:loadTextureFromPlist(fileName)
- hitItem[#hitItem]:setVisible(true)
- hitItem[#hitItem]:setOpacity(255)
- end
-
- --听牌标签
- if v:getChildren()[1]:isVisible() then
- v:getChildren()[1]:setVisible(false)
- hitItem[#hitItem]:getChildren()[1]:setVisible(true)
- end
- self.ui.Items.ImageView_handTempCard.lieshu = curLieShu
- self.ui.Items.ImageView_handTempCard.hangshu = curHangShu
- self:neatenCard()
- end
-
- --handTemp->tarPos action
- if self.handCardRoot[curLieShu].imgList[curHangShu - 1] and
- self.handCardRoot[curLieShu].imgList[curHangShu - 1].value then
- local node = hitItem[#hitItem]
- local nodeSize = node:getParent():getContentSize()
- local nodePos = cc.pAdd(node:getWorldPosition(),cc.p(nodeSize.width/2,nodeSize.height/2))
- local seq = cc.Sequence:create(cc.MoveTo:create(0,nodePos),cc.CallFunc:create(callback))--self.gameSpeedConfig.OPCARDTIME
- self.ui.Items.ImageView_handTempCard:runAction(seq)
- else
- callback()
- end
- logE("88888888-=============curItem.value == nil 2================")
- logE("88888888-=============执行牌插入结束================")
-
- else
- logE("88888888-=============cancel curItem.value exist 1================")
-
- --数组数据更新
- local curLieShu = hitItem[#hitItem].lieshu
- local curHangShu = hitItem[#hitItem].hangshu
- local value = hitItem[#hitItem].value
- local isKan = hitItem[#hitItem].isKan
- if isKan then
- --showTooltip("坎牌不可拆")
- return
- end
-
- --如果小于3则插入到空的那个
- if self:getRowVisibleCount(curLieShu) < 5 then
- logE("88888888-=============如果小于5则插入到空的那个================")
- logE("88888888-=============执行牌插入到空的位置================")
- --同列有多个牌相同的,找出对应点击的牌
- local row = v.hangshu
- local lieshu = v.lieshu
- logE("88888888-row :"..row)
- logE("88888888-lieshu :"..lieshu)
- --原来的数据删除
- table.remove(self.handCardValueLocal[lieshu],row)
- --在新的数据列里插入新的值
- local newRow = 0
- for i = 1,self.hangShuMax do
- if self.handCardRoot[curLieShu].imgList[i].value == nil then
- newRow = i
- table.insert(self.handCardValueLocal[curLieShu],v.value)
- break
- end
- end
-
- --数据交换
- local tempValue = nil
- tempValue = v.value
- v.value = nil
- self.handCardRoot[curLieShu].imgList[newRow].value = tempValue
- logE("888888888-curLieShu:"..tostring(curLieShu))
- logE("888888888-newRow:"..tostring(newRow))
- --ui更新
- v:setVisible(false)
- local fileName = ZPFuc.getZPCardImgByValue(self.handCardRoot[curLieShu].imgList[newRow].value,ZPDef.CardType.CARD_TYPE_HAND,self.colorType)
- self.handCardRoot[curLieShu].imgList[newRow]:loadTextureFromPlist(fileName)
- self.handCardRoot[curLieShu].imgList[newRow]:setVisible(true)
- self.handCardRoot[curLieShu].imgList[newRow]:setOpacity(255)
-
- --听牌标签
- if v:getChildren()[1]:isVisible() then
- v:getChildren()[1]:setVisible(false)
- self.handCardRoot[curLieShu].imgList[newRow]:getChildren()[1]:setVisible(true)
- end
-
- logE("88888888-======================after insert card=========================")
- logE("88888888-first item lieshu:"..v.lieshu)
- logE("88888888-first item value:"..0)
- self:neatenCard()
- logE("88888888-=============如果小于5则插入到空的那个 结束================")
- logE("88888888-=============执行牌插入到空的位置 结束================")
- else
- logE("88888888-=============该列满5个牌只能交换================")
- logE("88888888-=============执行牌交换================")
- if value > 0 then
- logE("被交换的牌为"..value)
- end
-
- --牌交换:
- --同列有多个牌相同的,找出对应点击的牌
- local rowFirst = v.hangshu
- local rowSecond = curHangShu
-
- logE("88888888-rowFirst 第一个交换的行数:"..rowFirst)
- logE("88888888-rowSecond 第二个交换的行数:"..rowSecond)
-
- logE("88888888-原始列数数据:"..table.tostring(self.handCardValueLocal[v.lieshu]))
- logE("88888888-交换列数数据:"..table.tostring(self.handCardValueLocal[curLieShu]))
-
- --原来的数据删除
- if self.handCardRoot[v.lieshu].imgList[rowFirst].value == v.value then
- table.remove(self.handCardValueLocal[v.lieshu],rowFirst)
- table.insert(self.handCardValueLocal[v.lieshu],rowFirst,value)
- end
-
- --原来的数据删除
- if self.handCardRoot[curLieShu].imgList[rowSecond].value == value then
- table.remove(self.handCardValueLocal[curLieShu],rowSecond)
- table.insert(self.handCardValueLocal[curLieShu],rowSecond,v.value)
- end
-
- logE("88888888-删除后的原始列数数据:"..table.tostring(self.handCardValueLocal[v.lieshu]))
- logE("88888888-删除后的列数数据:"..table.tostring(self.handCardValueLocal[curLieShu]))
-
- logE("查看数据:")
- logE("88888888-first item lieshu:"..v.lieshu)
- logE("88888888-first item value:"..v.value)
- logE("88888888-second item lieshu:"..curItem.lieshu)
- logE("88888888-second item value:"..curItem.value)
- logE("查看数据完毕")
- --数据交换
- local tempValue = nil
- tempValue = v.value
- v.value = hitItem[#hitItem].value
- hitItem[#hitItem].value = tempValue
-
- --ui交换
- local fileName = ZPFuc.getZPCardImgByValue(v.value,ZPDef.CardType.CARD_TYPE_HAND,self.colorType)
- v:loadTextureFromPlist(fileName)
- fileName = ZPFuc.getZPCardImgByValue(hitItem[#hitItem].value,ZPDef.CardType.CARD_TYPE_HAND,self.colorType)
- hitItem[#hitItem]:loadTextureFromPlist(fileName)
-
- local srcVisible = v:getChildren()[1]:isVisible()
- local changeVisible = hitItem[#hitItem]:getChildren()[1]:isVisible()
-
- --听牌标签
- hitItem[#hitItem]:getChildren()[1]:setVisible(srcVisible)
- v:getChildren()[1]:setVisible(changeVisible)
-
- logE("交换完毕,查看数据:")
- logE("88888888-first item lieshu:"..v.lieshu)
- logE("88888888-first item value:"..v.value)
- logE("88888888-second item lieshu:"..hitItem[#hitItem].lieshu)
- logE("88888888-second item value:"..hitItem[#hitItem].value)
- logE("查看数据完毕")
- logE("88888888-=============牌交换 结束================")
- logE("88888888=============cancel curItem.value exist 2================")
- end
- end
- else
- --@part:牌取消回来,出牌逻辑的实现
- --判断是否大于出牌点
- if touchPos.y > self.ui.Items.ImageView_line:getPosition().y and self.bOutCard then
- if app.room:isLittleFamily() then
- return
- end
- --比牌的时候,在比牌间隔点到了牌,拖出去报错
- if v.value == nil then
- showTooltip("牌已经操作过!")
- return
- end
-
- --send sender
- v:setOpacity(0)
- self:sendOutCard(v.value)
- logE("玩家出牌:"..v.value)
- self.bOutCard = false
- self.isGodHand = true;
- --记录数据
- local lieshu = v.lieshu
- local hangshu = v.hangshu
- local value = v.value
-
- self.ui.Items.ImageView_handTempCard.lieshu = lieshu
- self.ui.Items.ImageView_handTempCard.hangshu = hangshu
- self.ui.Items.ImageView_handTempCard.value = value
- self.ui.Items.ImageView_handTempCard.index = k
-
- else
- logE("牌回到原来的位置")
- --回到原点动画
- self:goBackWithAni(v,0.15)
- end
- end
-
- -------------------------------------------------------
- -------------------------------------------------------
- logE("88888888=============onTouchCancel 2================")
- logE("88888888-onTouchCancel :card :"..table.tostring(self.handCardValueLocal))
-
- end
- v:setTouchEnabled(true)
- v:registerTouchEvent(onTouchBegan, onTouchMove, onTouchEnd, onTouchCancel)
- end
- end
-
-
- --隐藏剩余牌层
- function changpaiRoomView:setCircleCardLeftPanelView(bVisible,viewId,leftNum)
- self.leftNum = leftNum
- self:setFaPaiQiPanelView(bVisible,viewId,leftNum)
- if viewId and not self.isRecordStart and not self.isQiShou then
- self.PlayerView:setPClockVisible(viewId,true)
- end
- end
-
-
-
- --胡牌特效
- function changpaiRoomView:playHuEffect(viewId,onEnd,isRecontect)
- --[[ --黄庄了直接return
- if app.room.roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_HUANG_ZHUANG then
- return
- end--]]
- logE("changpaiRoomView 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 changpaiRoomView:showPaoImage()
- if app.room.roomInfo.dianPaoUserId and app.room.roomInfo.dianPaoUserId >= 0 then
- local dianPaoViewId = app.room:getViewIdByUserId(app.room.roomInfo.dianPaoUserId)
- --点炮精灵
- local mSprite = cc.ImageView:createNode()
- mSprite:loadTextureFromPlist("zp_room_chapai_dianpao.png")
- --if dianPaoViewId == 2 then
- --mSprite:setEulerRotation(cc.vec3(0, 0, -90))
- --end
-
- local name = string.format("Layout_outCardPoint_%d",dianPaoViewId)
- local mLayout = self.ui.Items[name]
-
- local pos = mLayout:getPosition()
-
- if dianPaoViewId == self:getMeViewId() then
- local centerPos = cc.Director:getInstance():getVisibleSize()
- local pos = cc.p(centerPos.width/2,centerPos.height/2 - 70)
- mSprite:setPosition(pos)
- elseif dianPaoViewId == 1 then
- mSprite:setPosition(cc.pAdd(pos,cc.p(90,-30)))
- elseif dianPaoViewId == 2 then
- mSprite:setPosition(cc.pAdd(pos,cc.p(0,20)))
- elseif dianPaoViewId == 3 then
- mSprite:setPosition(cc.pAdd(pos,cc.p(-70,-30)))
- end
-
- self.ui.Items.Layout_Player_HuEffect:addChild(mSprite,2)
-
- local pPos = cc.p(0,0)
- for k,v in pairs(self.playerPos) do
- if k == dianPaoViewId then
- --pPos = v.headPos
- if dianPaoViewId == 2 then
- pPos.y = v.headPos.y + 5
- pPos.x = v.headPos.x - 5
- elseif dianPaoViewId == 1 then
- pPos.y = v.headPos.y + 5
- pPos.x = v.headPos.x
- elseif dianPaoViewId == 3 then
- pPos.y = v.headPos.y + 5
- pPos.x = v.headPos.x + 5
- elseif dianPaoViewId == 4 then
- pPos.y = v.headPos.y + 5
- pPos.x = v.headPos.x + 5
- end
- end
- end
-
- local mSpawn = cc.Spawn:create(cc.MoveTo:create(0.5,pPos),cc.ScaleTo:create(0.3,0.5))
-
- mSprite:runAction(cc.Sequence:create(cc.DelayTime:create(0.5),mSpawn))
- end
- end
-
-
- -- 大局结算
- function changpaiRoomView: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 app.room.roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_LONG_NOT_END then
- view:playAni()
- self:showGameOverAward()
- else
- if not app.room.roomInfo.nShowDismiss then
- log("2000000000-onGameDaJuResponse --------- zhengchangjiesu ")
- view:setVisible(false);
- else
- log("2000000000-onGameDaJuResponse --------- yichangjiesu ")
- --结算直接播放动画
- view:playAni()
- self:showGameOverAward()
- end
- end
-
-
-
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-ZPRoomView - addCallBack(runGameDaJuResponse)")
- self:addCallBack(runGameDaJuResponse);
- end
-
-
-
- --从手牌找与牌值相等的牌,没有再找加起来可以成14的,没有再找点数相同的
- function changpaiRoomView:findCardPos(card)
- local secondDstCard
-
- logE("changpaiRoomView - findCardPos",card)
-
- secondDstCard = 14 - tempCardVlue[tonumber(card)]
-
- local threeDstCard = tempCardVlue[tonumber(card)]
- --第一目标
- local dstCol1,dstRow1
- --第二目标
- local dstCol2,dstRow2
- --第三目标
- local dstCol3,dstRow3
- --第四目标
- local dstCol4,dstRow4
- --第一次找到值时,赋值一次,
- local firstSet = true
- local isEnd = false
- for col = self.lieShuMax, 1, -1 do
- for row = 5, 1, -1 do
- --if self.handCardRoot[col].imgList[row].value == card then
- --牌值相同的
- if self.handCardValueLocal[col][row] == card and #self.handCardValueLocal[col] < 5 then
- dstCol1 = col
- dstRow1 = #self.handCardValueLocal[col]+1
- isEnd = true
- break
- end
- --if self.handCardRoot[col].imgList[row].value == secondDstCard then
- --点数加起来等于十四的
- local tempCard = tempCardVlue[tonumber(self.handCardValueLocal[col][row])]
- if tempCard == secondDstCard and #self.handCardValueLocal[col] < 5 then
- dstCol2 = col
- dstRow2 = #self.handCardValueLocal[col]+1
- end
-
- --点数一样的
- if tempCard == threeDstCard and #self.handCardValueLocal[col] < 5 then
- dstCol3 = col
- dstRow3 = #self.handCardValueLocal[col]+1
- end
-
-
- if firstSet and self.handCardValueLocal[col][row] then
- if col == self.lieShuMax then
- --最多只存在8列 最多只有16张牌 只要判断到第六列就可以了
- local secondLieshu = self.lieShuMax - 1
- local thirdLieshu = self.lieShuMax - 2
- if #self.handCardValueLocal[col] < self.hangShuMax then
- firstSet = false
- dstCol4 = col
- dstRow4 = #self.handCardValueLocal[col]+1
- elseif #self.handCardValueLocal[secondLieshu] < self.hangShuMax then
- firstSet = false
- dstCol4 = secondLieshu
- dstRow4 = #self.handCardValueLocal[col]+1
- elseif #self.handCardValueLocal[thirdLieshu] < self.hangShuMax then
- firstSet = false
- dstCol4 = thirdLieshu
- dstRow4 = #self.handCardValueLocal[col]+1
- end
- else
- firstSet = false
- dstCol4 = col + 1
- dstRow4 = 1
- end
-
- end
-
- --[[
- if firstSet and self.handCardValueLocal[col][row] then
- firstSet = false
- dstCol4 = col + 1
- dstRow4 = 1
- end
- ]]
-
-
- end
- if isEnd then
- break
- end
- end
- if dstCol1 then
- return dstCol1,dstRow1
- end
- if dstCol2 then
- return dstCol2,dstRow2
- end
- if dstCol3 then
- return dstCol3,dstRow3
- end
-
- if dstCol4 then
- return dstCol4,dstRow4
- end
-
- if firstSet then --手里面没有列数了
- return 5,1
- end
- end
-
- --获取该列显示了几个
- function changpaiRoomView:getRowVisibleCount(lieshu)
- local count = 0
- for k = 1, 5 do
- if self.handCardRoot[lieshu].imgList[k] and self.handCardRoot[lieshu].imgList[k]:isVisible() then
- count = count + 1
- end
- end
- return count
- end
-
- --显示提牌按钮
- function changpaiRoomView:showTiPaiBtn(vis)
- vis = vis or false
- self.ui.Items.Button_tipai:setVisible(vis)
- end
-
-
- --牌UI调整
- function changpaiRoomView:RankCard(isNotShowAni)
- --如果列小于最大列数则需要调整UI
- local showColNum = self:getVisibleCardLayoutNum()
- if showColNum == 0 then
- self:getLocalHuShu()
- return
- end
-
- local tempLieshu = self.lieShuMax + 1
- if showColNum <= tempLieshu then
- --根据当前存在的列数获取一个枚举列表,让手牌的列数重新旋转到指定新的列数
- local list = self.lieshulist[showColNum]
- local blankList = self.lieshuBlanklist[showColNum]
-
- local youIndex = 0
- local wuIndex = 0
- --card data
- local handCardValueLocalTemp = {}
- local handCardRootTemp = {}
-
- for k = 1,tempLieshu do
- if #self.handCardValueLocal[k] <= 0 then
- wuIndex = wuIndex + 1
- local blankIndex = blankList[wuIndex] -- 1 2 9 10
- local tarPos = self.boxPosList4[blankIndex]
- if isNotShowAni then
- self.handCardRoot[k].ui:setPosition(tarPos)
- else
- self.handCardRoot[k].ui:stopAllActions()
- self.handCardRoot[k].ui:runAction(cc.MoveTo:create(self.gameSpeedConfig.OPCARDTIME,tarPos))
- end
-
- --列数修改
- for i = 1,self.hangShuMax do
- self.handCardRoot[k].imgList[i].lieshu = blankIndex
- end
-
- self.handCardRoot[k].ui:setLocalZOrder(blankIndex)
-
- handCardValueLocalTemp[blankIndex] = self.handCardValueLocal[k]
- handCardRootTemp[blankIndex] = self.handCardRoot[k]
- else
- youIndex = youIndex + 1
- local index = list[youIndex] -- 3 4 5 6 7 8
- local tarPos = self.boxPosList4[index]
- if isNotShowAni then
- self.handCardRoot[k].ui:setPosition(tarPos)
- else
- self.handCardRoot[k].ui:stopAllActions()
- self.handCardRoot[k].ui:runAction(cc.MoveTo:create(self.gameSpeedConfig.OPCARDTIME,tarPos))
- end
- --列数修改
- for i = 1,self.hangShuMax do
- self.handCardRoot[k].imgList[i].lieshu = index
- end
-
- --self.handCardRoot[k].ui:setLocalZOrder(index)
-
- handCardValueLocalTemp[index] = self.handCardValueLocal[k]
- handCardRootTemp[index] = self.handCardRoot[k]
-
- end
- end
-
- --牌数据
- self.handCardValueLocal = handCardValueLocalTemp
- handCardValueLocalTemp = {}
- --牌
- self.handCardRoot = handCardRootTemp
- handCardRootTemp = {}
- --logE("RankCard 排序后: "..table.tostring(self.handCardValueLocal))
- end
- self:getLocalHuShu()
- end
-
-
- --备份的手牌数据,只对此数据使用的接口
- function changpaiRoomView:rankDeletOneBakCard(card)
- local isEnd = false
- --倒叙遍历1-10列
- local tempLieshu = self.lieShuMax + 1
- for col = tempLieshu,1,-1 do --列数
- for row = self.hangShuMax,1,-1 do --行数
- if self.handCardValueBak[col] and self.handCardValueBak[col][row] and card == self.handCardValueBak[col][row] then --判断值是否相等
- logE("delete bakcard ============= :"..card)
- table.remove(self.handCardValueBak[col],row)
-
- isEnd = true
- break
- end
- end
- if isEnd then
- break
- end
- end
- end
-
- --隐藏出牌按钮
- function changpaiRoomView:setGuideView(bVisible)
- if app.room:isLittleFamily() then
- bVisible = false
- end
- self.ui.Items.Layout_tips:setVisible(bVisible)
- --self.ui.Items.Button_OutCard:setVisible(bVisible)
- self.ui.Items.Button_OutCard:setVisible(false)
- self.ui.Items.Button_OutCard:setEnabled(false)
- if bVisible then
- self.ui.Items.ImageView_3:playClip("tip")
- end
- end
- ---
- -- 托管通知
- -- @param data
- -- @return
- --
- function changpaiRoomView: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 changpaiRoomView:onOperationError(data)
- local function runOnOperationError(onEnd)
- log("2000000000-ZPRoomView - (runOnOperationError)")
- --恢复操作面板
- --self.operationView:touchEatOneCardCallBack()
- self.ui:sendMsg(app.room,ZPDef.ZPEvent.GetTableInfo)
-
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-ZPRoomView - addCallBack(runOnOperationError)")
-
- self:addCallBack(runOnOperationError)
- end
-
- return changpaiRoomView
|