|
- -- xx : 2018 3 27
- -- 跑得快主界面
- local PdkDef = require("luaScript.SubGameDefine.Poker.luzhouPdkWanFa")
- local PdkFunctions = require("pk_luzhoupdk.luaScript.luzhouPdkFunctions")
- local PdkPlayerNode = require("pk_luzhoupdk.luaScript.Views.Room.Node.luzhouPdkPlayerNode")
- local PdkCardNode = require("pk_luzhoupdk.luaScript.Views.Room.Node.luzhouPdkCardNode")
- local luzhouPdkRoomViewConfig = require("pk_luzhoupdk.luaScript.Views.Room.luzhouPdkRoomViewConfig")
- local PdkEffectHelper = require("pk_luzhoupdk.luaScript.Views.Room.luzhouPdkEffectHelper"):new()
- local ETS = luzhouPdkRoomViewConfig.EffectType
- local PdkSoundHelper = require("pk_luzhoupdk.luaScript.Views.Room.luzhouPdkSoundHelper"):new()
- local RoomGpsComponent = require("luaScript.Views.Room.RoomGpsComponent")
- require("luaScript.Views.Room.RoomFunctions")
- local PdkMessage = require("pk_luzhoupdk.luaScript.Protocol.luzhouPdkMessage")
- local CENTER_X=640*g_radio_x
- local CENTER_Y=360*g_radio_y
-
- local luzhouPdkRoomView = class("luzhouPdkRoomView", cc.UIView)
- function luzhouPdkRoomView:ctor(params)
- luzhouPdkRoomView.super.ctor(self)
- -- 玩家节点
- self._playerNodes = {}
- -- 自己手牌集合
- self._selfCards = {}
- -- 玩家出牌集合
- self._showCards = {{},{},{},{}}
- -- 点击选择的牌
- self._selectCards = {}
- -- 上一次出牌viewPos
- self._lastOutPos = 0
- -- 上一次出牌类型
- self._lastOutType = 0
- -- 上一次出牌类型,只记录服务器下发的类型
- app.room.lastOutType = 0
- -- 上一次出牌,用于提示
- self._lastCards = {}
- -- 排序轮次用
- self._turnsQueue = {}
- -- 快速开始界面
- self.fastStartRequestView = nil
-
- self.ui = loadUI("pk_luzhoupdk/res/ui/ui_room/ui_lzpdk_gameview.ui")
- self:addChild(self.ui)
- self.panelMenu = self.ui.Items.Layout_Menu
- self.cardRoot = self.ui.Items.cardRoot
- self.imgOtherCards = self.ui.Items.ImageView_other
- self.txtOtherCards = self.ui.Items.Text_otherNum
-
- self:showOtherCards(false)
-
- loadSpriteFrameFile("pk_luzhoupdk/res/ui/zy_game/lzroom_add.plist")
- self:initChatView()
- self:initUi()
-
- self:showMenu(false)
- self:showTurnBtn(false)
- self:setRoomInfo(app.room:getRoomInfo())
-
- loadSpriteFrameFile("pk_luzhoupdk/res/ui/zy_game/zy_lzpdk_cards.plist")
- loadSpriteFrameFile("pk_luzhoupdk/res/ui/zy_effect/lzpdk_effect.plist")
- loadSpriteFrameFile("pk_luzhoupdk/res/ui/zy_effect/lzpdk_effect_bomb.plist")
- loadSpriteFrameFile("pk_luzhoupdk/res/ui/zy_effect/lzpdk_effect_shunziliandui.plist")
- loadSpriteFrameFile("pk_luzhoupdk/res/ui/zy_effect/lzpdk_effect_plan.plist")
-
- --
- local gameInfo = app.room:getRoomInfo().nGameInfo
- local data = json.decode(gameInfo)
- local rule = tonumber(data.specialRule)
- -- 是否选择三不带全
- self.ruleIsNotEnough = true--getNumBand(rule, 0x0008)>0
- -- 炸弹可拆
- self.ruleIsChaiBomb = getNumBand(rule, 0x0004)>0
- -- 是否选择4带3
- self.ruleIsFAT = getNumBand(rule, 0x0002)>0
- -- 玩法模式 经典 15张
- self.ruleType = tonumber(data.gamerule)
- -- 是否选择扎鸟
- self.ruleZhaniao = getNumBand(rule, 0x0001)>0
- --
- self.functionQueue = require("luaScript.Tools.FunctionQueue"):new()
- end
-
- --[[
- GAME_STATE_INIT =0, --//游戏准备状态
- GAME_STATE_SEND_HAND_CARD =1, --//发牌
- GAME_STATE_OUT_CARD =2, --//打牌
- GAME_STATE_ROUND_OVER =3, --//游戏一局结束
- GAME_STATE_GAME_OVER =4, --//游戏结束
- ]]
- function luzhouPdkRoomView:onEnter()
- luzhouPdkRoomView.super.onEnter()
- local roomInfo = app.room:getRoomInfo()
- if roomInfo.nGameStartCount > 0 then
- setShowCountAll(true)
- end
- PokerUtil = require("pk_luzhoupdk.luaScript.Views.Room.luzhouPokerUtil"):new({isChai=self.ruleIsChaiBomb, isFAT=self.ruleIsFAT})
- self:bindEvents()
- self:addTouchesListener()
- local roomInfo = app.room:getRoomInfo()
- if roomInfo.recoverItem then
- local recoverData = roomInfo.recoverItem
- self:recover(recoverData)
- else
- --self:checkGpsDistance(nil,roomInfo.nGameStartCount==0)
- end
- -- GPS组件
- self:initGpsComponent()
- local changeDesk = tonumber(loadUserInfo("lzpdk_setting_bg_idx")) or 2
- self:onNormalChangeDesktop({idx=changeDesk})
- local cacheMusic = "gameBgMusic"..app.gameId
- local defaultMusic = tonumber(loadUserInfo(cacheMusic)) or 2
- PdkSoundHelper:playBgMusic(defaultMusic)
-
- --定时器
- local roomInfo = app.room:getRoomInfo()
- if self.ui.Items.systemTime then
- self.ui.Items.systemTime:setText(string.format("%s", os.date("%y-%m-%d %H:%M:%S", os.time()) ) )
- end
- if not self.Time then
- self.Time = cc.Director:getInstance():getScheduler():scheduleScriptFunc(function()
- local roomInfo = app.room:getRoomInfo()
- self.ui.Items.systemTime:setText(string.format("%s", os.date("%y-%m-%d %H:%M:%S", os.time()) ) )
- end,1.0,false)
- end
-
- if app.room.isReconnection == true then
- --断线重连
- self:isShowFastStartView()
- end
- self:doSound()
-
- self:initPlayGameAgain()
-
- self:checkCanDismiss()
-
- if self.chatView and PdkFunctions.isForbidProp() then
- self.chatView:hideFace()
- end
- if self.chatView and PdkFunctions.isForbidVoice() then
- self.chatView:hideVoice()
- end
- end
-
- function luzhouPdkRoomView:doSound()--1 普通话 2 方言
- local cacheLan = "LanguageType"..GAME_IDS.luzhouPaoDeKuai
- local languageType = tonumber(loadUserInfo(cacheLan)) or 1
- saveUserInfo(cacheLan,languageType)
- end
-
- function luzhouPdkRoomView:onExit()
- self.fastStartRequestView = nil
- setShowCountAll(false)
- if self.Time then
- cc.Director:getInstance():getScheduler():unscheduleScriptEntry(self.Time)
- self.Time = nil
- end
-
- for _,node in pairs(self._playerNodes) do
- if node then node:setTurn(false) end
- end
-
- PokerUtil = nil
- app.room:cleanCache()
- stopBGMusic()
- self:cleanCache()
- end
-
- function luzhouPdkRoomView:cleanCache()
- local preload = package.loaded
- for k, v in pairs(package.loaded or {}) do
- local res1 = string.find( k, "pk.luaScript") or 0
- local res2 = string.find( k, "pk_luzhoupdk.luaScript") or 0
- if res1 > 0 or res2 > 0 then
- package.loaded[k] = nil
- end
- end
- end
-
- function luzhouPdkRoomView:addFunction( func )
- if self.functionQueue then
- self.functionQueue:addFunction(func)
- else
- func()
- end
- end
-
- function luzhouPdkRoomView:initChatView()
- local children = self.panelMenu:getParent():getChildByTag(99)
- if children then
- children:removeFromParent()
- end
-
- local messageList = PdkDef.ChatMessages
- local headInfos = {}
- if app.room:getRoomInfo().nMaxPlayCount == 2 then
- headInfos[1] = {headPos = cc.p((62+25)*g_radio_x, (111+20)*g_radio_y), voiceDir = 2}
- headInfos[2] = {headPos = cc.p((1224-25)*g_radio_x, (560+20)*g_radio_y), voiceDir = 1}
- elseif app.room:getRoomInfo().nMaxPlayCount == 3 then
- headInfos[1] = {headPos = cc.p((62+25)*g_radio_x, (111+20)*g_radio_y), voiceDir = 2}
- headInfos[2] = {headPos = cc.p((1224-25)*g_radio_x, (505+40)*g_radio_y), voiceDir = 1}
- headInfos[3] = {headPos = cc.p((62+25)*g_radio_x, (505+40)*g_radio_y), voiceDir = 2}
- elseif app.room:getRoomInfo().nMaxPlayCount == 4 then
- headInfos[1] = {headPos = cc.p((62+25)*g_radio_x, (111+20)*g_radio_y), voiceDir = 2}
- headInfos[2] = {headPos = cc.p((1224-25)*g_radio_x, (450+20)*g_radio_y), voiceDir = 1}
- headInfos[3] = {headPos = cc.p(940*g_radio_x, (590+20)*g_radio_y), voiceDir = 2}
- headInfos[4] = {headPos = cc.p((62+25)*g_radio_x, (450+20)*g_radio_y), voiceDir = 2}
- end
- local showBtn = true;
- self.chatView = import("luaScript.Views.Room.ChatView"):new(messageList, headInfos, showBtn)
- --self.chatView:setLanguage(false)
- self.chatView:setLocalZOrder(99)
- self.chatView:setTag(99)
- self.chatView:setBtnFace(cc.p(0.9411563, 0.3730273),"room_menu3_room_btn_kjy.png")
- self.chatView:setBtnVoice(cc.p(0.9411563, 0.2163281),"room_menu3_room_btn_yuyin.png")
-
- self.panelMenu:getParent():addChild(self.chatView)
-
- if PdkFunctions.isForbidProp() then
- -- self.chatView:hideBtns()
- -- self.chatView:setPropEnabled(false)
- -- self.chatView:setVoiceEnabled(false)
-
- self.chatView:hideFace()
- self.chatView:setPropEnabled(false)
- end
- -- todo
- if PdkFunctions.isForbidVoice() then
- self.chatView:hideVoice()
- self.chatView:setVoiceEnabled(false)
- end
- end
-
- function luzhouPdkRoomView:resetRoundData( )
- -- 上一次出牌viewPos
- self._lastOutPos = 0
- -- 上一次出牌类型
- self._lastOutType = 0
- self._lastCards = {}
- self.lastOutFlag = -1
- --
- self:showTurnBtn(false)
- self:cleanSelfCards()
- self:cleanShowCards()
-
- self:showOtherCards(false)
- -- 清空玩家时钟
- for _,v in pairs(self._playerNodes) do
- v:setTurn(false)
- end
- self._resultMsg = nil
- self:showRstComfirm(false)
- if self.xiaojuView and (not tolua.isnull(self.xiaojuView)) then
- self.xiaojuView:removeFromParent()
- self.xiaojuView = nil
- end
- end
-
- function luzhouPdkRoomView:getMode()
- return app.room:getRoomInfo().nMaxPlayCount or 4
- --[[if app.room:getRoomInfo().nMaxPlayCount == 2 then
- return 0
- elseif app.room:getRoomInfo().nMaxPlayCount == 3 then
- return 1
- end
- return 1--]]
- end
-
- function luzhouPdkRoomView:initUi()
- self.ui.Items.btnMenu:registerClick(handler(self , self.onClickButtonMenu))
- self.ui.Items.Button_Leave:registerClick(handler(self , self.onClickButtonLeave))
- self.ui.Items.Button_Dismiss:registerClick(handler(self , self.onClickButtonDismiss))
- self.ui.Items.Button_Set:registerClick(handler(self , self.onClickButtonSetting))
- -- self.ui.Items.Button_updateLog:registerClick(handler(self , self.onClickButtonUlog))
- self.ui.Items.Button_Ready:registerClick(handler(self , self.onClickButtonReady))
- self.ui.Items.Button_Ready.oPos = self.ui.Items.Button_Ready:getPosition()
- self.ui.Items.Button_invite:registerClick(handler(self , self.onClickButtonInvite))
- self.ui.Items.Button_invite.oPos = self.ui.Items.Button_invite:getPosition()
- self.ui.Items.Layout_7:registerClick(handler(self , self.onClickMenuOut))
- self.ui.Items.Button_rule:registerClick(handler(self, self.onClickButtonDetails))
- self.ui.Items.Button_Copy:registerClick(handler(self, self.onClickCopy))
-
- -- self.ui.Items.btnDetail:registerClick(handler(self , self.onClickButtonDetails))
-
- self.ui.Items.Button_tip:registerClick(handler(self , self.onClickButtonTip))
- self.ui.Items.Button_out:registerClick(handler(self , self.onClickButtonOut))
- self.ui.Items.Button_not_out:registerClick(handler(self , self.onClickButtonNotOut))
-
- --邀请俱乐部成员
- self.ui.Items.Button_Invite_Club:registerClick(handler(self , self.onClickInviteClub))
-
- -- self.ui.Items.btnShot:registerClick(handler(self , self.onClickButtonShot))
- -- 小局结算展示按钮
- self._btnComfirm = self.ui.Items.Button_RstComfirm
- self._btnComfirm:registerClick(handler(self , self.onClickButtonRstComfirm))
- self:showRstComfirm(false)
-
- self.ui.Items.imgTip:setVisible(false)
- self.ui.Items.imgTip:setOpacity(0)
- self.ui.Items.imgTip:setLocalZOrder(200)
-
- self.ui.Items.btnShowClub:registerClick(handler(self , self.onClickButtonShowClub))
- if app.club_php.clubID and app.club_php.clubID~=0 then
- self.ui.Items.btnShowClub:setVisible(true)
- self.ui.Items.Button_Invite_Club:setVisible(true)
- else
- self.ui.Items.btnShowClub:setVisible(false)
- self.ui.Items.Button_Invite_Club:setVisible(false)
- end
-
- local roomInfo = app.room.roomInfo or {}
- local gameId = roomInfo.gameId or app.gameId
- local gameConfig = getSubGameConfig(gameId)
- if gameConfig.isOpenClubInvite == false then
- self.ui.Items.Button_Invite_Club:getParent():setVisible(false)
- end
-
- local roomInfo = app.room:getRoomInfo()
-
- --快速开始按钮
- self.ui.Items.Button_fastStart:registerClick(handler(self, self.onClickFastStart))
- if roomInfo.nGameStartCount and roomInfo.nGameStartCount <= 0 then
- --游戏未开始
- self:showFastStart(true)
- self:showJiPaiQi(false)
- else
- self:showFastStart(false)
- --self:showJiPaiQi(true)
- end
-
- --添加玩家节点
- local players = app.room:getPlayers()
- for _, info in pairs(players) do
- self:addPlayerNode( info )
- end
- --
- local myself = app.room:getMyself()
- if myself and myself.playFlag>=1 then
- self:showSitdownBtn(false)
- else
- self:showSitdownBtn(true)
- end
- -- 水印
- local gameInfo = roomInfo.nGameInfo
- local data = json.decode(gameInfo)
- --[[local logostr = ""
- if tonumber(data.gamerule) == PdkDef.GameTypes.Normal then
- logostr = "pdk_img_logo_jingdian.png"
- else
- logostr = "pdk_img_logo_swz.png"
- end
- self.ui.Items.ImageView_logo:loadTexture(logostr, 1)--]]
- if not isReviewVersion() and self.gpsComponent then
- --self.gpsComponent:updateUserInfos(app.room:getUserInfoList())
- end
- self.ui.Items.Button_invite:setVisible(app.room:getPlayerNum() ~= roomInfo.nMaxPlayCount)
- self:updateButtonPosition()
- --
- if not self.LeavePos then
- self.LeavePos = self.ui.Items.Button_Leave:getPosition()
- self.DisbandPos = self.ui.Items.Button_Dismiss:getPosition()
- self.SettingPos = self.ui.Items.Button_Set:getPosition()
- self.RulePos = self.ui.Items.Button_rule:getPosition()
- end
- -- self:showMenu(false, true)
- self.ui.Items.Layout_Rule:setVisible(false)
- self.ui.Items.Layout_7:setVisible(false)
- self.ui.Items.Text_Rule:setVisible(false)
- --self.ui.Items.btnMenu:setVisible(false)
- self.ui.Items.Layout_Menu_1:setVisible(false)
- self.ui.Items.Layout_Menu_1:setLocalZOrder(199)
- if roomInfo.nGameStartCount > 0 then
- self.ui.Items.Layout_Rule:setVisible(false)
- else
- self.ui.Items.Layout_Rule:setVisible(true)
- self.ui.Items.Button_rule:setVisible(false)
- self.ui.Items.Layout_7:setVisible(true)
- 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_rule:setVisible(true)
- end)))
- end
-
- local bar = self.ui.Items.ListView:getVBar()
- -- bar:setPositionX(220)
- bar:setVisible(false)
-
- if isReviewVersion() then
- self.ui.Items.Button_invite:setVisible(false)
- self.ui.Items.Button_Invite_Club:setVisible(false)
- end
- end
-
- function luzhouPdkRoomView:onClickInviteClub()
- playBtnEffect()
-
- if app.club_php.clubID and app.club_php.clubID ~= 0 then
- local roomInfo = app.room:getRoomInfo()
- local strInvite = luzhouPdkRoomViewConfig.getClubInviteWanFa(roomInfo.gameId or GAME_IDS.luzhouPaoDeKuai, roomInfo)
- view = import("luaScript.Views.Club.ClubInvite"):new(roomInfo.nTableId, strInvite)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
- end
-
- -- 弹出小结算展示按钮
- function luzhouPdkRoomView:showRstComfirm( is )
- self._btnComfirm:setVisible(is==true)
- end
-
- -- 设置房间信息
- function luzhouPdkRoomView:setRoomInfo( info )
- self.ui.Items.roomNum:setString(string.format("房号: %06d", info.nTableId or 0))
- self.ui.Items.Label_JuShu:setString(string.format("%02d/%02d局", info.nGameStartCount or 0, info.nTotalGameNum or 0))
- --设置规则信息
- -- local ruleInfo = json.decode(info.nGameInfo)
- if not self.isHadupdateRule then
- self.isHadupdateRule = true
- else
- return
- end
- self.ui.Items.ListView:removeAllChildren()
- self.ui.Items.ListView:setAutoSize(true)
- local rules = luzhouPdkRoomViewConfig.getWanfaTab(info.nGameInfo or "")
- for k,v in pairs(rules) do
- local text = self.ui.Items.Text_Rule:getCopied()
- text:setVisible(true)
- text:setString(v)
- self.ui.Items.ListView:addChild(text)
- end
-
- end
-
- --[[更新房间局数信息--]]
- function luzhouPdkRoomView:updateRoomInfo(startCount, totalCount)
- local roomInfo = app.room:getRoomInfo()
- roomInfo.nGameStartCount = startCount
- roomInfo.nTotalGameNum = totalCount
- end
-
- -- 显示操作按钮
- function luzhouPdkRoomView:showTurnBtn( is, isShowPass ,opFlag)
- --获取开房参数
- local roomInfo = app.room:getRoomInfo()
- local gameInfo = roomInfo.nGameInfo or ""
- local ruleInfo = json.decode(gameInfo)
- --是否选择了AAA可为炸弹
- local isChoiceAAA = false
- if ruleInfo and ruleInfo.specialRule and getNumBand(ruleInfo.specialRule, 0x0080)>0 then
- isChoiceAAA = true
- end
-
- if (is and (opFlag and opFlag > 0)) then--倒计时 --最后一手牌
- local cards = self:getHandCards()
- local ttp = PokerUtil:checkType(cards)
- --[[if ttp==ETS.THREE_AND_ONE or ttp==ETS.THREE then--归并3带2
- ttp = ETS.THREE_AND_TWO
- end--]]
- local function __delay( onEnd )
- self.ui:runDelay(1, function() if onEnd and type(onEnd)=='function' then onEnd() end end)
- end
- local function __lastOut(onEnd)
- self:resetSelect()
- app.room:requestOutCards(cards)
- if onEnd and type(onEnd)=='function' then onEnd() end
- end
- if self._lastOutType==ttp then
- if ttp==ETS.LIAN_DUI or ttp==ETS.SHUN_ZI then--最后一手牌顺子连对保证牌数相等
- if #self._lastCards==#cards then
- self:addFunction(__lastOut)
- return
- end
- elseif ttp==ETS.AIRPLANE then--最后一手飞机校验
- if #self._lastCards>=#cards then
- self:addFunction(__lastOut)
- return
- end
- elseif ttp==ETS.SINGLE_CARD or ttp==ETS.DUI_ZI then--最后一手单张
- local result = PokerUtil:getTip(cards, self._lastCards)
- if result and #result > 0 then
- self:addFunction(__lastOut)
- return
- end
- end
- elseif self._lastOutType==0 and (not self.isTuoGuan) then
- local can, handCards = self:checkOnceOut()
- if can then
- self:addFunction(__delay)
- self:addFunction(__lastOut)
- return
- end
- end
- else
- -- showTooltip("---------------------------------showBtn false")
- end
-
- self.ui.Items.Layout_tip:setVisible(true)
- self.ui.Items.Layout_out:setVisible(true)
- self.ui.Items.Layout_not_out:setVisible(true)
- --是否选择了可不要
- if ruleInfo and ruleInfo.allowPass and ruleInfo.allowPass == 1 then
- --开房参数设置为可不要时,才显示不要按钮
- self.ui.Items.Layout_not_out:setVisible(true)
- self.ui.Items.Button_not_out:setVisible(is==true)
- if opFlag and opFlag == 0 then-- 不是有大必打,需要玩家点不出
- self.ui.Items.Layout_tip:setVisible(false)
- self.ui.Items.Layout_out:setVisible(false)
- self.ui.Items.Button_not_out:setBright(true)
- elseif isShowPass ~= nil and isShowPass == false then
- --针对每一局开始发完牌后,庄家不能操作不要按钮
- self.ui.Items.Button_not_out:setBright(false)
- self.ui.Items.Layout_not_out:setVisible(false)
- else
- self.ui.Items.Button_not_out:setBright(true)
- end
- else
- self.ui.Items.Layout_not_out:setVisible(false)
- end
- if self._lastCards and #self._lastCards == 0 and self._lastOutType == 0 then--第一首牌
- self.ui.Items.Layout_not_out:setVisible(false)
- end
-
- --解散按钮状态
- if roomInfo.nGameStartCount == 0 and not app.room:isMyself(roomInfo.nRoomOwnedUid) then
- --未开始,且自己不是房主,则解散按钮不可点击
- self.ui.Items.Button_Dismiss:setEnabled(false)
- else
- self.ui.Items.Button_Dismiss:setEnabled(true)
- end
-
- self:checkCanDismiss()
-
- self.ui.Items.Layout_operating_menus:requestDoLayout()
- self.ui.Items.Layout_operating_menus:doLayout()
-
- self.ui.Items.Button_tip:setVisible(is==true)
- self.ui.Items.Button_out:setVisible(is==true)
- -- 自动提示
- if self._lastOutType>0 and is then
- local cards = self._lastCards
- if cards and #cards>0 then
- local handCards = self:getHandCards()
- local result = PokerUtil:getTip(handCards, cards)
- if result and #result > 0 then
- --local result2 = PokerUtil:getOnlyTip(handCards, cards)
- --if result2 then --有且只有一种提示 自动弹出牌
- -- self:tipCards(clone(result2))
- --end
- else
- result = {}
- end
-
- -- 计算不能出的牌
- local canotOuts = {}
- local tp = self._lastOutType
- if tp == ETS.SINGLE_CARD or (app.room.isMustBomb and app.room.isMustBomb == 1) then
- local bombs = PokerUtil:getAllBomb(handCards, isChoiceAAA)
- local node = self:getPlayerNodeVpos(2)
- if node then
- if node:isAlarm() then
- local max = result[1]
- for _,v in ipairs(result) do
- if v.val > max.val then
- max = v
- end
- end
- local tmpresult = {}
- if max and (max.val == 13 or max.val == 14) then--2和2王 这时候所有的2和王都要提示
- for _,v in ipairs(result) do
- if v.val >= 13 then
- table.insert(tmpresult,v)
- end
- end
- result = tmpresult
- else
- result = {max}
- end
- end
- end
- for _,v in pairs(bombs) do table.insert(result, 1, v) end
- canotOuts = PokerUtil:leftSingleCards(handCards, result)
-
- elseif tp == ETS.DUI_ZI or tp == ETS.SHUN_ZI or tp == ETS.LIAN_DUI or tp == ETS.THREE_AND_TWO
- or tp == ETS.THREE or tp == ETS.THREE_AND_DUI or tp == ETS.AIRPLANE or tp == ETS.AIRPLANE_TOW or tp == ETS.AIRPLANE_DUI then
- local bombs = PokerUtil:getAllBomb(handCards, isChoiceAAA)
- for _,v in pairs(bombs) do table.insert(result, 1, v) end
- if tp == ETS.DUI_ZI or tp == ETS.SHUN_ZI or tp == ETS.LIAN_DUI then --飞机带的牌可以随意
- canotOuts = PokerUtil:leftCardsEx(handCards, result)
- end
- elseif tp == ETS.BOMB then
- end
- local donotTip = false
- if opFlag and opFlag == 0 then
- self:downCanotOuts(handCards, true)
- donotTip = true
- elseif #canotOuts>0 then
- if app.room.isMustBomb and app.room.isMustBomb == 1 then--出的牌有多种牌型可能时,所有牌都可以组合打出去
- canotOuts = {}
- elseif tp == ETS.SHUN_ZI then--是顺子且顺子里面有2,所有牌都可以组合打出去
- local tLastCards = PokerUtil:parseCards(self._lastCards)
- for i = #tLastCards,1,-1 do
- if tLastCards[i].val == 13 then
- canotOuts = {}
- break
- end
- end
- end
- self:downCanotOuts(canotOuts, true)
- end
-
- if result and #result > 0 and (not donotTip) then
- --始终都不自动弹出提示
- --[[local node = self:getPlayerNodeVpos(2)
- if node then
- if node:isAlarm() then
- self:tipCards(clone(result[1].cid and{result[1]} or result[1]))
- else
- self:tipCards(clone(result[#result].cid and {result[#result]} or result[#result]))
- end
- end
- self.ui.Items.Button_tip._tipCards = result
- table.remove(self.ui.Items.Button_tip._tipCards, #self.ui.Items.Button_tip._tipCards)--]]
- --[[local result2 = PokerUtil:getOnlyTip(handCards, cards)
- if result2 then --有且只有一种提示 自动弹出牌
- self:tipCards(clone(result2[1].cid and result2 or result2[1]))
- end--]]
- end
- end
- end
- end
-
- function luzhouPdkRoomView:showMenu( is, flag )
- -- self.ui.Items.btnMenu.show = is==true
- -- if flag then
- -- self.panelMenu:setVisible(is==true)
- -- return
- -- end
- -- if is==true then
- -- self.panelMenu:setVisible(is==true)
- -- local actime = 0.08
- -- local leavAc = { cc.Spawn:create(cc.MoveTo:create(actime, self.LeavePos), cc.FadeIn:create(actime)) }
- -- local disbandAc = { cc.Spawn:create(cc.MoveTo:create(actime, self.DisbandPos), cc.FadeIn:create(actime)) }
- -- local settingAc = { cc.Spawn:create(cc.MoveTo:create(actime, self.SettingPos), cc.FadeIn:create(actime)) }
- -- local uplogAc = {cc.Spawn:create(cc.MoveTo:create(actime, self.RulePos), cc.FadeIn:create(actime)) }
-
- -- self.ui.Items.Button_Leave:runAction(cc.Sequence:create(leavAc))
- -- self.ui.Items.Button_Dismiss:runAction(cc.Sequence:create(disbandAc))
- -- self.ui.Items.Button_Set:runAction(cc.Sequence:create(settingAc))
- -- self.ui.Items.Button_rule:runAction(cc.Sequence:create(uplogAc))
- -- else
- -- local oPos = self.ui.Items.btnMenu:getPosition()
- -- local actime = 0.08
- -- local leavAc = cc.MoveTo:create(actime, oPos)
-
- -- self.ui.Items.Button_Leave:runAction(cc.Spawn:create(leavAc:clone(), cc.FadeOut:create(actime)))
- -- self.ui.Items.Button_Dismiss:runAction(cc.Spawn:create(leavAc:clone(), cc.FadeOut:create(actime)))
- -- self.ui.Items.Button_Set:runAction(cc.Spawn:create(leavAc:clone(), cc.FadeOut:create(actime)))
- -- self.ui.Items.Button_rule:runAction(cc.Sequence:create(cc.Spawn:create(leavAc:clone(), cc.FadeOut:create(actime)), cc.CallFunc:create(function() self.panelMenu:setVisible(is==true) end)))
- -- end
- end
-
- -- 是否显示准备按钮
- function luzhouPdkRoomView:showSitdownBtn( is )
- if self._isGameOver and true == self._isGameOver then return end
- self.ui.Items.Button_Ready:setVisible(is == true)
- local playerNum = app.room:getPlayerNum()
- if playerNum ~= app.room:getRoomInfo().nMaxPlayCount then--房间人数未满
- self.ui.Items.Button_invite:setVisible(true)
- -- local invitePos = self.ui.Items.Button_invite:getPosition()
- -- if is then
- -- self.ui.Items.Button_invite:runAction(cc.MoveTo:create(0.2, self.ui.Items.Button_invite.oPos))
- -- self.ui.Items.Button_Ready:runAction(cc.MoveTo:create(0.2, self.ui.Items.Button_Ready.oPos))
- -- else
- -- if invitePos.x < 10 then
- -- self.ui.Items.Button_invite:stopAllActions()
- -- self.ui.Items.Button_invite:setPosition(self.ui.Items.Button_invite.oPos)
- -- self.ui.Items.Button_invite:runAction(cc.MoveTo:create(0.2, cc.p(10, invitePos.y)))
- -- end
- -- end
- else
- -- local readyPos = self.ui.Items.Button_Ready:getPosition()
- -- self.ui.Items.Button_Ready:stopAllActions()
- -- self.ui.Items.Button_Ready:runAction(cc.MoveTo:create(0.2, cc.p(10, readyPos.y)))
- end
- self:updateInviteClubButton()
- self:updateButtonPosition()
- end
-
- function luzhouPdkRoomView:updateButtonPosition()
- self.ui.Items.Button_Ready:getParent():setVisible(self.ui.Items.Button_Ready:isVisible())
- self.ui.Items.Button_invite:getParent():setVisible(self.ui.Items.Button_invite:isVisible())
- self.ui.Items.Button_Invite_Club:getParent():setVisible(self.ui.Items.Button_Invite_Club:isVisible())
-
- local roomInfo = app.room.roomInfo or {}
- local gameId = roomInfo.gameId or app.gameId
- local gameConfig = getSubGameConfig(gameId)
- if gameConfig.isOpenClubInvite == false then
- self.ui.Items.Button_Invite_Club:getParent():setVisible(false)
- end
- if isReviewVersion() then
- self.ui.Items.Button_invite:getParent():setVisible(false)
- self.ui.Items.Button_Invite_Club:getParent():setVisible(false)
- end
-
- self.ui.Items.Layout_Button:requestDoLayout()
- self.ui.Items.Layout_Button:doLayout()
- end
-
- function luzhouPdkRoomView:onClickButtonShowClub( sender )
- --[[local clubList = app.club_php.clubList
- if clubList and table.nums(clubList)>0 then
- local roomInfo = app.room:getRoomInfo()
- local infoT = json.decode(roomInfo.nGameInfo)
- local view = import("luaScript.Views.Club.ClubTable"):new(clubList[app.club_php.clubID], infoT.tableIdx)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- else
- app.club_php:getClubList()
- end--]]
- playBtnEffect()
- if IS_USER_NEW_CLUB then
- openClub()
- else
- local clubList = app.club_php.clubList
- if clubList and table.nums(clubList) > 0 then
- --房间号
- local roomInfo = app.room:getRoomInfo()
- if roomInfo then
- --创建房间时传入的桌子下标
- local infoT = json.decode(roomInfo.nGameInfo)
-
- self.clubView = import("luaScript.Views.Club.ClubTable"):new(clubList[app.club_php.clubID], infoT.tableIdx)
- self.clubView:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(self.clubView)
- end
- else
- --未找到茶馆列表数据时,请求茶馆列表(可能是断线重连)
- app.club_php:getClubList();
- end
- end
- end
-
- function luzhouPdkRoomView:onClickButtonRstComfirm( sender )
- playBtnEffect()
- -- 小结算
- local showFunc = function (msg)
- for _,node in pairs(self._playerNodes) do
- node:cleanScore()
- end
- if msg then
- self.xiaojuView = import("pk_luzhoupdk.luaScript.Views.Room.Sub.luzhouPdkGameResultView"):new(msg)
- self.xiaojuView:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(self.xiaojuView)
- end
- end
- showFunc(self._resultMsg)
- end
-
- -- 三人玩打开GPS
- --[[function luzhouPdkRoomView:onClickButtonGps( sender )
- playBtnEffect()
- local isStart = app.room:getRoomInfo().nGameStartCount>0
- local exitFunc = function ()
- local isStart = app.room:getRoomInfo().nGameStartCount>0
- if isStart then
- app.room:requestDismissRoom(1)--发起解散
- else
- self.ui:sendMsg(app.room, "callLeaveRequest")--离开房间
- end
- end
- local dismissFunc = function ()
- app.room:requestDismissRoom(1)--发起解散
- end
- -- self.gpsComponent:showGpsView(app.room:getRoomInfo().nMaxPlayCount, isStart, exitFunc, dismissFunc)
- local playerlist = app.room:getUserInfoList()
- if not isReviewVersion() and self.gpsComponent then
- self.gpsComponent:updateUserInfos(playerlist)
- self.gpsComponent:showGpsView(4, isStart, exitFunc, exitFunc)
- end
-
- end--]]
-
- -- 显示GPS界面
- function luzhouPdkRoomView:showGpsView()
- if self.isRecordScene then return end--回放场景直接return
- logD("luzhouPdkRoomView:showGpsView()")
- playBtnEffect()
- local isGameStart = app.room:getRoomInfo().nGameStartCount > 0
- if self.gpsComponent then
- self.gpsComponent:showGpsView(isGameStart)
- end
- end
-
- -- 玩家点击房间详情
- function luzhouPdkRoomView:onClickButtonDetails( sender )
- playBtnEffect()
- self.ui.Items.Layout_Rule:setVisible(not self.ui.Items.Layout_Rule:isVisible())
- self.ui.Items.Layout_7:setVisible(self.ui.Items.Layout_Rule:isVisible())
- self.ui.Items.Button_rule:setVisible(not self.ui.Items.Layout_Rule:isVisible())
- -- self:showMenu(false, true)
- -- local view = import("pk_luzhoupdk.luaScript.Views.Room.Sub.luzhouPdkGameDetailView"):new(app.room:getRoomInfo().nGameInfo)
- -- view:setAnchorPoint(cc.p(0.5, 0.5))
- -- app:showWaitDialog(view)
- end
-
- -- 一键截屏
- function luzhouPdkRoomView:onClickButtonShot( sender )
- playBtnEffect()
- showScreenShot()
- end
-
- function luzhouPdkRoomView:onClickButtonMenu( sender )
- playBtnEffect()
- --self:showMenu(not sender.show)
- self.ui.Items.Layout_Menu_1:setVisible(not self.ui.Items.Layout_Menu_1:isVisible())
- self.ui.Items.Layout_7:setVisible(self.ui.Items.Layout_Menu_1:isVisible())
- end
-
- function luzhouPdkRoomView:onClickMenuOut( sender )
- -- self:showMenu(false)
- self.ui.Items.Layout_Rule:setVisible(false)
- self.ui.Items.Layout_7:setVisible(false)
- self.ui.Items.Layout_Menu_1:setVisible(false)
- self.ui.Items.Button_rule:setVisible(true)
- end
-
- function luzhouPdkRoomView:onClickButtonLeave( sender )
- playBtnEffect()
- self:showMenu(false, true)
- self.ui:sendMsg(app.room, "callLeaveRequest")
- end
-
- function luzhouPdkRoomView:onClickButtonDismiss( sender )
- playBtnEffect()
- local function onClickOk()
- self:showMenu(false, true)
- app.room:requestDismissRoom(1)--发起解散
- end
- local function onClickCancel()
- end
- showConfirmDialog("确定要申请解散房间吗?", onClickOk, onClickCancel)
- end
-
- function luzhouPdkRoomView:onClickButtonSetting( sender )
- playBtnEffect()
- self:showMenu(false, true)
- local view = import("pk_luzhoupdk.luaScript.Views.Room.Sub.luzhouPdkSettingView"):new()
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
-
- function luzhouPdkRoomView:onClickButtonUlog( sender )
- playBtnEffect()
- self:showMenu(false, true)
- local view = import("luaScript.Views.Room.UplogView"):new()
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
-
- function luzhouPdkRoomView:onClickButtonTip( sender, tag, tipShow )
- playBtnEffect()
- --获取开房参数
- local roomInfo = app.room:getRoomInfo()
- local gameInfo = roomInfo.nGameInfo or ""
- local ruleInfo = json.decode(gameInfo)
- --是否选择了AAA可为炸弹
- local isChoiceAAA = false
- --[[if ruleInfo and ruleInfo.specialRule and getNumBand(ruleInfo.specialRule, 0x0080)>0 then
- isChoiceAAA = true
- end--]]
-
- --出牌提示
- local cards = self._lastCards
- if cards and #cards>0 then
- local tp = PokerUtil:checkType(cards)
- if tp >= ETS.NONE then
- return nil
- end
- -- showTooltip("提示牌型: " .. PokerUtil:getTypeString(tp))
- local handCards = self:getHandCards()
- if #handCards<=0 then return false end
- if tp == ETS.SINGLE_CARD then
- if sender._tipCards and #sender._tipCards>0 then
- local tmp = sender._tipCards[#sender._tipCards]
- if tmp[1] and type(tmp[1])=='table' then
- self:tipCards(clone(tmp))
- else
- self:tipCards({clone(tmp)})
- end
- table.remove(sender._tipCards, #sender._tipCards)
- if #sender._tipCards <= 0 then
- sender._tipCards = nil
- end
- else
- local result = PokerUtil:getTip(handCards, cards)
- if result and #result > 0 then else result = {} end
- -- 判断下家是否报单
- local node = self:getPlayerNodeVpos(2)
- if node then
- if node:isAlarm() then
- local max = result[1]
- for _,v in ipairs(result) do
- if v.val > max.val then
- max = v
- end
- end
- local tmpresult = {}
- if max and max.val and (max.val == 13 or max.val == 14) then--2和2王 这时候所有的2和王都要提示
- for _,v in ipairs(result) do
- if v.val >= 13 then
- table.insert(tmpresult,v)
- end
- end
- result = tmpresult
- else
- result = {max}
- end
- end
- end
- local bombs = PokerUtil:getAllBomb(handCards, isChoiceAAA)
- local cds = {}
- for _,v in pairs(bombs) do
- table.insert(result, 1, v)
- end
- if #result <= 0 then return end
- sender._tipCards = clone(result)
- local tmp = sender._tipCards[#sender._tipCards]
- if tag then
- if #result>=1 then
- if tmp[1] and type(tmp[1])=='table' then
- self:tipCards(clone(tmp))
- else
- self:tipCards({clone(tmp)})
- end
- table.remove(sender._tipCards, #sender._tipCards)
- end
- else
- if tmp[1] and type(tmp[1])=='table' then
- self:tipCards(clone(tmp))
- else
- self:tipCards({clone(tmp)})
- end
- table.remove(sender._tipCards, #sender._tipCards)
- end
- end
- elseif tp == ETS.DUI_ZI or tp == ETS.SHUN_ZI or tp == ETS.LIAN_DUI or tp == ETS.THREE_AND_TWO
- or tp == ETS.THREE_AND_DUI or tp == ETS.THREE or tp == ETS.AIRPLANE or tp == ETS.AIRPLANE_TOW or tp == ETS.AIRPLANE_DUI then
- if sender._tipCards and #sender._tipCards>0 then
- self:tipCards(clone(sender._tipCards[#sender._tipCards]))
- table.remove(sender._tipCards, #sender._tipCards)
- if #sender._tipCards <= 0 then sender._tipCards = nil end
- else
- local result = PokerUtil:getTip(handCards, cards)
- if result and #result > 0 then else result = {} end
- local bombs = PokerUtil:getAllBomb(handCards, isChoiceAAA)
- for _,v in pairs(bombs) do table.insert(result, 1, v) end
-
- if #result <= 0 then return end
- sender._tipCards = clone(result)
- if tag then
- if #result >= 1 then
- self:tipCards(clone(sender._tipCards[#sender._tipCards]))
- table.remove(sender._tipCards, #sender._tipCards)
- end
- else
- self:tipCards(clone(sender._tipCards[#sender._tipCards]))
- table.remove(sender._tipCards, #sender._tipCards)
- end
- end
- elseif tp == ETS.BOMB then
- if sender._tipCards and #sender._tipCards>0 then
- self:tipCards(clone(sender._tipCards[#sender._tipCards]))
- table.remove(sender._tipCards, #sender._tipCards)
- if #sender._tipCards <= 0 then sender._tipCards = nil end
- else
- local result = PokerUtil:getTip(handCards, cards)
- if result and #result > 0 then else return end
- sender._tipCards = clone(result)
- if tag then
- if #result >= 1 then
- self:tipCards(clone(sender._tipCards[#sender._tipCards]))
- table.remove(sender._tipCards, #sender._tipCards)
- end
- else
- self:tipCards(clone(sender._tipCards[#sender._tipCards]))
- table.remove(sender._tipCards, #sender._tipCards)
- end
- end
- else
- return nil
- end
- else--没有牌,第一手提示
- local handCards = self:getHandCards()
- if sender._tipCards and #sender._tipCards>0 then
- self:tipCards(clone(sender._tipCards[#sender._tipCards]))
- table.remove(sender._tipCards, #sender._tipCards)
- if #sender._tipCards <= 0 then sender._tipCards = nil end
- else
- local result = PokerUtil:getFirstTip(handCards)
- if result and #result > 0 then else return end
- sender._tipCards = clone(result)
- self:tipCards(clone(sender._tipCards[#sender._tipCards]))
- table.remove(sender._tipCards, #sender._tipCards)
- end
- end
- end
-
- -- 变暗不能出的牌
- function luzhouPdkRoomView:downCanotOuts(canotOuts, isTouch)
- for _,v in pairs(canotOuts) do
- local node = self:getCardNode(v)
- if node and (not tolua.isnull(node)) then
- node:setNormal()
- node:setNormalColor()
- node:setNoTouch(isTouch)
- end
- end
- local tmp = {}
- for _,v in pairs(self._selectCards) do
- if v and (not tolua.isnull(v)) and v:isDown() then
- table.insert(tmp, v)
- end
- end
- self._selectCards = tmp
- end
-
- --出牌
- function luzhouPdkRoomView:onClickButtonOut( sender )
- playBtnEffect()
- local cards = self:getSelected()
- if #cards <= 0 then
- return showTooltip("请选择要出的牌")
- else
- local serverLastOuttype
- if app.room.lastOutType and app.room.lastOutType >0 and app.room.lastOutType < 100 then
- serverLastOuttype = app.room.lastOutType
- end
- local isThreeA = false
- local tp = PokerUtil:checkType(cards)
- local gameInfo = app.room:getRoomInfo().nGameInfo or ""
- local ruleInfo = json.decode(gameInfo)
- --[[--是否选择了AAA为炸弹
- if ruleInfo.specialRule and getNumBand(ruleInfo.specialRule, 0x0080) > 0 then
- if PokerUtil:isAAA(cards) then
- tp = ETS.BOMB
- isThreeA = true
- end
- end--]]
-
- if tp >=100 then
- --return showTooltip("选择的牌型错误")
- end
- if self._lastCards and #self._lastCards>0 then
- self._lastOutType = serverLastOuttype or PokerUtil:checkType(self._lastCards)
- end
- --检测炸弹是否可拆(不可拆要做检测)
- --[[if not self.ruleIsChaiBomb then
- if PokerUtil:isChaiBombs(self:getHandCards(), cards) then
- return showTooltip("炸弹不可拆开")
- end
- end--]]
- --[[if not isThreeA and (tp == ETS.THREE_AND_ONE or tp == ETS.THREE) then--归并三带二
- tp = ETS.THREE_AND_TWO
- end--]]
- local isHaveGui,guiNum = PokerUtil:checkHaveGui1(cards)
- local isAllow = self._lastOutType == 4 or self._lastOutType == 5 or self._lastOutType == 9 or self._lastOutType == 10
- if (self._lastOutType==tp or isHaveGui) or self._lastOutType==0 or tp==ETS.BOMB or isAllow then
- -- 检测下家是否报单
- --获取自己的座位数据
- local myself = app.room:getMyself()
- local pdata = app.room:getPlayerVpos(myself.viewPos)
- logD("luzhouPdkRoomView:onClickButtonOut pdata = "..table.tostring(pdata))
- local node = self:getPlayerNode(pdata.userId)
- local isAlarm = node:isAlarm()
- if isAlarm and #cards==1 and tp==ETS.SINGLE_CARD then
- -- 判断是否是最大单张
- if PokerUtil:isMaxCard(self:getHandCards(), cards[1]) then
- app.room:requestOutCards(cards)
- else
- return showTooltip("报单必须出最大牌")
- end
- else
- if self._lastOutType==ETS.SHUN_ZI and tp==ETS.SHUN_ZI and #self._lastCards~=#cards then--限制顺子牌张数
- return showTooltip("顺子牌张数错误")
- end
- -- 判断顺子的大小
- if self._lastOutType==ETS.SHUN_ZI then
- local cards1 = pokerSortPdkCards(cards)
- local _, minVal = pokerParse(self._lastCards[1])
- local _, outMinVal = pokerParse(cards[1])
- if cards1[#cards].val <= minVal then
- --return showTooltip("出牌选择错误")
- end
- end
- app.room:requestOutCards(cards)
- end
- else
- return showTooltip("选择的牌型错误")
- end
- end
- end
-
- function luzhouPdkRoomView:onClickButtonNotOut( sender )
- local cards = {}
- app.room:requestOutCards(cards)
- end
-
- function luzhouPdkRoomView:onClickButtonReady( sender )
- playBtnEffect()
- self.ui:sendMsg(app.room, "callReadyRequestPdk")
- end
-
- function luzhouPdkRoomView:getInviteData()
- local strNames = ""
- local index = 0
- local num = app.room:getPlayerNum()
- for k,v in pairs(app.room:getPlayers()) do
- index = index + 1
- local name = getSubStringNickname(v.nickname)
- strNames = strNames..name
- if index < num then strNames = strNames.."," end
- end
- local roomInfo = app.room:getRoomInfo()
- if (not num) or (not roomInfo.nMaxPlayCount) or (not roomInfo.nGameInfo) or (not roomInfo.nTotalGameNum) or (not roomInfo.nTableId) then
- return "",""
- end
- local invitePtr = luzhouPdkRoomViewConfig.InviteConfig[roomInfo.nMaxPlayCount][num]--几缺几
- local strGameMode = luzhouPdkRoomViewConfig.getRuleString(roomInfo.nGameInfo)
- local strGameNum = string.format("%s局", roomInfo.nTotalGameNum)
- local desc = string.format("%s,%s 玩家:%s", strGameNum, strGameMode, strNames)
- print("pdk_invite : ",desc)
- local title = string.format("泸州跑得快 房号[%s] %s", roomInfo.nTableId, invitePtr )
- if app.club_php.clubID and app.club_php.clubID~=0 then
- title = string.format("%s %sID[%d]", title,(app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_NAME), tonumber(app.club_php.clubID))
- end
- print("pdk_invite : ", title)
-
- return title,desc
- end
-
- --邀请好友
- function luzhouPdkRoomView:onClickButtonInvite( sender )
- playBtnEffect()
- --[[local strNames = ""
- local index = 0
- local num = app.room:getPlayerNum()
- for k,v in pairs(app.room:getPlayers()) do
- index = index + 1
- local name = getSubStringNickname(v.nickname)
- strNames = strNames..name
- if index < num then strNames = strNames.."," end
- end
- local roomInfo = app.room:getRoomInfo()
- local invitePtr = luzhouPdkRoomViewConfig.InviteConfig[roomInfo.nMaxPlayCount][num]--几缺几
- local strGameMode = luzhouPdkRoomViewConfig.getRuleString(roomInfo.nGameInfo)
- local strGameNum = string.format("%s局", roomInfo.nTotalGameNum)
- local desc = string.format("%s,%s 玩家:%s", strGameNum, strGameMode, strNames)
- print("pdk_invite : ",desc)
- local title = string.format("欢乐跑得快 房号[%s] %s", roomInfo.nTableId, invitePtr )
- if app.club_php.clubID and app.club_php.clubID~=0 then
- title = string.format("%s 茶馆ID[%d]", title, tonumber(app.club_php.clubID))
- end
- print("pdk_invite : ", title)--]]
- local title,desc = self:getInviteData()
- local imagePath = cc.FileUtils:getInstance():getWritablePath().."icon.png"
-
- --[[ local info = {}
- info.scene = "talk"
- info.contentType = "url"
- info.url = app.config.Setting.appDownloadUrl
- info.title = title
- info.description = desc
- info.image = imagePath
- info.imageWidth = 100
-
- app.plugin:shareGame(info)--]]
-
- local info = {}
- info.title = title
- info.description = desc
- info.copyData={type=2}
-
- local view = import("luaScript.Views.Main.ShareView"):new(info)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
-
- function luzhouPdkRoomView:onClickCopy()
- playBtnEffect()
- local title,desc = self:getInviteData()
- local clubData = ""
- if app.club_php.clubID and app.club_php.clubID ~= 0 then
- local clubName = ""
- local clubList = app.club_php.clubList
- if clubList and table.nums(clubList) > 0 then
- clubName = clubList[tonumber(app.club_php.clubID)].clubName;
- end
- clubData = string.format((app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_NAME).."名:%s \n", clubName)
- end
- local tishi = "复制信息打开游戏将自动入座\n<仅供娱乐,严禁赌博>"
- copyData = string.format("%s%s\n%s\n%s",clubData,title,desc,tishi)
- logD(copyData)
-
- copyStringToClipboard(copyData)
-
- app.plugin:gotoWeiXin()
- end
-
- -- 恢复自己手牌
- function luzhouPdkRoomView:recoverHandcards(_cards)
- self:cleanSelfCards()
- local cards = pokerSortPdkCards(_cards)
- local pos = 1
- local allCount = #cards
- for i,card in ipairs(cards) do
- self:sendOneCardNoAct(card.cid, i, pos, i==allCount, allCount)
- end
- self:resetCardsPos()
- end
-
- function luzhouPdkRoomView:onPdkResponseGameRecover( data )
- local roomInfo = app.room:getRoomInfo()
- if roomInfo.recoverItem then
- local recoverData = roomInfo.recoverItem
- self:recover(recoverData)
- self._passGameResult = nil
- end
- end
-
- function luzhouPdkRoomView:updateInviteClubButton()
- if app.club_php.clubID and app.club_php.clubID~=0 then
- local roomInfo = app.room:getRoomInfo()
- if roomInfo.nGameStartCount==0 and table.nums(roomInfo.memberList)<roomInfo.nMaxPlayCount then
- self.ui.Items.Button_Invite_Club:setVisible(true)
- else
- self.ui.Items.Button_Invite_Club:setVisible(false)
- end
- end
-
- if isReviewVersion() then
- self.ui.Items.Button_Invite_Club:setVisible(false)
- self.ui.Items.Button_invite:setVisible(false)
- end
- end
-
- --断线恢复
- function luzhouPdkRoomView:recover( data , connect)
- connect = connect or false
- local roomInfo = app.room:getRoomInfo()
- --self:checkGpsDistance(nil,roomInfo.nGameStartCount==0)
- --self:checkMyGpsNeedUpdate();
- if roomInfo.nGameStartCount==0 then
- local tmpPosData = {}
- tmpPosData.players = {}
- for _,pdata in ipairs(data) do
- table.insert(tmpPosData.players,{nUserId = pdata.userId,nSeatId = pdata.seatId})
- end
- self:onUpdatePlayerPos({response = tmpPosData})
- end
-
- -- 当前操作玩家
- local curOpUserId = -1
- local tmpData = {}
- local outCount = 0--一手牌都没打的玩家数
- local cardNum = 0--桌面上牌组数量
- for _,pdata in ipairs(data) do
- tmpData[pdata.userId] = pdata
- local player = app.room:getPlayer(pdata.userId)
- local node = self:getPlayerNode(pdata.userId)
- if not node and player then
- self:addPlayerNode(player)
- else
- pdata.totalScore = tonumber(pdata.totalScore)
- node:setScoreNoAnim(pdata.totalScore)
- node:setBanker(pdata.seatId==roomInfo.reBankerId)
- node:setOffline(pdata.onlineStatus==0)
- node:setOfflineTime(pdata.onlineStatus==0,pdata.offtime or 0)
- node:setReady(pdata.playFlag==1)
- end
- if pdata.isCanOp==1 then
- curOpUserId = pdata.userId
- end
- if app.room:getRuleCardsNum()==#pdata.handCards then outCount = outCount + 1 end
- if #pdata.outCards>0 then cardNum = cardNum + 1 end
- end
-
- self:resetRoundData()
-
- self:updateInviteClubButton()
-
- -- 托管状态恢复
- for k,v in pairs(roomInfo.hostInfos or {}) do
- local aiStatus = v.aiStatus;
- local nUserID = v.nUserID;
- local viewId = app.room:getViewIdByUserId(nUserID)
- local isTuoGuan = aiStatus == 1;
- if app.room:isMyself(nUserID) then
- if isTuoGuan then
- self:showTuoGuan(true)
- self.isTuoGuan = true
- else
- self:showTuoGuan(false)
- self.isTuoGuan = false
- end
-
- end
- local node = self:getPlayerNodeVpos(viewId)
- if node then
- node:setTuoGuan(isTuoGuan)
- end
- end
-
- if roomInfo.nGameStartCount > 0 then
- self:showJiPaiQi(true,roomInfo.cardPlayerInfo)
- end
-
- if roomInfo.gameStatus == luzhouPdkRoomViewConfig.GameStatus.GAME_STATE_INIT then
- for _,pdata in ipairs(data) do
- local player = app.room:getPlayer(pdata.userId)
- local node = self:getPlayerNode(pdata.userId)
- if app.room:isMyself(pdata.userId) then
- self:showTurnBtn(false)--能否出牌
- self:showSitdownBtn(pdata.playFlag~=1 and pdata.playFlag~=2)
- end
- end
-
- --清理离线后的玩家
- local players = app.room:getPlayers()
- for k,v in pairs(self._playerNodes) do
- local is = false
- for _,pd in pairs(players) do
- if pd.userId == tonumber(k) then
- is = true
- break
- end
- end
- if not is then self:delPlayerNode(tonumber(k)) end
- end
-
- if app.room.isReconnection == true then
- self:isShowFastStartView()
- end
-
- self:showFastStart(true)
- elseif roomInfo.gameStatus == luzhouPdkRoomViewConfig.GameStatus.GAME_STATE_SEND_HAND_CARD
- or roomInfo.gameStatus == luzhouPdkRoomViewConfig.GameStatus.GAME_STATE_OUT_CARD then
- -- 清除上一次的提示牌
- self.ui.Items.Button_tip._tipCards = nil
- -- 离开房间不可点击
- self.ui.Items.Button_Leave:setEnabled(false)
-
- local cp = app.room:getPlayer(curOpUserId)
- local preCid = app.room:getPreSeatId(cp.seatId)
- self._lastCards = {}
- self._lastOutPos = 0
- self._lastOutType = 0
- local lastOutPlayer = nil
- while cp.seatId ~= preCid do
- local d = app.room:getPlayerCid(preCid)
- if d then
- local tmp = tmpData[d.userId]
- if tmp and #tmp.outCards>0 then
- self._lastCards = tmp.outCards
- self._lastOutType = tmp.handType--PokerUtil:checkType(tmp.outCards)
- app.room.lastOutType = tmp.handType
- self._lastOutPos = d.viewPos
- lastOutPlayer = d
- break
- end
- end
- preCid = app.room:getPreSeatId(preCid)
- end
-
- for _,pdata in ipairs(data) do
- local player = app.room:getPlayer(pdata.userId)
- self:clearPosShow(player.viewPos)
- local node = self:getPlayerNode(pdata.userId)
- if app.room:isMyself(pdata.userId) then
- if not connect then self:recoverHandcards(pdata.handCards) end
- if node then node:showLeft(#pdata.handCards) end
- else
- if node then
- node:showLeft(#pdata.handCards)
- node:setOffline(pdata.onlineStatus==0)
- node:setOfflineTime(pdata.onlineStatus==0,pdata.offtime or 0)
- end
- end
- if node then
- node:setTurn(pdata.isCanOp==1, 0)
- node:setScore(pdata.totalScore)
- node:setBanker(pdata.seatId==roomInfo.reBankerId)
- end
- local player = app.room:getPlayer(pdata.userId)
- if #pdata.outCards > 0 then--显示最后一手牌
- if app.room:isMyself(pdata.userId) and pdata.isCanOp==1 then
- else
- --node:setLastOp(PokerUtil:checkType(pdata.outCards), pdata.outCards)
- node:setLastOp(pdata.handType, pdata.outCards)
- end
- else
- -- 判断是否一次牌都没出过
- if app.room.roomInfo.nMaxPlayCount == outCount or (app.room:isMyself(pdata.userId) and pdata.isCanOp==1) or (pdata.isCanOp==1) then
- else
- if pdata.passShow then
- node:setLastOp(ETS.PASS, {})
- end
- end
- end
- if pdata.isCanOp == 1 and cardNum==app.room.roomInfo.nMaxPlayCount then
- node:cleanLastCards()
- end
- end
-
- local isShowPass = false
- --发牌后,还未出牌,判断当前可操作玩家id是否为自己
- if app.room:isMyself(roomInfo.curOpUid) then
- --当前操作玩家操作类型 0-pass 1-可以出牌也可以pass 2-只能出牌
- if roomInfo.curOpType == 1 then
- isShowPass = true
- end
- end
-
- for _,pdata in ipairs(data) do
- if roomInfo.gameStatus == luzhouPdkRoomViewConfig.GameStatus.GAME_STATE_SEND_HAND_CARD then--发牌庄家出牌
- if app.room:isMyself(pdata.userId) then
- self:showTurnBtn(pdata.seatId==roomInfo.reBankerId, isShowPass,2)
- end
-
- local node = self:getPlayerNode(pdata.userId)
- if node and pdata.seatId==roomInfo.reBankerId then
- node:setTurn(true, 0)
- else
- node:setTurn(false)
- end
- else--游戏中途
- if app.room:isMyself(pdata.userId) then
- self:showTurnBtn(pdata.isCanOp==1, isShowPass,roomInfo.curOpType)--能否出牌
- end
- end
- end
-
- self:showSitdownBtn(false)
-
- if self:getMode()==0 then
- self:showOtherCards(true)
- end
-
- --游戏中不显示2/3人快速开始按钮
- self:showFastStart(false)
- elseif roomInfo.gameStatus == luzhouPdkRoomViewConfig.GameStatus.GAME_STATE_ROUND_OVER then--需要判断是否已经有单局结算页面
- self.ui.Items.Button_Leave:setEnabled(false)
-
- local response = {}
- response.gameStartCount = roomInfo.nGameStartCount
- response.totalGamenum = roomInfo.nTotalGameNum
- response.bankSeatId = roomInfo.reBankerId
- local players = {}
- for i,v in ipairs(data) do
- local p = {}
- p.userId = v.userId
- p.turnScore = v.turnScore
- p.totalScore = v.totalScore
- p.bombTimes = v.turnBombTimes--单局炸弹数
- p.haveRedTen = v.haveRedTen
- p.bSpring = v.bSpring
- p.leftNum = #v.handCards
- p.handCards = v.handCards
- p.groupCardInfo = v.groupCardInfo
- p.allBombTimes = v.allBombTimes
- table.insert(players, p)
- local player = app.room:getPlayer(p.userId)
- local playerNode = self:getPlayerNode(player.userId)
- --[[if #v.outCards > 0 and player and playerNode then
- playerNode:showLastCards(v.outCards, PokerUtil:checkType(v.outCards))
- end--]]
- if #v.handCards>0 and player then
- self:showLeftCards(player.viewPos, v.handCards or {})
- end
- end
- response.players = players
- response.leftCards = {}
- self:showGameResultRecover({response=response})
-
- --游戏中不显示2/3人快速开始按钮
- self:showFastStart(false)
-
- if self:getMode()==0 then
- self:showOtherCards(true)
- end
- elseif roomInfo.gameStatus == luzhouPdkRoomViewConfig.GameStatus.GAME_STATE_GAME_OVER then
- local response = {}
- local players = {}
- for i,v in ipairs(data) do
- local p = {}
- p.userId = v.userId
- p.totalScore = v.totalScore
- --"extString" = "{"bombTimes":0,"loseTimes":0,"maxScore":3,"winTimes":2}"
- local extString = ""
- local d = {}
- d.bombTimes = v.totalBombTimes--总炸弹数
- d.loseTimes = v.loseTimes
- d.maxScore = v.maxScore
- d.winTimes = v.winTimes
- p.extString = json.encode(d)
- table.insert(players, p)
- end
- response.players = players
- self:onResponseGameOver({response=response})
-
- local quickStartInfo = app.room.roomInfo.quickStartInfo
- if quickStartInfo then
- if quickStartInfo.tablefaststate == true then
- local tmpInfo = {}
- for uid,status in pairs(quickStartInfo.list) do
- table.insert(tmpInfo, {nUserId=tonumber(uid), nStatus = status})
- end
- local response = {}
- response.pList = tmpInfo
- response.timeOut = app.room.roomInfo.quickStartInfo.time
- self:onBroadcastFaststart({response=response})
- else
- self:showFastStart(true)
- end
- else
- self:showFastStart(true)
- end
- end
- if roomInfo.bUserDisbandGame == 1 then --房间是否是解散状态
- app.room:dispatchEvent({name = "pdkNormalEvent_show_dissmiss_over"})
- -- 其他玩家的解散状态
- local dismissInfo = {}
- local list = {}
- for i,v in ipairs(data) do
- dismissInfo[v.userId] = v.disbandStatus
- local l = {}
- l.nUserId = v.userId
- l.dismissState = v.disbandStatus
- table.insert(list, l)
- end
- app.room.dismissInfo = dismissInfo
-
- local response = {}
- response.memberList = list
- response.timeLeft = roomInfo.leftTimeOut
- response.operateType = 1
- self:onDismissResponse({response=response})
- end
-
- if (roomInfo.gameStatus > luzhouPdkRoomViewConfig.GameStatus.GAME_STATE_INIT and roomInfo.gameStatus <= luzhouPdkRoomViewConfig.GameStatus.GAME_STATE_GAME_OVER) then
- self.ui.Items.Button_invite:setVisible(false)
- else
- self.ui.Items.Button_invite:setVisible(app.room:getPlayerNum()~=app.room:getRoomInfo().nMaxPlayCount)
- end
- self:updateButtonPosition()
-
- ----------------------------------------------------------------------------------------
- roomInfo.recoverItem = nil
- roomInfo.reBankerId = nil
- end
-
- -- 小局结算
- function luzhouPdkRoomView:showGameResultRecover( data )
- -- if self._gameResult then return false end--避免断线重连弹出多个小结算
- local msg = data.response
- local maxCards = 0
- for _,v in pairs(msg.players) do
- local node = self:getPlayerNode(v.userId)
- v.totalScore = tonumber(v.totalScore)
- if node then node:setScore(v.totalScore,false) end
- node:hideLeft()
- v.leftCards = v.leftCards or {}
- if #v.leftCards > maxCards then maxCards = #v.leftCards end
- local pdata = app.room:getPlayer(v.userId)
- v.unionid = pdata.unionid
- v.headimgurl = pdata.headimgurl
- v.gpsInfo = pdata.gpsInfo
- v.sex = pdata.sex
- v.openid = pdata.openid
- v.nickname = pdata.nickname
- v.areano = pdata.areano
- end
-
- --是不是最后一局
- local roomInfo = app.room:getRoomInfo()
- msg.isLast = roomInfo.nGameStartCount==roomInfo.nTotalGameNum
- msg.isZhaniao = self.ruleZhaniao
- msg.ruleString = luzhouPdkRoomViewConfig.getRuleString(roomInfo.nGameInfo)
-
- self._resultMsg = {}
- self._resultMsg.players = msg.players
- self._resultMsg.isLast = msg.isLast
- self._resultMsg.isZhaniao = msg.isZhaniao
- self._resultMsg.ruleString = msg.ruleString
- self._resultMsg.gameStartCount = msg.gameStartCount
- self._resultMsg.totalGamenum = msg.totalGamenum
- -- -- 小结算
- local showFunc = function ()
- for _,v in pairs(self._playerNodes) do
- v:hideLeft()
- end
- self:showRstComfirm(true)
- end
- self._gameResult = true
- --中途恢复直接展示
- -- showLeftFunc()
- showFunc()
- end
-
- function luzhouPdkRoomView:bindEvents()
- self:bindEvent(app.room , "onUserExitResponseRoom" , handler(self , self.onUserExitResponseRoom))
- --onDismissResponse
- self:bindEvent(app.room , "onDismissResponse" , handler(self , self.onDismissResponse))
- -- 其他玩家进入房间
- self:bindEvent(app.room , "onResponseBroadcastLogin" , handler(self , self.onResponseBroadcastLogin))
- -- 玩家离开房间
- self:bindEvent(app.room , "onResponseBroadcastLogout" , handler(self , self.onResponseBroadcastLogout))
- -- 玩家准备
- self:bindEvent(app.room , "onResponseUserReady" , handler(self , self.onResponseUserReady))
- -- 游戏开始
- self:bindEvent(app.room , "onResponseGameStart" , handler(self , self.onResponseGameStart))
- -- 给玩家发牌
- self:bindEvent(app.room , "onResponseSendCards" , handler(self , self.onResponseSendCards))
- -- 玩家出牌成功
- self:bindEvent(app.room , "onResponseOutCards" , handler(self , self.onResponseOutCards))
- -- 玩家出牌错误
- self:bindEvent(app.room , "onResponseOutCardsErr" , handler(self , self.onResponseOutCardsErr))
- -- 单局结算
- self:bindEvent(app.room , "onResponseGameResult" , handler(self , self.onResponseGameResult))
- -- 总结算
- self:bindEvent(app.room , "onResponseGameOver" , handler(self , self.onResponseGameOver))
- -- 玩家离线
- self:bindEvent(app.room , "onOtherDroppedResponse" , handler(self , self.onOtherDroppedResponse))
- -- 游戏设置里更换桌面
- self:bindEvent(app.room , "pdkNormalEvent_changeDesktop" , handler(self , self.onNormalChangeDesktop))
- -- 服务器通知更新当前玩家分数
- self:bindEvent(app.room , "onResponseUpdateScore" , handler(self , self.onResponseUpdateScore))
- -- 服务器通知当前玩家轮次
- self:bindEvent(app.room , "onResponseUpdateTurns" , handler(self , self.onResponseUpdateTurns))
- -- 显示大结算
- self:bindEvent(app.room , "pdkNormalEvent_show_game_over" , handler(self , self.onNormalShowGameOver))
- -- 断线重连
- self:bindEvent(app.room , "onResponseGameRecover" , handler(self , self.onPdkResponseGameRecover))
- -- 玩家请求快速开始广播
- self:bindEvent(app.room , "onBroadcastFastRequest", handler(self, self.onBroadcastFaststart))
- -- 快速开始成功
- self:bindEvent(app.room , "onFastStartSucc", handler(self, self.onFastStartSucc))
- --监听从后台进入游戏事件
- self:bindEvent(app, "applicationWillEnterForeground", handler(self, self.onApplicationWillEnterForeground))
- -- 玩家的GPS信息发生变化
- self:bindEvent(app.room , "onGpsChangeResponse" , handler(self , self.onGpsChangeResponse));
- --托管结果
- self:bindEvent(app.room , "onTuoGuanResponse",handler(self , self.onTuoGuanResponse));
- end
-
- function luzhouPdkRoomView:onNormalChangeDesktop( data )
- if data.idx >5 and data.idx<1 then return end
- self.ui.Items.ImageView_bg:loadTexture(string.format("pk_luzhoupdk/res/ui/zy_game/lzpdk_gamebg_%d.jpg", data.idx), 0)
- -- self.ui.Items.ImageView_2:setVisible(data.idx~=3)
- -- self.ui.Items.ImageView_3:setVisible(data.idx~=3)
- -- 水印
- --[[local gameInfo = app.room:getRoomInfo().nGameInfo
- local rdata = json.decode(gameInfo)
- local logostr = ""
- local logoJingDian = {
- [1] = "lzpdk_img_logo_jdhuang.png",
- [2] = "lzpdk_img_logo_jdlv.png",
- [3] = "lzpdk_img_logo_jdlan.png",
- [4] = "lzpdk_img_logo_jdhong.png",
- }
- local logoShiWu = {
- [1] = "pdk_img_logo_15huang.png",
- [2] = "pdk_img_logo_15lv.png",
- [3] = "pdk_img_logo_15lan.png",
- [4] = "pdk_img_logo_15hong.png",
- }
- if tonumber(rdata.gamerule) == PdkDef.GameTypes.Normal then
- logostr = logoJingDian[data.idx]--(data.idx==1 or data.idx==2 ) and "pdk_img_logo_jingdian_3d.png" or "pdk_img_logo_jingdian.png"
- else
- logostr = logoShiWu[data.idx]--(data.idx==1 or data.idx==2 ) and "pdk_img_logo_swz_3d.png" or "pdk_img_logo_swz.png"
- end
- local config = getSubGameConfig(GAME_IDS.luzhouPaoDeKuai)
- if config.logo then
- self.ui.Items.ImageView_logo:loadTexture(config.logo, 0)
- else
- self.ui.Items.ImageView_logo:loadTexture(logostr, 1)
- end--]]
- self:initLogo(data.idx)
- end
-
- -- 水印
- function luzhouPdkRoomView:initLogo(idx)
- if not (type(getSubGameRoomLogo) == 'function') then--大厅不支持此方法,则隐藏logo
- self.ui.Items.ImageView_logo:setVisible(false);
- return
- end
- local logofile = getSubGameRoomLogo(GAME_IDS.luzhouPaoDeKuai,1)
- if logofile then
- self.ui.Items.ImageView_logo:loadTexture(logofile)
- self.ui.Items.ImageView_logo:setVisible(true);
- else
- self.ui.Items.ImageView_logo:setVisible(false);
- end
- end
-
- -- 服务器通知玩家分数
- function luzhouPdkRoomView:onResponseUpdateScore( data )
- local msg = data.response
- for _,pdata in ipairs(msg.players) do
- local node = self:getPlayerNode(pdata.userId)
- if node then node:setScore(pdata.totalScore) end
- end
- end
- -- 玩家掉线
- function luzhouPdkRoomView:onOtherDroppedResponse( data )
- local msg = data.response
- local node = self:getPlayerNode(msg.nUserId)
- local pdata = app.room:getPlayer(msg.nUserId)
- if node then
- if msg.nDroppedStatus == 1 then
- node:setOffline(true)
- node:setOfflineTime(true,0)
- pdata.onlineStatus = 0
- elseif msg.nDroppedStatus == 0 then
- node:setOfflineTime(false)
- node:setOffline(false)
- pdata.onlineStatus = 1
- end
- end
- end
-
- function luzhouPdkRoomView:onUserExitResponseRoom( data )
- local function _exit( onEnd )
- local response = data.response -- 0: 不退出(回到子游戏), 1: 退出(回到大厅)
- if not self._isGameOver then
- if response.logoutFlag == 1 then
- --app:gotoView(import("luaScript.Views.Main.MainView"):new(GAME_IDS.luzhouPaoDeKuai))
- gotoMainView(GAME_IDS.luzhouPaoDeKuai)
- else
- --app:gotoView(import("luaScript.Views.Main.MainView"):new(GAME_IDS.luzhouPaoDeKuai))
- gotoMainView(GAME_IDS.luzhouPaoDeKuai)
- end
- end
- if onEnd and type(onEnd)=='function' then onEnd() end
- end
- self:addFunction(_exit)
- end
-
- function luzhouPdkRoomView:onDismissResponse( data )
- local __dis = function (onEnd)
- local response = data.response
- app.room:getRoomInfo().nDismissStateTime = response.timeLeft --剩余时间
- app.room:getRoomInfo().nDismissToTalTime = app.room:getRoomInfo().nDisbandTimeout or 60 --总的时间
- --显示解散(此标志会影响闹钟时间会冻住)
- app.room:getRoomInfo().nShowDismiss = true
-
- if response.operateType == 1 then
- if response.memberList ~= nil then
- for k,v in pairs(response.memberList) do
- if v.dismissState == 1 then
- --local view = import("pk_luzhoupdk.luaScript.Views.Room.Sub.luzhouPdkDismissView"):new(v.nUserId)
- local view = require("luaScript.Views.Room.RoomDismissView"):new(v.nUserId,app.room.roomInfo.memberList,response.timeLeft)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- return
- end
- end
- else
- --local view = import("pk_luzhoupdk.luaScript.Views.Room.Sub.luzhouPdkDismissView"):new(response.nUserId)
- local view = require("luaScript.Views.Room.RoomDismissView"):new(response.nUserId,app.room.roomInfo.memberList,response.timeLeft)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
- else
- local memberStatus={}
- if response.memberList ~= nil then
- for k,v in pairs(response.memberList) do
- table.insert(memberStatus,{userId = v.nUserId, status = v.dismissState})
- end
- else
- table.insert(memberStatus,{userId = response.nUserId, status = response.operateType})
- end
- app.room:dispatchEvent({name = GAME_EVENT.DISSMISS_UPDATE_STATUS , memberStatus = memberStatus});
- end
- end
- __dis()
- end
-
- -- 其他玩家进入
- function luzhouPdkRoomView:onResponseBroadcastLogin( data )
- self:addPlayerNode(data.pInfo)
- self.ui.Items.Button_invite:setVisible((not isReviewVersion()) and app.room:getPlayerNum()~=app.room:getRoomInfo().nMaxPlayCount)
- self:updateButtonPosition()
- if not isReviewVersion() and self.gpsComponent then
- --self.gpsComponent:updateUserInfos(app.room:getUserInfoList())
- --self:checkGpsDistance(data.pInfo.userId,true)
- end
-
- local myself = app.room:getMyself()
- if myself.playFlag>=1 then
- self:showSitdownBtn(false)
- else
- self:showSitdownBtn(true)
- end
-
- self:showFastStart(true)
- end
-
- -- 玩家离开房间
- function luzhouPdkRoomView:onResponseBroadcastLogout( data )
- local function __logout( onEnd )
- self:showFastStart(true)
- self:delPlayerNode(data.userId)
- local myself = app.room:getMyself()
- if myself.playFlag>=1 then
- self:showSitdownBtn(false)
- else
- self:showSitdownBtn(true)
- end
- --[[local roomInfo = app.room:getRoomInfo()
- if roomInfo and roomInfo.nGameStartCount == 0 then
- if not isReviewVersion() and self.gpsComponent then
- self.gpsComponent:updateUserInfos(app.room:getUserInfoList())
- self:checkGpsDistance()
- end
- end--]]
- if onEnd and type(onEnd)=='function' then onEnd() end
- end
- self:addFunction(__logout)
- end
-
- -- 玩家准备
- function luzhouPdkRoomView:onResponseUserReady( data )
- local userId = data.userId
- local node = self:getPlayerNode(userId)
- if node then node:setReady(true) end
- if app.room:isMyself(userId) then
- self:resetRoundData()
- app.room:addPlayer({playFlag=1, userId=userId})
- self:showSitdownBtn(false)
- end
- end
-
- -- 游戏开始
- function luzhouPdkRoomView:onResponseGameStart( data )
- local function __start( onEnd )
- local roomInfo = app.room:getRoomInfo()
- if roomInfo.nGameStartCount and roomInfo.nGameStartCount == 0 then
- self:onUpdatePlayerPos(data)
- end
- self._gameResult = false
- self._passGameResult = nil
- -- 离开房间不可点击
- self.ui.Items.Button_Leave:setEnabled(false)
- -- 取消玩家的准备标志
- for _,node in pairs(self._playerNodes) do
- node:setReady(false)
- node:cleanScore()
- app.room:updateFlag( node:getInfo().userId, 2 )
- end
- self:cleanSelfCards()
- self:cleanShowCards()
-
- self.ui.Items.Button_Ready:setVisible(false)
- self.ui.Items.Button_invite:setVisible(false)
- self:updateButtonPosition()
- self:updateInviteClubButton()
- --
- self:showTurnBtn(false)
- self:updateRoomInfo(roomInfo.nGameStartCount, roomInfo.nTotalGameNum)
- if onEnd and type(onEnd)=='function' then onEnd() end
- end
- self:addFunction(__start)
- end
-
- --更新玩家位置
- function luzhouPdkRoomView:onUpdatePlayerPos( data )
- if not data then return end
- local response = data.response
- if not response then return end
- -- 更新椅子号
- for _,v in pairs(response.players) do
- app.room:addPlayer({userId = v.nUserId, seatId = v.nSeatId})
- end
-
- -- 更新视图ID
- for _,v in pairs(response.players) do
- app.room:addPlayer({userId = v.nUserId, viewPos = app.room:transPos(v.nSeatId)})
- end
-
- --刷新房间玩家位置
- if response then
- --删除所有玩家节点
- for k,v in pairs(response.players) do
- self:delPlayerNode(v.nUserId)
- end
- self:initChatView()
- --重新添加玩家节点
- local players = app.room:getPlayers()
- for _, info in pairs(players) do
- self:addPlayerNode( info )
- end
- end
- end
-
- -- 给玩家发牌
- function luzhouPdkRoomView:onResponseSendCards( data )
- self:setRoomInfo(app.room:getRoomInfo())
- local function __sendCards( onEnd )
- self:resetRoundData()
- self._gameResult = false
- self._passGameResult = nil
- self:sendCards(data.response.cards)
- if onEnd and type(onEnd) == 'function' then onEnd() end
- end
- self:addFunction(__sendCards)
-
- local function __delay( onEnd )
- self.ui:runDelay(1, function() if onEnd and type(onEnd)=='function' then onEnd() end end)
- self:showJiPaiQi(true,data.response.cardPlayerInfo)
- end
- self:addFunction(__delay)
-
- local function __setBanker( onEnd )
- local bankerData = app.room:getPlayerCid(data.response.bankerSeat)
- if bankerData and bankerData.userId then
- for _,v in pairs( self._playerNodes ) do
- v:setBanker(v:getInfo().userId==bankerData.userId)
- v:setTurn(false)
- end
- end
- if onEnd and type(onEnd) == 'function' then onEnd() end
- end
- self:addFunction(__setBanker)
-
- local function __showTurn( onEnd )
- local bankerData = app.room:getPlayerCid(data.response.bankerSeat)
- if bankerData then -- 添加判断,不然CEST中,自动解散,点确认太快就进来发牌这里
- if app.room:isMyself(bankerData.userId) then
- --发完牌后庄家为自己,则不能操作不要按钮
- local isShowPass = false
- self:showTurnBtn(true,isShowPass,2)
- local node = self:getPlayerNodeVpos(1)
- if node then node:setTurn(true) end
- else
- self:showTurnBtn(false)
- local node = self:getPlayerNode(bankerData.userId)
- if node then node:setTurn(true) end
- end
- end
- if onEnd and type(onEnd) == 'function' then onEnd() end
- end
- self:addFunction(__showTurn)
-
- local function __showLeft( onEnd )
- local left = 13
- --if self.ruleType==2 then left = 15 end
- for uid,v in pairs(self._playerNodes) do
- v:showLeft(left)
- end
- if onEnd and type(onEnd) == 'function' then onEnd() end
- end
- self:addFunction(__showLeft)
- end
-
- -- 显示轮次时钟
- function luzhouPdkRoomView:showTurns( viewPos, cleanCards )
- for _,node in pairs(self._playerNodes) do
- local is = node:getInfo().viewPos==viewPos
- node:setTurn(is)
- -- if cleanCards==nil then cleanCards = true end
- if cleanCards then self:clearPosShow(viewPos) end
- if is then node:cleanPass() end
- end
- end
-
- -- 广播当前桌子轮次@userId@seatId@outFlag
- function luzhouPdkRoomView:onResponseUpdateTurns( data )
- local function __updateTurns( onEnd )
- local msg = data.response
- self.lastOutFlag = msg.outFlag
- local viewPos = app.room:transPos(msg.seatId)
- if viewPos == 1 then
- self:showTurns(viewPos, viewPos==1)
- else--这个逻辑过了1天god知道是干什么的
- local node = self:getPlayerNodeVpos(1)
- self:showTurns(viewPos, node:isShowPass()==false ) --如果要得起显示对方出的牌
- -- if self._lastOutPos == viewPos then --新起一轮
- -- self:showTurns(viewPos, false)
- -- else
- -- self:showTurns(viewPos, self._lastOutPos ~= viewPos)
- -- end
- end
- if onEnd and type(onEnd)=='function' then onEnd() end
- end
- self:addFunction(__updateTurns)
-
- local function __showOp( onEnd )
- local msg = data.response
- local viewPos = app.room:transPos(msg.seatId)
- local node = self:getPlayerNode(msg.userId)
- local delay = 0
- if msg.outFlag == 0 then--pass
- delay = 0.1
- local function _op()
- if viewPos == 1 then
- self:showPass()
- self:cleanLastCards(false)
- else
- end
- node:setLastOp(ETS.PASS, {})
- self:showTurnBtn(false)
- end
- -- self.ui:runDelay(0, _op)--不需要延时,同时显示出来?
- _op()
- else--show op
- local isShowPass = false
- if viewPos == 1 then--自己能出牌
- if msg.opType == 2 then--开启新的一轮
- self:cleanLastCards()
- self.lastOutFlag = -1
- end
- self:clearPosShow(1)
-
- --操作类型 0-只能pass 1-可以出牌也可以pass 2-必须出牌
- if msg.opType == 1 then
- isShowPass = true
- end
- end
- self:showTurnBtn( viewPos == 1 , isShowPass,msg.opType)
- end
- self.ui:runDelay(delay, function() if onEnd and type(onEnd)=='function' then onEnd() end end)
- end
- self:addFunction(__showOp)
- end
-
- -- 清理上一次的出牌
- function luzhouPdkRoomView:cleanLastCards(isClean)
- if isClean==nil then isClean = true end
- -- if self._lastOutPos > 0 then
- if isClean == true then
- -- self:clearPosShow(self._lastOutPos)
- end
- self._lastCards = {}
- self._lastOutType = 0
- self._lastOutPos = 0
- -- end
- end
-
- -- 玩家出牌成功
- function luzhouPdkRoomView:onResponseOutCards( data )
- local function __outCards( onEnd )
- local msg = data.response
- -- 清除上一次的提示牌
- self.ui.Items.Button_tip._tipCards = nil
- local isContinue = #self._lastCards>0 and self._lastOutType>0
- local tplayer = app.room:getPlayer(msg.userId)
- if not tplayer then
- if onEnd and type(onEnd)=='function' then onEnd() end
- return
- end
- local viewPos = app.room:getPlayer(msg.userId).viewPos
- if self._lastOutPos == viewPos or self._lastOutPos == 0 then --连出两轮
- for _,v in pairs(self._playerNodes) do
- v:cleanPass()
- end
-
- -- 清理上一次的出牌
- self:cleanLastCards()
- isContinue = false
- end
-
- app.room.isMustBomb = msg.isMustBomb
- if msg.isMustBomb and msg.isMustBomb == 1 then
- msg.cardType = ETS.NONE
- end
- --操作类型,0:pass 1:接牌
- if msg.opType == 1 then
- -- 缓存上次出的牌
- self._lastOutPos = viewPos
- self._lastOutType = msg.cardType
- app.room.lastOutType = msg.cardType
- self._lastCards = msg.cards
- self._opType = msg.opType
- end
-
- self:showTurns(0)
- local playerNode = self:getPlayerNode(msg.userId)
- playerNode:setLastOp(msg.cardType, msg.cards, isContinue)
- -- playerNode:showLastCards(msg.cards, msg.cardType, isContinue)
- if msg.cards and #msg.cards > 0 then
- PdkSoundHelper:playOut()
- end
- --玩家剩余牌
- local node = self:getPlayerNode(msg.userId)
- if node then
- if not node:isAlarm() and msg.leftNum==1 then
- --[[if self:getMode()==0 then
- if node:getInfo().viewPos==2 then PdkSoundHelper:single( node:getInfo().sex ) end
- elseif self:getMode()==1 then
- if node:getInfo().viewPos==3 then PdkSoundHelper:single( node:getInfo().sex ) end
- end--]]
- if node:getInfo().viewPos~=1 then
- PdkSoundHelper:single( node:getInfo().sex )
- end
- end
- node:showLeft(msg.leftNum)
- end
- if viewPos == 1 then--判断是否自己出牌
- self:showTurnBtn(false)
- for _,v in pairs(msg.cards) do
- self:removeCardNode(v)
- end
- if msg.leftNum==1 and not node:isAlarm() then
- PdkSoundHelper:single( node:getInfo().sex )
- end
- --还原不可点
- self:downCanotOuts(self:getHandCards(), false)
- self:resetCardsPos()
- end
- if onEnd and type(onEnd)=='function' then onEnd() end
- end
- self:addFunction(__outCards)
- --
- local function __delay( onEnd )
- self.ui:runDelay(0.5, function() if onEnd and type(onEnd)=='function' then onEnd() end end)
- self:showJiPaiQi(true,data.response.cardPlayerInfo)
- end
- self:addFunction(__delay)
- end
-
- -- 检测手上牌能否一次打出
- function luzhouPdkRoomView:checkOnceOut()
- --获取开房参数
- local roomInfo = app.room:getRoomInfo()
- --local gameInfo = roomInfo.nGameInfo
- --local ruleInfo = json.decode(gameInfo)
- --是否选择了AAA可为炸弹
- local isChoiceAAA = false
- --[[if ruleInfo and ruleInfo.specialRule and getNumBand(ruleInfo.specialRule, 0x0080)>0 then
- isChoiceAAA = true
- end--]]
-
- local handCards = self:getHandCards()
- local bCan, tp = PokerUtil:checkOnceOut(handCards)
- if bCan then--检测是否少带接完
- if tp==ETS.THREE_AND_ONE or tp==ETS.THREE then
- if not self.ruleIsNotEnough then
- return false, {}
- end
- end
- -- 是否拥有炸弹
- local allBombs = PokerUtil:getAllBomb(handCards, isChoiceAAA)
- bCan = #allBombs<=0
- end
- return bCan, handCards
- end
-
- -- 玩家自己显示要不起
- function luzhouPdkRoomView:showPass()
- self.ui.Items.imgTip:setOpacity(0)
- self.ui.Items.imgTip:setVisible(true)
- local ac = cc.Sequence:create(cc.FadeIn:create(0.2), cc.DelayTime:create(1), cc.FadeOut:create(0.2))
- self.ui.Items.imgTip:runAction(ac)
- --手牌变暗
- local anFunc = function ()
- self:resetSelect()
- for k,v in pairs(self._selfCards) do
- v:setNoTouch(true)
- end
- end
-
- local mingFunc = function ()
- for k,v in pairs(self._selfCards) do
- v:setNoTouch(false)
- end
- end
- local ac = cc.Sequence:create(cc.CallFunc:create(anFunc), cc.DelayTime:create(0.1), cc.CallFunc:create(mingFunc))
- self.cardRoot:runAction(ac)
- end
-
- -- 春天动画
- function luzhouPdkRoomView:showSpring()
- local node = PdkEffectHelper:getSpring()
- node:setPosition(cc.p(CENTER_X, CENTER_Y))
- self:addChild(node)
- if node.onEnter and type(node.onEnter)=='function' then
- node:onEnter()
- PdkSoundHelper:spring()
- end
- end
-
- -- 玩家出牌错误
- function luzhouPdkRoomView:onResponseOutCardsErr( data )
- local msg = data.response
- if msg.errFlag == 1 and app.room:isMyself(msg.userId) then
- self:showTurnBtn(true)
- end
- end
-
- -- 游戏单局结算
- function luzhouPdkRoomView:onResponseGameResult( data )
- -- 收到结算有动画,这个时候不让点击手牌
- self:setCardsNoTouch()
- local msg = data.response
- local maxCards = 0
- for _,v in pairs(msg.players) do
- local pdata = app.room:getPlayer(v.userId)
- v.unionid = pdata.unionid
- v.headimgurl = pdata.headimgurl
- v.gpsInfo = pdata.gpsInfo
- v.sex = pdata.sex
- v.openid = pdata.openid
- v.nickname = pdata.nickname
- v.areano = pdata.areano
- end
-
- local function __delay( onEnd )
- self.ui:runDelay(0.6, function() if onEnd and type(onEnd)=='function' then onEnd() end end)
- end
- self:addFunction(__delay)
-
- local function __pre( onEnd )
- -- app.room:dispatchEvent({name = "pdkNormalEvent_show_dissmiss_over"})
- self._gameResult = true
- for _,v in pairs(msg.players) do
- local node = self:getPlayerNode(v.userId)
- --找到本局炸弹得分
- local bombScore = 0
- if msg.playersBombScore then
- for i,j in pairs(msg.playersBombScore) do
- if j.userId and j.userId == v.userId then
- j.turnBombScore = tonumber(j.turnBombScore)
- bombScore = j.turnBombScore or 0
- end
- end
- end
- if node then
- node:setScore(v.totalScore, false,v.turnScore-bombScore)
- node:setTurn(false)
- end
- node:hideLeft()
- v.leftCards = v.leftCards or {}
- if #v.leftCards > maxCards then
- maxCards = #v.leftCards
- end
- end
-
- local isSpring = false
- for _,v in pairs(msg.players) do
- local node = self:getPlayerNode(v.userId)
- self:cleanSelfCards()
- self:showLeftCards(node:getInfo().viewPos, v.leftCards or {})
- if v.bSpring==1 then
- isSpring = true
- end
- end
- local delay = maxCards *0.02+0.5 + 1--加一秒钟延时显示确认,点确认时有可能还在飘分,防止飘分过程中点确认删掉了飘分动画影响最终分数显示
- if isSpring then
- --self.ui:runDelay(0.1, function() self:showSpring() end)
- end
- local function __onEnd()
- if onEnd and type(onEnd)=='function' then onEnd() end
- end
- self.ui:runDelay(delay, __onEnd )
-
- end
- self:addFunction(__pre)
-
- local function __showResult( onEnd )
- local msg = data.response
- --是不是最后一局
- local roomInfo = app.room:getRoomInfo()
- msg.isLast = roomInfo.nGameStartCount>=roomInfo.nTotalGameNum
- msg.isZhaniao = self.ruleZhaniao
- msg.ruleString = luzhouPdkRoomViewConfig.getRuleString(roomInfo.nGameInfo)
- if not msg.isLast then
- msg.isLast = msg.stopFlag==8 or msg.stopFlag==9
- end
- self._resultMsg = {}
- self._resultMsg.players = msg.players
- self._resultMsg.isLast = msg.isLast
- self._resultMsg.isZhaniao = msg.isZhaniao
- self._resultMsg.ruleString = msg.ruleString
- self._resultMsg.gameStartCount = msg.gameStartCount
- self._resultMsg.totalGamenum = msg.totalGamenum
- self._resultMsg.stopFlag = msg.stopFlag
- self._resultMsg.dipaiCard = msg.dipaiCard
-
- for _,v in pairs(self._playerNodes) do
- v:hideLeft()
- end
- self:showRstComfirm(true)
-
- if onEnd and type(onEnd)=='function' then onEnd() end
- end
- self:addFunction(__showResult)
- end
-
- -- 总结算
- function luzhouPdkRoomView:onResponseGameOver( data )
- setShowCountAll(true)
- app.room:dispatchEvent({name = GAME_EVENT.DISSMISS_CLOSE});
- local msg = data.response
- if msg.stopFlag == 9 or msg.stopFlag == 8 then
- self.isShowDismiss = true
- end
- for _,player in ipairs(msg.players) do
- local pdata = app.room:getPlayer(player.userId)
- player.unionid = pdata.unionid
- player.headimgurl = pdata.headimgurl
- player.gpsInfo = pdata.gpsInfo
- player.sex = pdata.sex
- player.openid = pdata.openid
- player.nickname = pdata.nickname
- player.areano = pdata.areano
- app.room:updateFlag( player.userId, 0 )
- end
- local function __over( onEnd )
- -- 缓存结算信息
- self._isGameOver = true
- self._gameOverData = msg
- local roomInfo = app.room:getRoomInfo()
- self._gameOverData.nShowTableId = roomInfo.nTableId
- app.room.roomInfo.nShowTableId = roomInfo.nTableId
- self._gameOverData.startCount = roomInfo.nGameStartCount
- self._gameOverData.totalCount = roomInfo.nTotalGameNum
- self._gameOverData.roomRule = luzhouPdkRoomViewConfig.getRuleString(roomInfo.nGameInfo)
- if self._gameResult==false or self.isShowDismiss then--已经展示过小结算后解散房间
- self:onNormalShowGameOver()
- end
-
- if onEnd and type(onEnd)=='function' then onEnd() end
- end
- self:addFunction(__over)
-
- app.club_php:dispatchEvent({name = GAME_EVENT.CLUB_BACK_ROOM})
- end
-
- --[[先显示小局结算,再显示总结算--]]
- function luzhouPdkRoomView:onNormalShowGameOver( data )
- self._gameResult = false
- local showFunc = function (msg)
- local view = import("pk_luzhoupdk.luaScript.Views.Room.Sub.luzhouPdkGameOverView"):new(msg)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- stopBGMusic()
- self:showGameOverAward()
- end
- if self._isGameOver and self._gameOverData then
- showFunc(self._gameOverData)
- end
- end
-
- ----------------------------------------------------------------------------------------------------------------------
- ----------------------------------------------------------------------------------------------------------------------
- -- 单局结算显示剩余牌
- function luzhouPdkRoomView:showLeftCards( pos, cards )
- self:showTurnBtn(false)
- if #cards <=0 then return end
- self:clearPosShow(pos)
- if pos==2 then
- local tmp = {}
- for _,v in ipairs(cards) do
- table.insert(tmp, 1, v)
- end
- cards = tmp
- end
- local root = cc.Node:create()
- local nodes = {}
- for i,card in ipairs(cards) do
- local node = self:genCard(card)
- local pt = cc.p(0, 25)
- if pos==1 then --self:getMode() == 0 or
- pt.x = pt.x + (i-1)*luzhouPdkRoomViewConfig.CARD_DLT_WIDTH*luzhouPdkRoomViewConfig.CARD_SCALE[2]
- node:setLocalZOrder(100+i)
- else
- if pos == 2 or (self:getMode() == 4 and pos == 3) then
- pt.x = pt.x - i*luzhouPdkRoomViewConfig.CARD_DLT_WIDTH*luzhouPdkRoomViewConfig.CARD_SCALE[2]
- node:setLocalZOrder(16-i)
- else
- pt.x = pt.x + i*luzhouPdkRoomViewConfig.CARD_DLT_WIDTH*luzhouPdkRoomViewConfig.CARD_SCALE[2]
-
- end
- end
- node:setScale(luzhouPdkRoomViewConfig.CARD_SCALE[2])
- node:setPosition(pt)
- root:addChild(node)
- node:setVisible(false)
- table.insert(nodes, node)
- end
- local dltWidth = 0
- local rpt = clone(luzhouPdkRoomViewConfig.SHOW_CARD_POS[self:getMode()][pos])
- if pos == 1 then
- else
- dltWidth = #cards/2*luzhouPdkRoomViewConfig.CARD_DLT_WIDTH*luzhouPdkRoomViewConfig.CARD_SCALE[2]
- end
- root:setPosition(rpt)
- self.cardRoot:addChild(root)
- table.insert(self._showCards[pos], root)
- for i,v in ipairs(nodes) do
- v:runAction(cc.Sequence:create(cc.DelayTime:create((i-1)*0.02), cc.CallFunc:create(function ()
- v:setVisible(true)
- end)))
- end
- end
-
- -- 清除某玩家的出牌
- function luzhouPdkRoomView:clearPosShow(pos)
- local pNode = self:getPlayerNodeVpos(pos)
- if pNode then pNode:cleanLastCards() end
- end
-
-
- -- 添加玩家节点
- function luzhouPdkRoomView:addPlayerNode( pInfo )
- if not pInfo then return end
- local node = self._playerNodes[pInfo.userId]
- if node then return end
- node = PdkPlayerNode:new()
- node:setPlayMode(self:getMode())
- local gameInfo = app.room:getRoomInfo().nGameInfo or ""
- local data = json.decode(gameInfo)
- local rule = tonumber(data.specialRule)
- node:setGameInfo(gameInfo)
- node:setMaxPlayerCount(app.room:getRoomInfo().nMaxPlayCount)
- node:setShowNum(getNumBand(rule, 0x0020)>0)--是否显示牌张数
- node:setInfo(pInfo)
-
- node:setReady(pInfo.playFlag==1)
- node:setOffline((pInfo.onlineStatus and pInfo.onlineStatus==0))
- node:setOfflineTime((pInfo.onlineStatus and pInfo.onlineStatus==0),pInfo.offtime or 0)
- node:setHost(pInfo.userId==app.room:getRoomInfo().nRoomOwnedUid)
- if luzhouPdkRoomViewConfig.PLAYER_POS[self:getMode()] and luzhouPdkRoomViewConfig.PLAYER_POS[self:getMode()][pInfo.viewPos] then
- node:setPosition(luzhouPdkRoomViewConfig.PLAYER_POS[self:getMode()][pInfo.viewPos])
- end
- self._playerNodes[pInfo.userId] = node
- node:setLocalZOrder(10)
- self.ui.Items.toolPanel:addChild(node)
- -- self.panelMenu:getParent():addChild(node)
- -- 将玩家加入到chatView
- self.chatView:addPlayer(pInfo.userId)
- end
-
- -- 删除玩家节点
- function luzhouPdkRoomView:delPlayerNode( uid )
- if self._gameResult or self._isGameOver then return end
- local node = self._playerNodes[uid]
- if not node then return end
- node:removeFromParent()
- self._playerNodes[uid] = nil
- -- 将玩家从chatView移除
- self.chatView:delPlayer(uid)
- end
-
- -- 获取玩家节点
- function luzhouPdkRoomView:getPlayerNode( uid )
- return self._playerNodes[uid]
- end
-
- -- 根据视图获取玩家节点
- function luzhouPdkRoomView:getPlayerNodeVpos( viewPos )
- for _,v in pairs(self._playerNodes) do
- if v:getInfo().viewPos==viewPos then
- return v
- end
- end
- return nil
- end
-
- ----------------------------------------------------------------------------
- -- 检查拖牌节点
- function luzhouPdkRoomView:checkTouches( pt )
- local rect = nil
- local node = nil
- for i,v in ipairs(self._selfCards) do
- if (not tolua.isnull(v) and v) and v:getRect() and cc.rectContainsPoint(v:getRect(), pt) then
- node = v
- break
- end
- end
- return node
- end
- ----------------------------------------------------------------------------
- function luzhouPdkRoomView:touchBegan( pt )
- if self._gameResult then return end
- self._selectCards = {}
- local node = self:checkTouches(pt)
- if node and node:getVal()>0 then
- self._selectCards[node:getVal()] = node
- end
- self:doSelectColor()
- end
-
- ----------------------------------------------------------------------------
- function luzhouPdkRoomView:touchMoved( pt )
- if self._gameResult then return end
- local node = self:checkTouches(pt)
- if node and self._selectCards[node:getVal()]==nil then
- self._selectCards[node:getVal()] = node
- end
- self:doSelectColor()
- end
-
- ----------------------------------------------------------------------------
- function luzhouPdkRoomView:touchEnded( pt )
- if self._gameResult then return end
- self:doSelect()
- if pt.y > luzhouPdkRoomViewConfig.NORMAL_HEIGHT + luzhouPdkRoomViewConfig.CARD_HEIGHT/2 and (not self:checkTouches(pt)) then
- for _,node in pairs(self._selfCards) do
- if node:isDown() then node:setNormal() end
- end
- end
- end
-
- ----------------------------------------------------------------------------
- function luzhouPdkRoomView:doSelect()
- local i = 0
- for _,node in pairs(self._selectCards) do
- i = i + 1
- if not tolua.isnull(node) and node and node.getParent and node:getParent() then
- if node:isDown() then
- node:setNormal()
- else
- node:setDown()
- end
- if i==1 then PdkSoundHelper:selectSnd() end
- end
- end
- end
-
- ----------------------------------------------------------------------------
- function luzhouPdkRoomView:doSelectColor()
- for _,node in pairs(self._selectCards) do
- if not tolua.isnull(node) and node and node.getParent and node:getParent() then
- node:setDownColor()
- end
- end
- end
-
- ----------------------------------------------------------------------------
- function luzhouPdkRoomView:resetSelect()
- local i = 0
- for _,v in pairs(self._selfCards) do
- i = i + 1
- if v:isDown() then
- v:setNormal()
- v:setNormalColor()
- if i==1 then PdkSoundHelper:selectSnd() end
- end
- end
- self._selectCards = {}
- end
-
- function luzhouPdkRoomView:setCardsNoTouch()
- for _,v in pairs(self._selfCards) do
- v:setNoTouch(true)
- v:setNormal()
- v:setNormalColor()
- end
- self:resetSelect()
- end
-
- ----------------------------------------------------------------------------
- -- 获取选择的牌的集合
- function luzhouPdkRoomView:getSelected()
- local sel = {}
- for _,v in pairs(self._selfCards) do
- if v:isDown() then table.insert(sel, v:getVal()) end
- end
- return sel
- end
-
- -- 添加牌节点监听
- function luzhouPdkRoomView:addTouchesListener()
- local function onTouchBegan(touch, event)
- local locationInNode = self:convertToWorldSpace(touch:getLocation())--触点
- self:touchBegan(locationInNode)
- return true
- end
-
- local function onTouchMoved(touch, event)
- local locationInNode = touch:getLocation()
- self:touchMoved(locationInNode)
- end
-
- local function onTouchEnded(touch, event)
- local locationInNode = touch:getLocation()
- self:touchEnded(locationInNode)
- end
-
- local listener1 = cc.EventListenerTouchOneByOne:create()
- listener1:setSwallowTouches(false)
- listener1:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN )
- listener1:registerScriptHandler(onTouchMoved,cc.Handler.EVENT_TOUCH_MOVED )
- listener1:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCH_ENDED )
- local eventDispatcher = self.cardRoot:getEventDispatcher()
- eventDispatcher:addEventListenerWithSceneGraphPriority(listener1, self)
- end
-
- -- 发牌
- function luzhouPdkRoomView:sendCards( cards_ )
- local cards = pokerSortPdkCards(cards_)
- local pos = 1
- local CardsCount = #cards
- for i,card in ipairs(cards) do
- local ac = cc.Sequence:create(cc.DelayTime:create(i*0.02), cc.CallFunc:create(function ()
- self:sendOneCard(card.cid, i, pos, i==CardsCount, CardsCount)
- if self:getMode()==0 then
- if i==CardsCount then self:showOtherCards(true) end
- end
- end))
- self.cardRoot:runAction(ac)
- end
- end
-
- -- 发一张牌
- function luzhouPdkRoomView:sendOneCard( card, i, pos, islast, allCount )
- -- local node = self:genCard(card)
- local node = self:genCard(-1)--back
- node.cid = card
- node:setScale(luzhouPdkRoomViewConfig.CARD_SCALE[pos])--luzhouPdkRoomViewConfig.CARD_SCALE_START
- node:setLast(islast)
- local endX = CENTER_X + (allCount-allCount/2+1)*luzhouPdkRoomViewConfig.CARD_DLT_WIDTH*luzhouPdkRoomViewConfig.CARD_SCALE[1]
- local pt = cc.p(0, 0)
- if pos ~= 1 then
- pt = clone(luzhouPdkRoomViewConfig.PLAYER_POS[self:getMode()][pos])
- else
- pt.x = CENTER_X
- local midIdx = allCount/2
- if i<=midIdx then--左边
- pt.x = pt.x - (midIdx-i-1)*luzhouPdkRoomViewConfig.CARD_DLT_WIDTH*luzhouPdkRoomViewConfig.CARD_SCALE[1]
- else--右边
- pt.x = pt.x + (i-midIdx+1)*luzhouPdkRoomViewConfig.CARD_DLT_WIDTH*luzhouPdkRoomViewConfig.CARD_SCALE[1]
- end
- pt.x = pt.x - luzhouPdkRoomViewConfig.CARD_WIDTH/2*luzhouPdkRoomViewConfig.CARD_SCALE[1]
-
- pt.y = luzhouPdkRoomViewConfig.CARD_POS[self:getMode()][pos].y
- end
- node:setPosition(cc.p(endX, pt.y))
- node:setLocalZOrder(i)
- node:setOpacity(0)
- self.cardRoot:addChild(node)
-
- local ac = nil
- if pos ~=1 then
- ac = cc.Sequence:create(cc.Spawn:create(cc.MoveTo:create(0.05, pt), cc.ScaleTo:create(0.7, luzhouPdkRoomViewConfig.CARD_SCALE[pos])), cc.CallFunc:create(function ()
- node:removeFromParent()
- end))
- node:runAction(ac)
- else
- ac = cc.Sequence:create(cc.Spawn:create(cc.MoveTo:create(0.05, pt), cc.FadeIn:create(0.1)), cc.CallFunc:create(function ()
- table.insert(self._selfCards, node)
- PdkSoundHelper:playSend()
- end), cc.DelayTime:create((i)*0.01), cc.CallFunc:create(function() node:setCard(node.cid) end ))
- node:runAction(ac)
- end
- end
-
- -- 发一张牌没有动画
- function luzhouPdkRoomView:sendOneCardNoAct( card, i, pos, islast, allCount )
- local node = self:genCard(card)
- node:setScale(luzhouPdkRoomViewConfig.CARD_SCALE[pos])
- node:setLast(islast)
- local pt = cc.p(0, 0)
- if pos ~= 1 then
- pt = clone(luzhouPdkRoomViewConfig.CARD_POS[self:getMode()][pos])
- else
- local midIdx = math.floor(allCount/2)
- if i<midIdx then--左边
- pt.x = CENTER_X - (midIdx-i-1)*luzhouPdkRoomViewConfig.CARD_DLT_WIDTH*luzhouPdkRoomViewConfig.CARD_SCALE[pos]
- else--右边
- pt.x = CENTER_X + (i-midIdx+1)*luzhouPdkRoomViewConfig.CARD_DLT_WIDTH*luzhouPdkRoomViewConfig.CARD_SCALE[pos]
- end
- pt.x = pt.x - luzhouPdkRoomViewConfig.CARD_WIDTH/2*luzhouPdkRoomViewConfig.CARD_SCALE[pos]
- pt.y = luzhouPdkRoomViewConfig.CARD_POS[self:getMode()][pos].y
- end
- node:setPosition(pt)
- node:setLocalZOrder(i)
- self.cardRoot:addChild(node)
- table.insert(self._selfCards, node)
- end
-
- -- 创建一张牌
- function luzhouPdkRoomView:genCard( card )
- local node = PdkCardNode:new()
- node:setCard(card)
- node:setSelectedHeight(luzhouPdkRoomViewConfig.SELECTED_HEIGHT)
- node:setNormalHeight(luzhouPdkRoomViewConfig.NORMAL_HEIGHT)
- return node
- end
-
- -- 从手牌中获取一张牌
- function luzhouPdkRoomView:getCardNode( card )
- if card > 0x00 and card <= 0x3d then
- for _,v in pairs(self._selfCards) do
- if v:getVal()==card then return v end
- end
- return nil
- else
- return nil
- end
- end
-
- -- 根据牌ID移除一张手牌,并重新调整手牌位置
- function luzhouPdkRoomView:removeCardNode( card )
- local node = self:getCardNode(card)
- if not node then return end
- for i=#self._selfCards,1,-1 do
- if self._selfCards[i]:getVal()==card then
- table.remove(self._selfCards, i)
- break
- end
- end
- node:removeFromParent()
- --reset pos
- self:resetCardsPos()
- end
-
- -- 获取当前手牌
- function luzhouPdkRoomView:getHandCards()
- local handCards = {}
- for _,v in pairs(self._selfCards) do
- table.insert(handCards, v:getVal())
- end
- return handCards
- end
-
- -- 重置手牌位置
- function luzhouPdkRoomView:resetCardsPos( )
- if #self._selfCards<=0 then return end
- local mode = self:getMode()
- local pos = 1
- local scale = luzhouPdkRoomViewConfig.CARD_SCALE[pos]
- local dtpx = (16 - #self._selfCards)/2*luzhouPdkRoomViewConfig.CARD_DLT_WIDTH*scale
- local allCount = #self._selfCards
- local midIdx = allCount/2
- for i,v in ipairs(self._selfCards) do
- if not tolua.isnull(v) then
- local pt = cc.p(CENTER_X, 0)
- if i<midIdx then--左边
- pt.x = pt.x - (midIdx-i-1)*luzhouPdkRoomViewConfig.CARD_DLT_WIDTH*scale
- else--右边
- pt.x = pt.x + (i-midIdx+1)*luzhouPdkRoomViewConfig.CARD_DLT_WIDTH*scale
- end
- pt.x = pt.x - luzhouPdkRoomViewConfig.CARD_WIDTH/2*scale
- pt.y = luzhouPdkRoomViewConfig.CARD_POS[self:getMode()][pos].y
- v:setPosition(pt)
- v:setLast(i==allCount)
- v:setNormal()
- end
- end
- end
-
- -- 提示对应的牌
- function luzhouPdkRoomView:tipCards( cards, show )
- if show ~= nil then return "" end
- self:resetSelect()
- self:resetCardsPos()
- for _,v in pairs(cards) do
- local node = self:getCardNode(v.cid)
- if node and node:getVal()>0 then
- self._selectCards[node:getVal()] = node
- node:setDown()
- end
- end
- end
-
- -- 清除所有牌
- function luzhouPdkRoomView:cleanSelfCards()
- for _,v in pairs(self._selfCards) do
- if not tolua.isnull(v) and v and v:getParent() then v:removeFromParent() end
- end
- self._selfCards = {}
- end
- function luzhouPdkRoomView:cleanShowCards()
- for _,v in pairs(self._showCards) do
- for _,vv in pairs(v) do
- if vv and vv:getParent() then
- vv:removeFromParent()
- end
- end
- end
- self._showCards = {{},{},{},{}}
- for _,v in pairs(self._playerNodes) do
- if v then v:cleanLastCards() end
- end
- end
-
- -- 二人玩显示另外一组牌
- function luzhouPdkRoomView:showOtherCards(is)
- if is then
- self.imgOtherCards:setVisible(true)
- local num = 16
- if self.ruleType==2 then num = 15 end
- self.txtOtherCards:setString(string.format("剩余%d张", num))
- else
- self.imgOtherCards:setVisible(false)
- end
- end
-
- --发起申请
- function luzhouPdkRoomView:onClickFastStart(sender)
- playBtnEffect()
- local request = PdkMessage.FastStartRequest:new()
- request.result = 1
- self.ui:sendMsg(app.room, "requestFastStartGame", request)
- end
-
- --是否显示2/3人快速开始按钮
- function luzhouPdkRoomView:showFastStart(is)
- local roomInfo = app.room:getRoomInfo()
- if not roomInfo.nGameInfo then
- return
- end
- if roomInfo.gameStatus and roomInfo.gameStatus > luzhouPdkRoomViewConfig.GameStatus.GAME_STATE_INIT and roomInfo.gameStatus <= luzhouPdkRoomViewConfig.GameStatus.GAME_STATE_GAME_OVER then
- self.ui.Items.Button_fastStart:setVisible(false)
- else
- local playerCount = app.room:getPlayerNum()
-
- local gameInfo = json.decode(roomInfo.nGameInfo or "")
- if true == is and playerCount < roomInfo.nMaxPlayCount and roomInfo.nGameStartCount <= 0 and gameInfo.playnum == 1 then
- self.ui.Items.Button_fastStart:setVisible(playerCount == 2 or playerCount == 3)
- else
- self.ui.Items.Button_fastStart:setVisible(false)
- end
- end
-
- end
-
- -- 服务器广播快速开始
- function luzhouPdkRoomView:onBroadcastFaststart(data)
- local response = data.response
- local isRemove = false
- if response.nUserId and response.nStatus then
- if response.nStatus == 3 or response.nStatus > 4 then
- isRemove = true
- end
- end
-
- if not isRemove then
- for _,v in ipairs(response.pList) do
- if v.nStatus == 3 or v.nStatus > 4 then
- isRemove = true
- end
- end
- end
-
- if response.timeOut <=0 then
- isRemove = true
- end
-
- logD("luzhouPdkRoomView:onBroadcastFaststart isRemove:"..table.tostring(isRemove)..";self.fastStartRequestView = "..table.tostring(self.fastStartRequestView))
- if self.fastStartRequestView == nil then
- if isRemove then
- return ""
- end
-
- local requesterId = 0
- for _,v in ipairs(response.pList) do
- if v.nStatus == 1 then
- requesterId = v.nUserId
- end
- end
-
- if requesterId <= 0 then
- return ""
- end
-
- local view = import("pk_luzhoupdk.luaScript.Views.Room.luzhouPdkRequestStartView"):new(requesterId)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- view:showItems(response)
- app:showWaitDialog(view)
- self.fastStartRequestView = view
- else
- if isRemove then
- local userInfo = app.room.roomInfo.memberList[response.nUserId]
- self.fastStartRequestView:removeFromParent()
- self.fastStartRequestView = nil
- if userInfo then
- local u = json.decode(userInfo.userInfo)
- local txt = string.format("玩家【%s】拒绝立即开局", u.nickname)
- showTooltip(txt)
- end
- app.room.roomInfo.quickStartInfo = nil
- self:showFastStart(true)
- else
- self.fastStartRequestView:updateView(response)
- end
- end
- end
-
- function luzhouPdkRoomView:onFastStartSucc(data)
- if self.fastStartRequestView then
- self.fastStartRequestView:removeFromParent()
- self.fastStartRequestView = nil
- end
- self:showFastStart(false)
- --self.playerView:setPlayerVisible(false)
- --self:updateRoomBaseData()
- --刷新房间玩家位置
- if data.response then
- --删除所有玩家节点
- for k,v in pairs(data.response.pList) do
- self:delPlayerNode(v.nUserId)
- end
-
- self:initChatView()
-
- --重新添加玩家节点
- local players = app.room:getPlayers()
- for _, info in pairs(players) do
- self:addPlayerNode( info )
- end
- end
- end
-
- --是否显示快速开始页面
- function luzhouPdkRoomView:isShowFastStartView()
- --快速开始数据
- local roomInfo = app.room:getRoomInfo()
- if roomInfo then
- local fastData = {}
- fastData.response = {}
- fastData.response.nStatus = roomInfo.userFastStartStatus
- fastData.response.timeOut = roomInfo.fastStartTimeout
- fastData.response.pList = {}
- if roomInfo.fastStartPlayersStatus then
- for k,v in pairs(roomInfo.fastStartPlayersStatus) do
- local playerList = {}
- if v.fastStartStatus and v.fastStartStatus == 1 then
- --玩家发起申请
- fastData.response.nUserId = v.userId
- end
- playerList.nStatus = v.fastStartStatus
- playerList.nUserId = v.userId
- table.insert(fastData.response.pList, playerList)
- end
- end
-
- logD("luzhouPdkRoomView:isShowFastStartView roomInfo = "..table.tostring(roomInfo))
- logD("luzhouPdkRoomView:isShowFastStartView fastData = "..table.tostring(fastData))
- self:onBroadcastFaststart(fastData)
- end
- end
-
- function luzhouPdkRoomView:onApplicationWillEnterForeground()
- --从后台返回游戏,但未重连,此时数据未改变
- local roomInfo = app.room:getRoomInfo()
- if roomInfo and roomInfo.nGameStartCount and roomInfo.nGameStartCount <= 0 then
- --从后台返回游戏时,如果已经开始游戏,则不处理快速开始view
- self:isShowFastStartView()
- end
- end
-
- --解析记牌器数据
- function luzhouPdkRoomView:calcJiPaiQiData(data)
- if not data or data == "" then
- return ""
- end
- local jxData = json.decode(data)
- if jxData then
- return jxData
- end
- end
-
- --设置记牌器显示或隐藏
- function luzhouPdkRoomView:showJiPaiQi(vis,data)
- if vis and vis == true then
- local roomInfo = app.room:getRoomInfo()
- local gameInfo = roomInfo.nGameInfo
- if not gameInfo then return end
- local ruleInfo = json.decode(gameInfo)
- local playernum = app.room:getPlayerNum()
- if ruleInfo and ruleInfo.specialRule and getNumBand(ruleInfo.specialRule, 0x0001)>0 and playernum>2 then
- self.ui.Items.Layout_jipaiqi:setVisible(true)
-
- local leftcardData = self:calcJiPaiQiData(data)
- if not data then return end
- for i=1,14 do
- if leftcardData[tostring(i)] then
- local nodeStr = string.format("Lable_leftCard_%d",i)
- self.ui.Items[nodeStr]:setText(leftcardData[tostring(i)])
- end
- end
- else
- self.ui.Items.Layout_jipaiqi:setVisible(false)
- end
- else
- self.ui.Items.Layout_jipaiqi:setVisible(false)
- end
- end
-
- -- 检测玩家与其他玩家之间的距离
- -- 如果不传参数,则检测所有玩家相互之间的距离
- --[[function luzhouPdkRoomView:checkGpsDistance(curUserId,isOpenGpsView)
- if self.gpsComponent then
- self.gpsComponent:updateUserInfos(app.room:getUserInfoList())
- end
- if self.gpsComponent then
- local isDanger = self.gpsComponent:checkGpsDistance(curUserId)
- if isDanger and isOpenGpsView then
- self:onClickButtonGps()
- showTooltip("玩家距离过近或者未开启GPS!")
- end
- end
- end--]]
-
- -- 服务器广播玩家数据发生变化
- function luzhouPdkRoomView:onGpsChangeResponse(data)
- logD("luzhouPdkRoomView:onGpsChangeResponse()")
- if not data or not data.nUserId then
- return
- end
- local roomInfo = app.room:getRoomInfo()
- local nUserId = data.nUserId
- logD("luzhouPdkRoomView:onGpsChangeResponse()", tostring(nUserId))
-
- --self:checkGpsDistance(nUserId,roomInfo.nGameStartCount==0)
- end
-
- function luzhouPdkRoomView:initGpsComponent()
- if self.isRecordScene then return end--回放场景直接return
- local versionCode = getAppVersionCode()
- versionCode = tonumber(versionCode) or 0
-
- logD("luzhouPdkRoomView:initGpsComponent() versionCode = ", versionCode)
-
- if isReviewVersion() then
- self.ui.Items.btnGps:setVisible(false)
- return
- end
-
- local function exitRoomCallback()
- local isGameStart = app.room:getRoomInfo().nGameStartCount > 0
- if isGameStart then
- app.room:requestDismissRoom(1)
- else
- self.ui:sendMsg(app.room, "callLeaveRequest");
- end
- end
-
- -- 创建 gps 组件
- --self.gpsComponent = RoomGpsComponent:new(self.ui.Items.btnGps)
- self.gpsComponent = import("luaScript.Views.Room.RoomGpsComponentView"):new(4,self.ui.Items.btnGps,exitRoomCallback,exitRoomCallback)
- self.gpsComponent:setLocalZOrder(100)
- self:addChild(self.gpsComponent)
-
- -- GPS 按钮
- self.ui.Items.btnGps:registerClick(handler(self , self.showGpsView))
-
- -- 我的GPS数据发生变化时检测是否需要通知服务器
- --self:bindEvent(app, "onGpsInoChanged", handler(self, self.checkMyGpsNeedUpdate))
-
- --self.isInitCheckGps = false
-
- -- 进入时检测一遍我的GPS数据是否需要更新
- --self:checkMyGpsNeedUpdate()
- end
-
- -- 检查服务器记录的我的GPS数据是最新的,如果不是,则请求更新
- --[[function luzhouPdkRoomView:checkMyGpsNeedUpdate(event)
- logD("luzhouPdkRoomView:checkMyGpsNeedUpdate()")
-
- if self.isInitCheckGps and not event then
- return
- end
-
- self.isInitCheckGps = true
-
- local nMyUserId = app.user.loginInfo.uid
- local myMemberInfo = app.room:getUserInfo(nMyUserId) or nil
- if myMemberInfo then
- local userInfo = json.decode(myMemberInfo)
- if userInfo then
- local gpsInfo = userInfo.gpsInfo
- local isNewest = app.user:isGpsInfoNewest(gpsInfo)
- logD("luzhouPdkRoomView:checkMyGpsNeedUpdate() gpsInfo is isNewest = ", tostring(isNewest))
- if not isNewest then
- app.room:onGpsChangeRequest();
- else
- logD("luzhouPdkRoomView:checkMyGpsNeedUpdate() gpsInfo is newest")
- end
- else
- logD("luzhouPdkRoomView:checkMyGpsNeedUpdate() userInfo is nil")
- end
- else
- logD("luzhouPdkRoomView:checkMyGpsNeedUpdate() myMemberInfo is nil")
- end
- end--]]
-
- -- 更新所有玩家的信息到GPS组件
- function luzhouPdkRoomView:updateAllGpsInfo()
- if self.isRecordScene then return end--回放场景直接return
- local userInfoList = app.room:getUserInfoList()
- if self.gpsComponent then
- self.gpsComponent:updateUserInfos(userInfoList)
- end
- end
- ---
- -- 初始化大结算再来一局
- -- @return
- --
- function luzhouPdkRoomView:initPlayGameAgain()
- local strGameInfo = app.room.roomInfo.nGameInfo
- local isInClub = app.club_php.clubID and app.club_php.clubID ~= 0
- if not isInClub then
- logD("IPlayGameAgain.initPlayGameAgain", "当前玩家不在亲友圈内,不能再来一局");
- return
- end
-
- local clubGameInfo = json.decode(strGameInfo) or {}
- if not clubGameInfo.ruleid then
- logD("IPlayGameAgain.initPlayGameAgain", "游戏包间id不存在,不能再来一局");
- return
- end
-
- dd.IPlayGameAgain.setAgainGameBaoJianId(clubGameInfo.ruleid)
- end
-
- --显示隐藏托管
- function luzhouPdkRoomView:showTuoGuan(isShow)
- if isShow then
- if not self.tuoguanView then
- self.tuoguanView = import("pk_luzhoupdk.luaScript.Views.Room.PdkRoomTuoGuanView"):new()
- self:addChild(self.tuoguanView)
- end
- else
- if self.tuoguanView and not tolua.isnull(self.tuoguanView) then
- self.tuoguanView:removeFromParent()
- self.tuoguanView = nil
- end
- end
- end
-
- --托管结果协议
- function luzhouPdkRoomView:onTuoGuanResponse(data)
- local function runTuoGuanResponse(onEnd)
- log("2000000000-luzhouPdkRoomView - (runTuoGuanResponse)")
- local response = data.response
-
- local userCnt = response.userCnt;
- if userCnt then
- for k,v in pairs(userCnt) do
- local aiStatus = v.aiStatus;
- local nUserID = v.nUserID;
- local viewId = app.room:getViewIdByUserId(nUserID)
- local isTuoGuan = aiStatus == 1;
- if app.room:isMyself(nUserID) then
- if isTuoGuan then
- self:showTuoGuan(true)
- self.isTuoGuan = true
- else
- self:showTuoGuan(false)
- self.isTuoGuan = false
- end
-
- end
- local node = self:getPlayerNodeVpos(viewId)
- if node then
- node:setTuoGuan(isTuoGuan)
- end
- end
- end
-
-
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-luzhouPdkRoomView - addCallBack(runTuoGuanResponse)")
-
- self:addFunction(runTuoGuanResponse)
- end
- --获取托管状态
- function luzhouPdkRoomView:getTuoGuanState()
- return self.isTuoGuan or false
- end
- ---
- -- 显示抽奖界面
- --
- function luzhouPdkRoomView:showGameOverAward()
- if not (dd and dd.IGameOverAward) then
- return
- end
- self:runDelay(0.1, function ( )
- -- 延迟0.1秒执行,可能有些游戏弹大结算的时候还未收到抽奖消息
- dd.IGameOverAward.showAwardView();
- end)
- end
- ---
- -- 检测是否可以解散房间
- -- @param
- -- @return
- --
- function luzhouPdkRoomView:checkCanDismiss( )
- local onCanDismissCallback = function (info)
- local nUserId = app.room:getMyUserId()
- local roomInfo = app.room.roomInfo or {}
- local canDismiss = (tonumber(info.canDismiss or 1) == 1) or roomInfo.nRoomOwnedUid == nUserId or dd.IClub.isAdmin()
- if roomInfo.nGameStartCount == 0 and roomInfo.nRoomOwnedUid ~= nUserId then
- canDismiss = false
- end
- self:onCanDismissCallback(canDismiss)
- end
-
- if dd.IClub.getCanDismiss then
- local canDismiss = dd.IClub.getCanDismiss(onCanDismissCallback)
- if canDismiss then
- onCanDismissCallback({canDismiss = canDismiss})
- end
- end
- end
-
- function luzhouPdkRoomView:onCanDismissCallback(canDismiss)
- if self.ui.Items.Button_Dismiss then
- self.ui.Items.Button_Dismiss:setEnabled(canDismiss)
- end
- end
-
- return luzhouPdkRoomView
|