|
- require("luaScript.Views.Room.RoomFunctions")
- local MJRoomToolView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomToolView")
- local MJRoomMessageView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomMessageView")
- local MJRoomPlayerView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomPlayerView")
- local MJDefine=MJFramework.MJImport("mj.luaScript.MJDefine")
- local MJHandCardView=MJFramework.MJImport("mj.luaScript.Views.Game.MJHandCardView")
- local MJRoomXiaoJuView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomXiaoJuView")
- local MJRoomDaJuView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomDaJuView")
- local MJRoomDismissView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomDismissView")
- local MJRoomDirection=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomDirection")
- local MJMessage=MJFramework.MJImport("mj.luaScript.Protocol.MJMessage")
- local MJ=MJFramework.MJImport("mj.luaScript.Views.Game.MJ")
- local MJWanFa=MJFramework.ImportWanFa("luaScript.SubGameDefine.MaJiang.MJWanFa")
- local MJAnimationCompnent=MJFramework.MJImport("mj.luaScript.Views.Compnent.MJAnimationCompnent")
- local MJFunction=MJFramework.MJImport("mj.luaScript.MJFunction")
- local MJSound = MJFramework.MJImport("mj.luaScript.MJSound")
-
- local MJRoomView = MJFramework.MJFrameworkClassImprot("mj.luaScript.Views.Room.MJRoomView")
- local ncmajRoomView = class("ncmajRoomView", MJRoomView)
-
- local zhongNiaoTime=1.33
- local HU_EFFECT_TAG = 100
-
- function ncmajRoomView:ctor()
- ncmajRoomView.super.ctor(self)
- self.operates = {}
-
- if app.systemSetting.info.viewType == MJDefine.DesktopType.TwoD then -- viewType只保存2d 3d类型 mj_desktop_2d_mjType保存2d麻将类型
- local value = loadUserInfo("mj_ncmaj_desktop_2d_mjType")
- if value=="" or not value then
- value = MJDefine.DesktopType.TwoDL
- saveUserInfo("mj_ncmaj_desktop_2d_mjType", value)
- end
- self.desktopType = value
- else
- self.desktopType = app.systemSetting.info.viewType
- end
- MJDefine.MJConfig = MJDefine.loadMJConfig(self.desktopType)
- end
-
- function ncmajRoomView:loadUi()
- local ui = loadUI("mj_ncmaj/res/ui_fangjian/mj_ncmaj_roomView.ui")
- self.ui = ui
- self:addChild(ui)
- end
-
- function ncmajRoomView:onEnter()
- ncmajRoomView.super.onEnter(self)
-
- -- 初始化听牌组件
- self:initTingCardView();
- -- 初始化听牌按钮,动态创建的
- self:initTingBtnView();
- self:setButtonTingInfoVisible(false);
-
- --获取是否贴鬼杠和是否自动对齐
- self:setCheckDefault()
- self:doSound()
- end
-
- function ncmajRoomView:onExit()
- ncmajRoomView.super.onExit(self)
- self:cleanCache()
- end
-
- function ncmajRoomView:cleanCache()
- local preload = package.loaded
- for k, v in pairs(package.loaded or {}) do
- local res1 = string.find( k, "mj.luaScript") or 0
- local res2 = string.find( k, "mj_ncmaj.luaScript") or 0
- if res1 > 0 or res2 > 0 then
- package.loaded[k] = nil
- end
- end
- local temp = {
- "mj/res/ui/zy_fangjian/mj.plist",
- "mj/res/ui/zy_fangjian/mahjong/mj_2d_cards.plist",
- "mj/res/ui/zy_fangjian/mj_2d.plist",
- "mj/res/ui/zy_fangjian/mahjong/mj_3d_cards_1.plist",
- "mj/res/ui/zy_fangjian/mahjong/mj_3d_cards_2.plist",
- "mj/res/ui/zy_fangjian/mj_2d_gold.plist",
- "mj_ncmaj/res/zy_fangjian/mj_2d_cards_l.plist",
- }
- -- 删除缓存,防止与其他麻将资源混淆(例如南充麻将的墨绿大麻将和邻水麻将的金黄大麻将)
- for i, v in ipairs(temp) do
- cc.SpriteFrameCache:getInstance():removeSpriteFramesFromFile(v)
- end
- end
-
- function ncmajRoomView:doSound()--1 普通话 2 方言
- local cacheLan = "mj_language"..(MJDefine.GameID or app.gameId)
- --saveUserInfo(cacheLan,1)--恒定为普通话
- local defaultValue = tonumber(loadUserInfo(cacheLan)) or 1
- saveUserInfo(cacheLan,defaultValue)
- MJSound.setSoundType(defaultValue)
- end
-
- function ncmajRoomView:setCheckDefault()
- MJDefine.isAutomatic = true
- end
-
-
- -- 一键截屏
- function ncmajRoomView:onClickButtonShot( sender )
- playBtnEffect()
- showScreenShot()
- end
-
- --隐藏俱乐部
- function ncmajRoomView:hideClub()
- -- self.ui.Items.Button_Club:setVisible(false)
- if self.clubView and not tolua.isnull(self.clubView) then
- self.clubView:removeFromParent()
- self.clubView=nil
- end
- end
-
- --更换桌布(同维度)
- function ncmajRoomView:changeGameBg(isUpdateViewType)
- if isUpdateViewType then
- if app.systemSetting.info.viewType == MJDefine.DesktopType.TwoD then --更新2D麻将类型 金色还是绿色
- local value = loadUserInfo("mj_ncmaj_desktop_2d_mjType") --or MJDefine.DesktopType.TwoD
- if value=="" or not value then
- value = MJDefine.DesktopType.TwoDL
- saveUserInfo("mj_ncmaj_desktop_2d_mjType", value)
- end
- logD("changeGameBg value:"..value)
- self.desktopType = value
- else
- self.desktopType = app.systemSetting.info.viewType
- end
- self:loadTextureCache()
- logD("changeGameBg"..self.desktopType)
- end
-
- local defaultValue = tonumber(loadUserInfo("ncmaj_mj_desktop_group")) or 1
- local bgData = MJDefine.CHANGE_GAME_BG[defaultValue]
- if self.desktopType==MJDefine.DesktopType.TwoD or self.desktopType==MJDefine.DesktopType.TwoDGold or self.desktopType==MJDefine.DesktopType.TwoDL then
- self.ui.Items.ImageView_bg:loadTexture(bgData['2d'])
- else
- self.ui.Items.ImageView_bg:loadTexture(bgData['3d'])
- end
- end
-
- function ncmajRoomView:defaultState()
- --队列初始化
- self.callbackQueue = {}
- self.callbackRunning = false
- self.playerView:setOffLineVisible(false)
- self.playerView:setPlayerVisible(false)
-
- if self.waitOperates and #self.waitOperates>0 then
- for k,v in pairs(self.waitOperates) do
- v:removeFromParent()
- end
- end
- self.waitOperates = {}
-
- self:resetGame()
- end
-
- function ncmajRoomView:loadTextureCache()
- ncmajRoomView.super.loadTextureCache(self)
- -- local defaultValue = tonumber(loadUserInfo("luzhou_mj_majhong")) or 1
-
- loadSpriteFrameFile("mj_ncmaj/res/zy_fangjian/mj_operateEffect.plist")
- loadSpriteFrameFile("mj_ncmaj/res/zy_fangjian/effect_guafeng.plist")
- loadSpriteFrameFile("mj_ncmaj/res/zy_fangjian/effect_xiayu.plist")
- end
-
-
- function ncmajRoomView:initGameButton()
- --点击空白
- self.ui.Items.Layout_Touch:registerClick(nil,function()
- -- 隐藏个人信息
- self.playerView:removePlayerInfoView()
- self.toolView:setMenuVisible(false)
- if self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:hideOperateItem()
- end
-
- self.toolView:hideRule()
- self:setTingCardVisible(false);
- self:setTingCardViewVisible(false);
- end)
-
- --隐藏听牌模板
- self.ui.Items.Item_Ting:setVisible(false)
-
- self.ui.Items.Button_Ting_Info:setVisible(false);
- --self.ui.Items.Button_Ting_Info:registerClick(handler(self, self.onBtnTingInfoClicked))
-
- self.toolView.ui.Items.Button_Face:setPosition(cc.p(1208*g_radio_x,(322+25)*g_radio_y))
- self.toolView.ui.Items.Button_Voice:setPosition(cc.p(1208*g_radio_x,(237+30)*g_radio_y))
- end
-
- function ncmajRoomView:initGpsComponent()
- if cc.Application:getInstance():getTargetPlatform() == 0 or app.room.roomInfo.isEapCreate == 1 then
- self.ui.Items.Button_GPS:setVisible(false)
- return
- end
-
- local versionCode = getAppVersionCode()
- versionCode = tonumber(versionCode) or 0
-
- logD("ncmajRoomView:initGpsComponent() versionCode = ", versionCode)
- logD("ncmajRoomView:initGpsComponent() isReviewVersion = ", isReviewVersion()==true and 1 or 0)
-
-
- self.singleComponent = import("luaScript.Views.Room.RoomSinglePowerComponent"):new(self.ui.Items.ImageView_Single,self.ui.Items.LoadingBar_Power)
-
- if isReviewVersion() then -- or versionCode < 110
- self.ui.Items.Button_GPS:setVisible(false)
- return
- end
-
- local function exitRoomCallback()
- local isGameStart = app.room.roomInfo.nGameStartCount > 0
- if isGameStart then
- app.room:requestDismissRoom(1)
- else
- self.ui:sendMsg(app.room, MJDefine.MJEvent.CallLeaveRequest)
- end
- end
-
- self.gpsComponent = import("luaScript.Views.Room.RoomGpsComponentView"):new(4,self.ui.Items.Button_GPS,exitRoomCallback,exitRoomCallback)
- self:addChild(self.gpsComponent)
-
- -- GPS 按钮
- self.ui.Items.Button_GPS:registerClick(handler(self, self.showGpsView))
- end
-
- --通知庄家可以爆牌
- function ncmajRoomView:onBankerBaoPai(data)
- local function runBankerBaoPai(onEnd)
- local myUserId = app.room:getMyUserId()
- local viewId = app.room:getViewIdByUserId(myUserId)
-
- if data.response.nUserId == myUserId then
- self:showBaoJiao()
- self.playerHandCards[viewId]:setOutCardEnable(false)
- end
-
- if onEnd then
- onEnd()
- end
- end
- self:addCallBack(runBankerBaoPai)
- end
-
- --广播玩家爆牌
- function ncmajRoomView:onBaoPai(data)
- local myUserId = app.room:getMyUserId()
- if data.response.isBaoPai == 1 then
- local effect=MJAnimationCompnent.CreateBaoEffect()
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
-
- local userInfo=app.room:getUserInfoByViewId(viewId)
- --爆牌音效
- MJSound.PlayBaoSound(userInfo.sex)
-
- if effect then
- self.ui.Items.Layout_Player:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end
- if myUserId == data.response.nUserId then
- --self.playerHandCards[viewId]:lockHandCard(true)
- self.playerHandCards[viewId]:setBaoPai(1)
- -- self.playerHandCards[viewId]:setOutCardEnable(false)
- else
- --self.playerHandCards[viewId]:setOutCardEnable(true)
- end
- self.playerHandCards[viewId]:setOutCardEnable(true)
- self.playerView:playBaoAnim(viewId)
- elseif data.response.isBaoPai == 2 then--博自摸
- local effect=MJAnimationCompnent.CreateBoZiMoEffect()
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- local myUserId = app.room:getMyUserId()
- local userInfo=app.room:getUserInfoByViewId(viewId)
- --爆牌音效
- MJSound.PlayBaoSound(userInfo.sex)
- if effect then
- self.ui.Items.Layout_Player:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end
- if myUserId == data.response.nUserId then
- self.playerHandCards[viewId]:lockHandCard(true)
- else
- end
- self.playerView:showBoZiMo(viewId,true)
- elseif self.reShowBao and self.reShowBao == true then--过爆
- self.guobao = true--重连过爆要显示打出的第一张牌
- end
- if myUserId == data.response.nUserId then--报牌后可以躺
- --[[local operate={}
- operate.Datas = {}
- local toperate={}
- toperate.opType=MJDefine.MJOperateType.OPREATE_PLACE_CARD
- toperate.opCard=0
- toperate.redNum = 0
- table.insert(operate.Datas,toperate)--]]
- self.playerHandCards[MJDefine.MyViewId]:showOperate(data.response.operates)
- --报牌情况下,只能打听牌
- if data.response.isBaoPai == 1 then
- self.playerHandCards[MJDefine.MyViewId]:tangCardEnabled(true)
- self.playerHandCards[MJDefine.MyViewId]:setIsTanging(false)
- end
- self.playerHandCards[MJDefine.MyViewId]:setOutCardEnable(true)
- end
- if app.room:getMyUserId() == data.response.nUserId then
- self:hideBaoJiao()
- end
- --[[if app.room:getMyUserId() == data.response.nUserId and (data.response.isBaoPai == 1 or data.response.isBaoPai == 2) then
- local gameInfo =json.decode(app.room.roomInfo.strGameInfo);
- --if gameInfo.tingpai > 0 then
- --self.ui.Items.Button_Ting_Info:setVisible(true);
- self:setButtonTingInfoVisible(true)
- app.room.roomInfo.memberList[data.response.nUserId].nTingStatus = MJDefine.MJTingStatus.Ting;
- self.ui:sendMsg(app.room, MJDefine.MJEvent.Ting)
- self.isTing = true;
- --end
- end--]]
- end
-
- function ncmajRoomView:onGameSendCardResponse()
- --发牌的时候清除桌面上的飘
- self.ui.Items.Layout_Effect_luobo:removeAllChildren()
- local function runGameSendCardResponse(onEnd)
- log("2000000000-ncmajRoomView - runGameSendCardResponse()" )
- self:hidePiao()
-
- local myUserId = app.room:getMyUserId()
- for k,v in pairs(app.room.roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- if self.playerHandCards[viewId] then
- self.playerHandCards[viewId]:createHandCards(v.handCards)
- self.playerHandCards[viewId]:resetHandCards()
- end
-
- if v.isBaoPai == 1 and myUserId == v.nUserId then
- --self.playerHandCards[viewId]:showBaoPai()
- self:showBaoJiao()
- end
- end
-
- --self.playerHandCards[MJDefine.MyViewId]:initSwapCardTouchEvent()
- MJAnimationCompnent.CreateStartSendCards(self.playerHandCards,onEnd)
- self.isTang = false
-
- -- if onEnd then
- -- onEnd()
- -- end
- self.toolView:showTuoGuan(app.room.roomInfo.hosting==1)
- end
- log("2000000000-ncmajRoomView - addCallBack(runGameSendCardResponse)" )
- self:addCallBack(runGameSendCardResponse);
- end
-
- function ncmajRoomView:onUserReadyResponse(response)
- ncmajRoomView.super.onUserReadyResponse(self,response)
-
- local myUserId = app.room:getMyUserId()
- if response and response.nUserId==myUserId then
- self.playerView:clearBao()
- self.playerView:clearAllPiao()
- --self.playerView:clearAllBoZiMo()
- self.playerView:clearAllQue()
- self.playerView:clearAllBai()
- self:setTingCardVisible(false);
- self:setTingCardViewVisible(false);
- if self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:setQueType(-1)--设置缺牌类型为空
- end
- app.room.roomInfo.luoboCards = nil
- -- local roomInfo = app.room.roomInfo
- -- for k,v in pairs(roomInfo.memberList) do
- -- self.ui.Items.Layout_Player:removeChildByTag(HU_EFFECT_TAG)
- -- end
- end
-
- --self.ui.Items.Button_Ting_Info:setVisible(false);
- self:setButtonTingInfoVisible(false)
- end
-
-
- -- 广播桌子上所有玩家庄家起手操作 这里其实是发牌
- function ncmajRoomView:onBankerOutCard(data)
-
- --[[ -- 庄家uid
- , defVar("nUserId", VT_Int, 0)
- -- 庄家操作类型
- , defVar("mainOpCode", VT_Short, 0)
- --庄家是否需要出牌0不需要 1:需要
- , defVar("IsShouldOutCard", VT_UChar, 0)--]]
- local function runOnBankerOutCard(onEnd)
- logE("ncmajRoomView onBankerOutCard :"..table.tostring(data.response))
- -- if not data.response.nUserId then
- -- showTooltip("庄家起手操作nUserId is not exist")
- -- end
-
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- local card= data.response.card
- local operates=data.response.operates
- local nSeatId=data.response.nSeatId
-
- -- app.room.roomInfo.outCardUserId = data.response.nUserId
-
- if self.playerHandCards[viewId] then
- self.playerHandCards[viewId]:onGetCard(operates,card)
- end
- --检测定缺牌
- self.playerHandCards[MJDefine.MyViewId]:checkQueAndDisableOtherCard()
-
- --先清除所有操作按钮
- --self.playerHandCards[MJDefine.MyViewId]:hideOperate()
- self.playerHandCards[MJDefine.MyViewId]:hideOperateItem()
-
- self.playerHandCards[MJDefine.MyViewId]:showOperate(operates,card,true)
-
- if viewId == MJDefine.MyViewId then
- --self.ui.Items.Button_Ting_Info:setVisible(false)
- self:setButtonTingInfoVisible(false)
- if operates and table.nums(operates)>0 then
- self.operates = operates
- else
- self.operates = {}
- end
-
- if self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:setTing(false)
- local player = app.room.roomInfo.memberList[data.response.nUserId]
- if player and player.isBaoPai==1 then
- --self.playerHandCards[MJDefine.MyViewId]:lockHandCard(true)
- end
- end
-
- app.room:dispatchEvent({name = MJDefine.MJEvent.SelectCard})
- app.room:dispatchEvent({name = MJDefine.MJEvent.PushTing})
- -- app.room:dispatchEvent({name = MJDefine.MJEvent.ShowTing})
-
- end
-
-
-
- -- local myUserId = app.room:getMyUserId()
- -- if data.response.nUserId == myUserId then
- -- if self.playerHandCards[MJDefine.MyViewId] then
- -- self.playerHandCards[MJDefine.MyViewId]:pushTing()
- -- end
- -- end
-
- self:updateGameNums()
-
- self.direcionView:updateDirection(nSeatId)
-
- if onEnd then
- onEnd()
- end
- end
-
- log("2000000000-ncmajRoomView - addCallBack(runOnBankerOutCard)")
- self:addCallBack(runOnBankerOutCard);
-
- end
-
- function ncmajRoomView:onAfterDingQue(data)
- local function runOnAfterDingQue(onEnd)
- logE("ncmajRoomView onAfterDingQue :"..table.tostring(data.response))
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- local card= data.response.card
- local operates=data.response.operates
- local nSeatId=data.response.nSeatId
- self.playerHandCards[MJDefine.MyViewId]:hideOperateItem()
- self.playerHandCards[MJDefine.MyViewId]:showOperate(operates,card,true)
-
- if viewId == MJDefine.MyViewId then
- --self.ui.Items.Button_Ting_Info:setVisible(false)
- self:setButtonTingInfoVisible(false)
- if operates and table.nums(operates)>0 then
- self.operates = operates
- self.playerHandCards[MJDefine.MyViewId]:setOutCardEnable(true)
- else
- self.playerHandCards[MJDefine.MyViewId]:setOutCardEnable(true)
- self.operates = {}
- end
- if self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:setTing(false)
- end
- app.room:dispatchEvent({name = MJDefine.MJEvent.SelectCard})
- app.room:dispatchEvent({name = MJDefine.MJEvent.PushTing})
- end
- self:updateGameNums()
- self.direcionView:updateDirection(nSeatId)
- self.playerHandCards[MJDefine.MyViewId]:checkQueAndDisableOtherCard()
- self.playerHandCards[MJDefine.MyViewId]:initTouchEvent()
- if onEnd then
- onEnd()
- end
- end
- self:addCallBack(runOnAfterDingQue)
- end
-
- function ncmajRoomView:onTurnOutCard(data)
- local function runOnTurnOutCard(onEnd)
- logE("MJRoomView:runOnOutCard(), response = ", table.tostring(data.response))
- log("2000000000-MJRoomView - runOnOutCard")
-
- if app.room.roomInfo.lastOutViewId~=MJDefine.MyViewId then
- self.playerHandCards[MJDefine.MyViewId]:setOutCardEnable(true)
- end
- -- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- -- local card= data.response.card
- -- if self.playerHandCards[viewId] then
- -- self.playerHandCards[viewId]:createOutCards(card)
- -- end
-
- if onEnd then
- onEnd()
- end
- end
-
- log("2000000000-MJRoomView - addCallBack(runOnTurnOutCard)")
- self:addCallBack(runOnTurnOutCard)
- end
-
- --出牌成功
- function ncmajRoomView:onOutCardSuccess(data)
- logE("ncmajRoomView:onOutCardSuccess(), response = ", table.tostring(data.response))
- local function runOnOutCardSuccess(onEnd)
- log("2000000000-ncmajRoomView - runOnOutCardSuccess---------")
-
- -- app.room.roomInfo.outCardUserId = data.response.nUserId
-
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- local card= data.response.card
- local operates=data.response.operates
- local typr = operates.opType
-
- if operates and table.nums(operates)>0 then
- self.operates = operates
- else
- self.operates = {}
- end
-
- local function callback()
- -- app.room.roomInfo.lastOutViewId = nil
- self.playerHandCards[MJDefine.MyViewId]:showOperate(operates,card)
- --self.playerHandCards[MJDefine.MyViewId]:checkQueAndDisableOtherCard()
- self.playerHandCards[MJDefine.MyViewId]:checkBaoAndDisableCard()
- self.playerHandCards[MJDefine.MyViewId]:setTing(false)
- if onEnd then
- onEnd()
- end
- end
- -- self.lastOutCard = card
-
-
- if self.playerHandCards[viewId] then
- --(viewId~=MJDefine.MyViewId or player.isBaoPai == 1) and app.room.roomInfo.lastOutViewId~=MJDefine.MyViewId
-
- if viewId==MJDefine.MyViewId then
- local player = app.room.roomInfo.memberList[data.response.nUserId]
- self.playerHandCards[viewId]:setTing(false)
- --点击爆牌的时候 前端已经打出牌 要判断上次出牌的人是不是自己 避免重复出牌
- if ((player.isBaoPai==1 or player.isBaoPai==2 or (self.isTang and self.isTang == true) or (self.guobao and self.guobao == true))
- and app.room.roomInfo.lastOutViewId~=MJDefine.MyViewId) or app.room.roomInfo.hosting == 1 then
- self.guobao = nil
- self.playerHandCards[viewId]:onOutCard(card,callback)
- --音效
- local userInfo=app.room:getUserInfoByViewId(viewId)
- if userInfo then
- --MJSound.PlayMJSound(userInfo.sex,card)
- end
- elseif self.needDeleteOutCard and true == self.needDeleteOutCard then
- self.needDeleteOutCard = nil
- uploadLogs("mjduopai")
- self.playerHandCards[viewId]:onOutCard(card,callback)
- else
- callback()
- end
-
- local gameInfo = json.decode(app.room.roomInfo.strGameInfo);
- --if gameInfo.tingpai > 0 then
- self._isOutCardTingCheck = true;
- self.ui:sendMsg(app.room,MJDefine.MJEvent.Ting)
- --end
- else
- self.playerHandCards[viewId]:onOutCard(card,callback)
- end
- app.room:dispatchEvent({name = MJDefine.MJEvent.OutCardFalg, value=card ,viewId=viewId})
- else
- callback()
- end
-
- app.room.roomInfo.lastOutViewId = viewId
-
- end
- log("2000000000-ncmajRoomView - addCallBack(runOnOutCardSuccess)")
- self:addCallBack(runOnOutCardSuccess)
- end
-
- --已经发送了过操作,此时就算再勾选贴鬼碰,也不会显示操作
- function ncmajRoomView:onSendGuo()
- --发牌重置,主要用于贴鬼碰/杠
- MJDefine.isSendGuo = false
- self.operates = {}
- end
-
- -- 操作成功
- function ncmajRoomView:onOperationCodeSuccess(data)
- local function runOnOperationSuccess(onEnd)
- local response = data.response
- local nUserId = response.nUserId
- local opType = response.opType
- local opCard = response.opCard
-
- local bIsOutCard = response.isNeedOutCard > 0
- local fromSeatId = response.fromSeatId
- local isNeedTang = response.isNeedTang or 0
- local redNum = 0 or response.redNum
- local viewId = app.room:getViewIdByUserId(nUserId)
- local fromViewId = app.room:getViewIdBySeatId(fromSeatId)
- local opSeatId = app.room:getSeatIdByViewId(viewId)
- local fromUserId = app.room:getUserIdBySeatId(fromSeatId)
- if self.playerHandCards[viewId] then
- --组合一下牌
- local groups={
- self:getChangeGruopDatas({opType=opType, opCard=opCard, redNum = redNum, targetSeatId=opSeatId, opUserId=fromUserId})
- }
- --删除手中对应的牌
- local deleteCards
- for k,v in pairs(groups) do
- if v.showType==MJDefine.MJGroupType.Peng then
- self.playerHandCards[viewId]:removeHandCardByNum(opCard,2,v.redNum)
- elseif v.showType==MJDefine.MJGroupType.Chi then
- --TODO:吃的牌删除两张
-
- elseif v.showType==MJDefine.MJGroupType.AnGang
- or v.showType==MJDefine.MJGroupType.MAnGang then
- self.playerHandCards[viewId]:removeHandCardByNum(opCard,4,v.redNum)
- else
- if opType==MJDefine.MJOperateType.OPREATE_BAGANG then
- self.playerHandCards[viewId]:removeHandCardByNum(opCard,1,v.redNum)
- else
- self.playerHandCards[viewId]:removeHandCardByNum(opCard,3,v.redNum)
- end
- end
- end
- --删除出去的牌 遍历哪些操作需要删除牌
- for k,v in pairs(MJDefine.MJOperateNeedRemoveCard) do
- if v==opType then
- self.playerHandCards[fromViewId]:removeOutCard(opCard)
- break
- end
- end
-
- if opType==MJDefine.MJOperateType.OPREATE_BAGANG then
- self.playerHandCards[viewId]:buGang(opCard,redNum)
- else
- self.playerHandCards[viewId]:createGroupCards(groups)--创建显示的牌
- end
-
- self.playerHandCards[viewId]:resetHandCards()
- self.playerHandCards[viewId]:hideOperate()
- self.playerHandCards[viewId]:setOutCardEnable(bIsOutCard)
-
- self.direcionView:updateDirection(app.room:getSeatIdByViewId(viewId))
- end
-
- local function guafengxiayuEffect()
- local effect
- if (opType==MJDefine.MJOperateType.OPREATE_ZHIGANG) or (opType==MJDefine.MJOperateType.OPREATE_BAGANG) or
- (opType==MJDefine.MJOperateType.OPREATE_MINGGANG) then
- effect=MJAnimationCompnent.createGuaFengEffect()
- MJSound.PlayWindSound()
- elseif (opType==MJDefine.MJOperateType.OPREATE_ANGANG) then
- effect=MJAnimationCompnent.createXiaYuEffect()
- MJSound.PlayRainSound()
- end
- if effect then
- self.ui.Items.Layout_Player:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end
- end
- --[[if (opType==MJDefine.MJOperateType.OPREATE_ZHIGANG) or (opType==MJDefine.MJOperateType.OPREATE_BAGANG) or
- (opType==MJDefine.MJOperateType.OPREATE_MINGGANG) or (opType==MJDefine.MJOperateType.OPREATE_ANGANG) then
- guafengxiayuEffect()
- else--]]
- --播放动画
- local effect=MJAnimationCompnent.CreateOperareEffect(opType)--,onEnd)
- if effect then
- self.ui.Items.Layout_Player:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- -- else
- -- if onEnd then
- -- onEnd()
- -- end
- end
- --end
- --音效
- local userInfo=app.room:getUserInfo(nUserId)
- if userInfo then
- MJSound.PlayOperateSound(userInfo.sex,opType)
- end
-
-
- if viewId == MJDefine.MyViewId then
- self.playerHandCards[MJDefine.MyViewId]:setTing(false)
- self:setTingCardViewVisible(false)
- --self.ui.Items.Button_Ting_Info:setVisible(false)
- self:setButtonTingInfoVisible(false)
- self.operates={}
- --碰等操作后检查定缺牌
- --self.playerHandCards[MJDefine.MyViewId]:checkQueAndDisableOtherCard()
- self.playerHandCards[MJDefine.MyViewId]:checkBaoAndDisableCard()
- end
-
- --删除等待操作的显示
- if self.waitOperates and #self.waitOperates>0 then
- for k,v in pairs(self.waitOperates) do
- v:removeFromParent()
- end
- self.waitOperates={}
- end
- --[[if viewId == MJDefine.MyViewId and opType==MJDefine.MJOperateType.OPREATE_PENG then
- local cards = {opCard}
- self.playerHandCards[viewId]:cardEnabled(cards, true)
- end--]]
-
- -- 取消操作按钮
- self.playerHandCards[MJDefine.MyViewId]:hideOperate()
- if viewId == MJDefine.MyViewId and isNeedTang == 1 then--碰牌后可以躺
- local operate={}
- operate.Datas = {}
- local toperate={}
- toperate.opType=MJDefine.MJOperateType.OPREATE_PLACE_CARD
- toperate.opCard=0
- toperate.redNum = 0
- table.insert(operate.Datas,toperate)
- self.playerHandCards[MJDefine.MyViewId]:showOperate(operate)
- end
-
- if onEnd then
- onEnd()
- end
- end
- self:addCallBack(runOnOperationSuccess)
- end
-
-
- function ncmajRoomView:test()
- self.playerHandCards={}
-
- self.playerHandCards[MJDefine.MyViewId] = MJHandCardView:new(MJDefine.MyViewId)
-
- self:addChild(self.playerHandCards[MJDefine.MyViewId])
-
- self.playerView = MJRoomPlayerView:new()
- self:addChild(self.playerView)
-
- end
-
- --飘状态停止
- function ncmajRoomView:stopDirection()
- self.direcionView:stopAllActions()
- self.direcionView.ui.Items.ImageView_Dir_Down:setVisible(false)
- self.direcionView.ui.Items.ImageView_Dir_Up:setVisible(false)
- self.direcionView.ui.Items.ImageView_Dir_Left:setVisible(false)
- self.direcionView.ui.Items.ImageView_Dir_Right:setVisible(false)
- self.direcionView.ui.Items.Text_Time:setString(string.format("%02d",0))
- --self.direcionView.ui.Items.Text_Leave_Card_Num:setText("72")
- end
-
- function ncmajRoomView:onGameReconnection()
- ncmajRoomView.super.onGameReconnection(self)
- local roomInfo = app.room.roomInfo
- local gameInfo=json.decode(roomInfo.strGameInfo)
- local piaoMode = gameInfo.piaomode
-
- local myUserId = app.room:getMyUserId()
- -- 托管状态恢复
- 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;
- self.playerView:showTuoGuanByViewId(viewId,isTuoGuan)
- end
-
- local isMyGetCard = false
- local meIsHu = false
- if roomInfo.nStatus and roomInfo.nStatus>=MJDefine.GameStatus.GAME_STATUS_WAIT_BANKER_START and roomInfo.nStatus<MJDefine.GameStatus.GAME_STATUS_GAME_OVER then
- -- 游戏开始后才显示托管状态
- self.toolView:showTuoGuan(app.room.roomInfo.hosting == 1)
- end
- if (roomInfo.nStatus==MJDefine.GameStatus.GAME_STATUS_ROUND_OVER or roomInfo.nStatus==MJDefine.GameStatus.GAME_STATUS_GAME_OVER) and
- roomInfo.memberList[myUserId].nPlayerFlag ~= 1 then
- local fpSeatId = -1
- for k,v in pairs(roomInfo.memberList) do
- if v.result == MJDefine.MJGameHuType.HU_DIANPAO or v.result == MJDefine.MJGameHuType.HU_QIANGGANG then
- fpSeatId = v.dpSeatId
- end
- end
- --显示哪些玩家胡牌
- for i,player in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(player.nUserId)
- local nSeatId = app.room:getSeatIdByUserId(player.nUserId)
- local effect
- if player.result>0 and self.playerHandCards[viewId] then
- effect = MJAnimationCompnent.CreateHuOrderEffect(player.result,player.huOrder)
- if myUserId == player.nUserId then
- --self.playerHandCards[viewId]:removeHandCard(player.huCard)
- --self.playerHandCards[viewId]:resetHandCards()
- self.playerHandCards[viewId]:createHandCards(player.huCard)
- self.playerHandCards[viewId]:moveLastCard()
- else
- --self.playerHandCards[viewId]:removeHandCard(player.huCard)
- --self.playerHandCards[viewId]:resetHandCards()
- self.playerHandCards[viewId]:createOpenHandCards(player.huCard)
- self.playerHandCards[viewId]:moveLastOpenCard()
- end
- end
- if nSeatId == fpSeatId then
- effect = MJAnimationCompnent.CreateFangPaoEffect()
- end
-
- if effect then
- self.ui.Items.Layout_Effect:addChild(effect)
- effect:setTag(HU_EFFECT_TAG)
- effect:setLocalZOrder(1000)
- local pos = self.playerHandCards[viewId]:getAnimationPostion()
- if viewId==MJDefine.PlayerViewType.My then
- effect:setPosition(pos.x,pos.y-60)
- elseif viewId==MJDefine.PlayerViewType.Left then
- effect:setPosition(pos.x-20,pos.y)
- elseif viewId==MJDefine.PlayerViewType.Right then
- effect:setPosition(pos.x+10,pos.y)
- elseif viewId==MJDefine.PlayerViewType.Top then
- effect:setPosition(pos.x,pos.y+10)
- end
- end
-
- if gameInfo.luobonum and gameInfo.luobonum > 0 then
- local effect1 = MJAnimationCompnent.CreateLoBoLabel(player.luoboNum or 0)
- local pos = self.playerHandCards[viewId]:getAnimationPostion()
- if viewId==MJDefine.PlayerViewType.My then
- effect1:setPosition(pos.x+130,pos.y-60)
- elseif viewId==MJDefine.PlayerViewType.Left then
- effect1:setPosition(pos.x-20-30,pos.y-70)
- elseif viewId==MJDefine.PlayerViewType.Right then
- effect1:setPosition(pos.x+10-30,pos.y-70)
- elseif viewId==MJDefine.PlayerViewType.Top then
- effect1:setPosition(pos.x+130,pos.y+10-50)
- end
- self.ui.Items.Layout_Effect:addChild(effect1)
- end
- --显示飘状态
- self.playerView:showPiao(viewId,tonumber(player.isPiao))
- end
- elseif roomInfo.nStatus==MJDefine.GameStatus.GAME_STATUS_WAIT_PIAO then
- self:stopDirection()
- for i,player in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(player.nUserId)
- if myUserId == player.nUserId then
- if tonumber(player.canPiao) == 1 then -- 操作过飘了
- self.playerView:showPiao(viewId,tonumber(player.isPiao))
- else
- --随飘或者固定飘的第一局,恢复显示飘
- if piaoMode == 1 or (piaoMode == 2 and roomInfo.nGameStartCount == 1) then--可以飘 还没有飘 显示飘按钮
- self:showPiao()
- end
- end
- else
- self.playerView:showPiao(viewId,tonumber(player.isPiao))
- end
- if tonumber(player.isPiao) > 0 then
- local effect = MJAnimationCompnent.CreatePiaoEffect()
- if effect then
- self.ui.Items.Layout_Effect_luobo:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end
- end
- end
- elseif roomInfo.nStatus==MJDefine.GameStatus.GAME_STATUS_WAIT_OP_BAO then--等待爆牌
- for k,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- --可以爆牌玩家显示爆牌
- if v.canBaoPai == 1 and v.nUserId == myUserId then
- --self.playerHandCards[viewId]:showBaoPai()
- self:showBaoJiao()
- end
-
- --已爆牌玩家不能出牌
- if v.isBaoPai ~= 0 then
- if v.isBaoPai == 1 then-- 报叫
- self.playerView:playBaoAnim(viewId)
- end
-
- if v.nUserId == myUserId then --自己爆牌
- self.playerHandCards[viewId]:lockHandCard(true)
- -- self.playerHandCards[viewId]:setOutCardEnable(false)
- end
- app.room:dispatchEvent({name = MJDefine.MJEvent.OutCardFalg,value = roomInfo.lastOpCard,viewId = viewId})
- else
-
- end
- --显示飘状态
- self.playerView:showPiao(viewId,tonumber(v.isPiao))
- end
- elseif roomInfo.nGameStartCount > 0 and roomInfo.memberList[myUserId].nPlayerFlag ~= 1 then--游戏中
- --local outCardUserId = app.room:getUserIdBySeatId(roomInfo.needOutCardId)
- local bIsOutCard = roomInfo.isNeedOutCard > 0 or false
- if (not bIsOutCard) and roomInfo.memberList[myUserId].nTingStatus == MJDefine.MJTingStatus.Ting then
- local gameInfo =json.decode(app.room.roomInfo.strGameInfo);
- --if gameInfo.tingpai > 0 then
- --self.ui.Items.Button_Ting_Info:setVisible(true);
- self:setButtonTingInfoVisible(true)
- --end
- end
-
- for k,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- --可以爆牌玩家显示爆牌
- if v.canBaoPai == 1 and v.nUserId == myUserId then
- self.reShowBao = true--重连显示报叫操作标志
- self:showBaoJiao()
- end
- --已爆牌玩家不能出牌
- if v.isBaoPai ~= 0 then
- if v.isBaoPai == 1 then-- 报叫
- self.playerView:playBaoAnim(viewId)
- self.playerHandCards[viewId]:setBaoPai(1)
- end
- if v.nUserId == myUserId then --自己爆牌
- --self.playerHandCards[viewId]:lockHandCard(true)
- --报牌情况下,只能打听牌
- self.playerHandCards[MJDefine.MyViewId]:tangCardEnabled(true)
- self.playerHandCards[MJDefine.MyViewId]:setIsTanging(false)
- end
- app.room:dispatchEvent({name = MJDefine.MJEvent.OutCardFalg,value = roomInfo.lastOpCard,viewId = viewId})
- end
- local handcardNum = #v.handCards
- if handcardNum%3 == 2 then
- isMyGetCard = true
- end
- if roomInfo.outCardUserId == v.nUserId then
- if v.nUserId == myUserId and roomInfo.lastOpCard~=0 and isMyGetCard then
- self.playerHandCards[viewId]:removeHandCard(roomInfo.lastOpCard)
- self.playerHandCards[viewId]:resetHandCards()
- if v.isBaoPai == 1 then
- self.playerHandCards[viewId]:setNotTingCardDidable(true)
- end
- self.playerHandCards[viewId]:createHandCards(roomInfo.lastOpCard)
- end
-
- if roomInfo.isNeedOutCard > 0 then
- self.playerHandCards[viewId]:setOutCardEnable(true)
- end
- end
- if viewId == MJDefine.MyViewId then
- if roomInfo.operates and table.nums(roomInfo.operates)>0 then
- self.operates = roomInfo.operates
- else
- self.operates = {}
- end
- if v.tangCards and type(v.tangCards) == 'table' and #v.tangCards > 0 then
- self.isTang = true
- self.playerHandCards[viewId]:setTangSuccess(true)
- end
- self.playerHandCards[viewId]:setTangCard(true,v.tangCards)
- self.playerHandCards[viewId]:setPaoCard(true,roomInfo.paoCards)
- else
- self.playerHandCards[viewId]:showTangCard(true,v.tangCards)
- end
- --摆标志显示
- if v.tangCards and type(v.tangCards) == 'table' and #v.tangCards > 0 then
- self.playerView:showBai(viewId,true)
- else
- self.playerView:showBai(viewId,false)
- end
- --显示飘状态
- self.playerView:showPiao(viewId,tonumber(v.isPiao))
-
- if (v.nTingStatus==MJDefine.MJTingStatus.Ting or v.isBaoPai ~= 0) and (not isMyGetCard) then
- -- 听牌、报叫、胡牌情况下,显示听牌按钮
- -- 此时需重新请求一下听牌数据,否则显示为空
- self.ui:sendMsg(app.room, MJDefine.MJEvent.Ting)
- self.isTing = true;
- self:setButtonTingInfoVisible(true);
- end
- end
- if isMyGetCard then
- --self.playerHandCards[MJDefine.MyViewId]:checkQueAndDisableOtherCard()
- self.playerHandCards[MJDefine.MyViewId]:setOutCardEnable(true)
- end
-
- --显示哪些玩家胡牌
- for i,player in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(player.nUserId)
- local effect
- if player.result>0 then --胡的类型大于0
- if player.result == MJDefine.MJGameHuType.HU_ZIMO then
- effect=MJAnimationCompnent.CreateHuOrderEffect(player.result,player.huOrder)
- else
- effect=MJAnimationCompnent.CreateHuOrderEffect(player.result,player.huOrder)
- end
- if viewId == MJDefine.MyViewId then
- self.playerHandCards[viewId]:createHandCards(player.huCard)
- self.playerHandCards[viewId]:moveLastCard()
- meIsHu = true
- else
- self.playerHandCards[viewId]:removeAllHandCards()
- self.playerHandCards[viewId]:createOpenHandCards(player.handCards)
- self.playerHandCards[viewId]:createOpenHandCards(player.huCard)
- self.playerHandCards[viewId]:moveLastOpenCard()
- end
- end
- if effect then
- self.ui.Items.Layout_Effect:addChild(effect)
- effect:setTag(HU_EFFECT_TAG)
- effect:setLocalZOrder(1000)
- local pos = self.playerHandCards[viewId]:getAnimationPostion()
- if viewId==MJDefine.PlayerViewType.My then
- effect:setPosition(pos.x,pos.y-60)
- elseif viewId==MJDefine.PlayerViewType.Left then
- effect:setPosition(pos.x-20,pos.y)
- elseif viewId==MJDefine.PlayerViewType.Right then
- effect:setPosition(pos.x+10,pos.y)
- elseif viewId==MJDefine.PlayerViewType.Top then
- effect:setPosition(pos.x,pos.y+10)
- end
- end
- end
- end
- --显示出牌角标(需要服务器修改outCardUserId为最后一位出牌玩家的id,而不是当前需要出牌玩家的ID)
- local lastOutCardViewId = app.room:getViewIdByUserId(roomInfo.outCardUserId);
- app.room:dispatchEvent({name = MJDefine.MJEvent.OutCardFalg, value = roomInfo.lastOpCard, viewId = lastOutCardViewId});
-
- --显示听标示
- app.room:dispatchEvent({name = MJDefine.MJEvent.PushTing});
- app.room:dispatchEvent({name = MJDefine.MJEvent.ShowTing})
- --如果有操作显示操作按钮
- if not (roomInfo.nStatus==MJDefine.GameStatus.GAME_STATUS_WAIT_OP_BAO) then
- if self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:showOperate(roomInfo.operates,roomInfo.lastOpCard,isMyGetCard);
- end
- end
-
- --如果一局结束,玩家点了准备,不再显示牌信息
- if MJDefine.GameStatus.GAME_STATUS_ROUND_OVER == roomInfo.nStatus and roomInfo.memberList[myUserId].nPlayerFlag == 1
- or MJDefine.GameStatus.GAME_STATUS_GAME_OVER == roomInfo.nStatus and roomInfo.memberList[myUserId].nPlayerFlag == 1
- then --游戏为停止或开始状态
- self:onUserReadyResponse({nUserId=myUserId})
- end
- if meIsHu and meIsHu == true then
- self.playerHandCards[MJDefine.MyViewId]:setOutCardEnable(false)
- self:setTingCardViewVisible(false)
- --self.ui.Items.Button_Ting_Info:setVisible(false)
- self:setButtonTingInfoVisible(false)
- self.playerHandCards[MJDefine.MyViewId]:setTing(false)
- self.playerHandCards[MJDefine.MyViewId]:lockHandCard(true);
- self.playerHandCards[MJDefine.MyViewId]:checkQueAndDisableOtherCard()
- end
-
- --快速成局
- if roomInfo.nGameStartCount == 0 then
- -- 游戏未开始
- if roomInfo.nStatus and roomInfo.nStatus<MJDefine.GameStatus.GAME_STATUS_WAIT_BANKER_START then
- if roomInfo.bUserFastStartGame then
- if roomInfo.bUserFastStartGame == 1 then
- --[[local tmpInfo = {}
- for uid,status in pairs(roomInfo.pList) do
- table.insert(tmpInfo, {nUserId=tonumber(uid), nStatus = status})
- end--]]
- local response = {}
- response.pList = roomInfo.pList
- response.timeOut = roomInfo.leftFastStartGameTime
- self:onBroadcastFaststart({response=response})
- end
- else
- if self._fastRequestView then
- self._fastRequestView:removeSelf()
- self._fastRequestView = nil
- end
- end
- end
- end
- end
-
- function ncmajRoomView:getChangeGruopDatas(g)
- local opType=g.opType
- local showType=MJDefine.MJOperateToGroupType[g.opType]
- local opCard=g.opCard
- local redNum = g.redNum
-
- local fromViewId = nil
- local targetSeatId = g.targetSeatId--操作位置座位号
- local fromUserId = g.opUserId or g.fromUserId or 0 --触发操作玩家
- local fromViewId1 = app.room:getViewIdByUserId(fromUserId)
- if fromUserId<=0 or not targetSeatId then
- else
- fromViewId = app.room:transPos( targetSeatId, app.room:getSeatIdByUserId(fromUserId))
- --判断是否是对面玩家,对面玩家的话要做一次翻转
- local opViewId = app.room:getViewIdBySeatId(targetSeatId)
- if opViewId == 2 then --对面
- if fromViewId==1 then fromViewId = 3
- elseif fromViewId==3 then fromViewId = 1 end
- end
- --三人玩只有上下家
- if app.room:getMaxPlayerCount()==3 and fromViewId==2 then fromViewId = 3 end
- if app.room:getMaxPlayerCount()==2 and fromViewId~=0 then
- if showType == MJDefine.MJGroupType.Peng then
- fromViewId = 2
- else
- fromViewId = 4
- end
- end
- end
- --组合一下牌
- local group={
- opType=opType,
- showType=showType,
- values={},
- opCard = opCard,
- redNum = redNum,
- fromViewId = fromViewId,
- fromViewId1 = fromViewId1,--真正的来源viewID
- }
- if MJDefine.MJGroupType.Chi==showType then
-
- elseif MJDefine.MJGroupType.Peng==showType then
- group.values={opCard,opCard,opCard}
- else
- group.values={opCard,opCard,opCard,opCard}
- end
-
- return group
- end
-
- -- 小局结算
- function ncmajRoomView:onGameXiaoJuResponse(data)
- local function runGameXiaoJuResponse(onEnd)
- if not tolua.isnull(self.firstTingTipsView) then
- self.firstTingTipsView:killSelf()
- self.firstTingTipsView = nil
- end
- -- 取消操作按钮
- if self.playerHandCards and self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:hideOperate()
- end
-
- local roomInfo = app.room.roomInfo
- self.direcionView:stopAllActions()
- self.operates = {}
- self:setTingCardViewVisible(false)
- app.room:resetTings()
- app.room:cleanTingStatus()
- --如果是解散直接return
- --[[if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_LONG_NOT_END or roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_DISBAND_GAME then
- if onEnd then
- onEnd()
- end
- return
- end --]]
-
- --所有胡牌的人 考虑抢杠胡的问题
- local viewIds={}
- local failViewId=0
- for k,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- if v.result and v.result>0 then
- table.insert(viewIds,viewId)
- --处理掉huCard, 不加入手牌
- --播放音效
- if viewId==MJDefine.MyViewId then
- --MJSound.PlayWinGame()
- end
- if v.result==MJDefine.MJGameHuType.HU_DIANPAO then
- failViewId = app.room:getViewIdBySeatId(v.dpSeatId)
- end
-
- end
- end
- self:showOpenCard()
- for k,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- if viewId and self.playerHandCards[viewId] then
- if viewId==MJDefine.MyViewId then
- else
- --倒牌
- if v.huCard and v.huCard ~= 0 then
- self.playerHandCards[viewId]:createOpenHandCards(v.huCard)
- self.playerHandCards[viewId]:moveLastOpenCard()
- end
- end
- end
- end
-
-
- --被抢杠的人回退补杠
- -- if resultInfo.hutype==MJDefine.MJHuType.QiangGangHu and roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_NORMAL then
- -- self.playerHandCards[failViewId]:retoreBuGang(resultInfo.hucard)
- -- end
-
- local function callback()
- self:showXiaoJuView()
- if onEnd then
- onEnd()
- end
- self.ui.Items.Layout_Effect_luobo:removeAllChildren()
- end
-
- local function luoboNumCallBack()
- local strGameInfo = json.decode(app.room.roomInfo.strGameInfo)
- if strGameInfo.luobonum and strGameInfo.luobonum > 0 then
- local index = 1
- for k,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- local effect
- if index == app.room.roomInfo.nMaxPlayCount then
- effect = MJAnimationCompnent.CreateLoBoLabel(v.luoboNum,callback)
- else
- effect = MJAnimationCompnent.CreateLoBoLabel(v.luoboNum)
- end
- local pos = self.playerHandCards[viewId]:getAnimationPostion()
- if viewId==MJDefine.PlayerViewType.My then
- effect:setPosition(pos.x+130,pos.y-60)
- elseif viewId==MJDefine.PlayerViewType.Left then
- effect:setPosition(pos.x-20-30,pos.y-70)
- elseif viewId==MJDefine.PlayerViewType.Right then
- effect:setPosition(pos.x+10-30,pos.y-70)
- elseif viewId==MJDefine.PlayerViewType.Top then
- effect:setPosition(pos.x+130,pos.y+10-50)
- end
- self.ui.Items.Layout_Effect_luobo_Lable:addChild(effect)
- index = index + 1
- end
- else
- callback()
- end
- end
-
- local luoboCards = roomInfo.luoboCards
- local function luoboCallBack()
- if luoboCards and #luoboCards>0 then
- local luoNum = #luoboCards
- --加一个黑底
- local layer = cc.LayerColor:create(cc.c4b(0,0,0,120))
- layer:setAnchorPoint(cc.p(0.5,0.5))
- layer:ignoreAnchorPointForPosition(false)
- local tPos = self.ui.Items.ImageView_Logo:getPosition()
- local tLuoBoPos = {
- [1] = {[1] = cc.p(tPos.x,360-40)},
- [2] = {[1] = cc.p(tPos.x-50,360),[2] = cc.p(tPos.x+50,360)},
- }
- layer:setPosition(cc.p(getWinSize().width/2,getWinSize().height/2))
- self.ui.Items.Layout_Effect_luobo:addChild(layer)
- for i,v in pairs(luoboCards) do
- local effect
- if i == #luoboCards then
- effect = MJAnimationCompnent.CreateLoBoEffect(v,self.desktopType,luoboNumCallBack)
- else
- effect = MJAnimationCompnent.CreateLoBoEffect(v,self.desktopType)
- end
- if MJDefine.LuoBoPos[luoNum] and MJDefine.LuoBoPos[luoNum][i] then
- effect:setPosition(tLuoBoPos[luoNum][i])
- self.ui.Items.Layout_Effect_luobo:addChild(effect)
- end
- end
- else
- self:runDelay(1.0,function()
- callback()
- end)
- end
- end
-
- if #viewIds>0 then
- if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_LONG_NOT_END or roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_DISBAND_GAME then
- self:runDelay(1.0,function()
- callback()
- end)
- else
- luoboCallBack()
- end
- local userInfo=app.room:getUserInfo(app.room:getMyUserId())
- if userInfo then --拔萝卜音效
- end
- else
- if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_HUANG_ZHUANG then
- local effect=MJAnimationCompnent.CreateLiuJuEffect(callback)
- self.ui.Items.Layout_Player:addChild(effect)
- effect:setLocalZOrder(1000)
- MJSound.PlayHuangZhuang()
- else
- callback()
- end
- end
- end
- self:addCallBack(runGameXiaoJuResponse);
- end
-
- -- 显示小局结算
- function ncmajRoomView:showXiaoJuView()
- self.direcionView:stopAllActions()
-
- self:setTingCardViewVisible(false)
- if self.xiaojuView then
- self.xiaojuView:removeFromParent()
- end
- local roomInfo = app.room.roomInfo
- self.xiaojuView = MJRoomXiaoJuView:new(self.desktopType)
- self:addChild(self.xiaojuView)
-
- end
-
- function ncmajRoomView:setTingCardViewVisible(bVisible,tingCards)
- self.ui.Items.Layout_Ting_Tip_Card_Panel:setVisible(false)
- --[[if self._tingCardView and (not tolua.isnull(self._tingCardView)) then
- self._tingCardView:setData(tingCards)
- if (not tingCards) or (type(tingCards) == 'table' and #tingCards==0) then
- self:setTingCardVisible(false)
- return
- end
- self:setTingCardVisible(bVisible)
- end--]]
- end
-
- --显示查听的牌
- function ncmajRoomView:setChaTingCardViewVisible(bVisible,tingCards)
- end
-
- function ncmajRoomView:onTingCardStatus()
- local myUserId=app.user.loginInfo.uid;
- local memberList=app.room.roomInfo.memberList;
- local player = memberList[myUserId];
- if not player then
- return ;
- end
- local nTingStatus = player.nTingStatus
- if nTingStatus == MJDefine.MJTingStatus.Ting then
- print("---------onTingCardStatus-----------1 "..myUserId)
- if player.isBaoPai == 1 then
- self.ui:sendMsg(app.room,MJDefine.MJEvent.Ting)
- end
- self.isTing = true;
- self:setButtonTingInfoVisible(true);
- else
- print("---------onTingCardStatus-----------0 "..myUserId)
- self:setButtonTingInfoVisible(false);
- end
- end
-
- function ncmajRoomView:onTingCardResult(data)
- print("---------听牌结果-------------")
- --[[if data.response.tingType==MJDefine.MJTingType.QuanTing then
- -- self:setChaTingCardViewVisible(true,{})
- else
- if self._isOutCardTingCheck then
- self._isOutCardTingCheck = false
- local count = table.nums(data.response.tingCards);
- local isTing = count > 0;
- --self.ui.Items.Button_Ting_Info:setVisible(isTing);
- self:setButtonTingInfoVisible(isTing)
- self:setTingCardViewVisible(false, data.response.tingCards)
- else
- self:setTingCardViewVisible(true, data.response.tingCards)
- end
- self._tingCardView:setData(tingCards);
- end--]]
- local tingCards = data.response.tingCards or {};
- self.isTing = table.nums(tingCards) > 0;
- self:setButtonTingInfoVisible(self.isTing);
- self._tingCardView:setData(tingCards);
- self:setTingCardVisible(false);
- end
-
- function ncmajRoomView:showTing(evet)
- --[[local roomInfo=app.room.roomInfo
- local selectCard = evet.card;
- if not selectCard or evet.card <= 0 then
- return;
- end
- if evet.card and roomInfo.tings and #roomInfo.tings>0 then
- local isTing = false
- for k,v in pairs(roomInfo.tings) do
- if evet.card==v.outCard then
- self:setTingCardViewVisible(true,v.tingCards)
- isTing = true
- end
- end
- if not isTing then
- self:setTingCardViewVisible(false)
- end
- else
- self:setTingCardViewVisible(false)
- local isMyGetCard = true
- if self.playerHandCards[MJDefine.MyViewId] then
- local handCards = self.playerHandCards[MJDefine.MyViewId]:getHandCardNodes()
- if handCards and type(handCards) == 'table' then
- isMyGetCard = (#handCards%3==2)
- end
- end
- local myUserId = app.room:getMyUserId()
- if roomInfo.nGameStartCount > 0 and roomInfo.memberList[myUserId].nPlayerFlag == 2 and (not isMyGetCard) then--游戏中,不是摸牌阶段
- self._isOutCardTingCheck = true;
- self.ui:sendMsg(app.room,MJDefine.MJEvent.Ting)
- end
- end--]]
- local roomInfo=app.room.roomInfo;
- local selectCard = evet.card;
- if not selectCard or evet.card <= 0 then
- return;
- end
-
- local curTingCards = app.room:getTingCardsByCard(selectCard);
- if not self._tingCardView then
- return ;
- end
-
- self._tingCardView:setData(curTingCards);
- self.isTing = table.nums(curTingCards) > 0;
- if self.isTing and (not self:isMySelfHu()) then
- self:setTingCardVisible(true);
- else
- self:setTingCardVisible(false);
- end
- end
-
- function ncmajRoomView:isMySelfHu()
- local myUserId = app.room:getMyUserId();
- local player = app.room.roomInfo.memberList[myUserId];
- if not player then
- return false;
- end
-
- local huCards = player.huCards or {};
- return table.nums(huCards) > 0;
- end
-
- function ncmajRoomView:pushTing()
- local function runPushTing(onEnd)
- if self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:pushTing()
- end
- if onEnd then
- onEnd()
- end
- end
- self:addCallBack(runPushTing);
- end
-
- function ncmajRoomView:onHuResponse(data)
- local function runHuResponse(onEnd)
- local response = data.response
-
- local function callback()
- self:playHuAni(response)
- if onEnd then
- onEnd()
- end
- end
-
- local viewId = app.room:getViewIdByUserId(response.nUserId)
- local userInfo=app.room:getUserInfoByViewId(viewId)
-
- --先播放胡牌动画和音效,再显示胡牌顺序
- local effect = MJAnimationCompnent.CreateHuEffect(response.huType,callback)
- if response.huType == MJDefine.MJGameHuType.HU_ZIMO then
- MJSound.PlayOperateSound(userInfo.sex,MJDefine.MJOperateType.OPREATE_ZIMOHU)
- -- effect=MJAnimationCompnent.CreateHuEffect("zimo",callback)
- -- elseif response.huType == MJDefine.MJGameHuType.HU_QIANGGANG then
-
- else
- MJSound.PlayOperateSound(userInfo.sex,MJDefine.MJOperateType.OPREATE_DIANPAOHU)
- -- effect=MJAnimationCompnent.CreateHuEffect("hu",callback)
- -- --点炮显示
- end
-
- if effect then
- self.ui.Items.Layout_Effect:addChild(effect)
- effect:setTag(HU_EFFECT_TAG)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end
-
- --删除等待操作的显示
- if self.waitOperates and #self.waitOperates>0 then
- for k,v in pairs(self.waitOperates) do
- v:removeFromParent()
- end
- self.waitOperates={}
- end
-
- if response.huType==MJDefine.MJGameHuType.HU_DIANPAO and response.curOpType ~= 1 then
- local failViewId = app.room:getViewIdByUserId(response.dpId)
- --点炮胡或抢杠胡,胡牌类型都是发 点炮胡
- if response.isQiangGng > 0 then
- local huCard = response.huCard == 65 and response.redRealCard or response.huCard --如果胡的牌是红中 用真实的牌 否则用胡的牌
- -- logD("isQiangGng huCard:"..huCard)
- --抢杠胡
- self.playerHandCards[viewId]:onGetCard(nil,huCard)
- --被抢杠的人回退补杠
- self.playerHandCards[failViewId]:retoreBuGang(huCard,1)
- elseif response.isGspHu and response.isGspHu > 0 then
- local gameInfo =json.decode(app.room.roomInfo.strGameInfo);
- if gameInfo.gshmode == 1 then
- dghDianPao = true
- --点杠炮(选择的点杠花)时手上已经有杠的牌 不需要再加一张胡的牌
- else
- self.playerHandCards[viewId]:onGetCard(nil,response.huCard)
- --将胡的牌收走
- self.playerHandCards[failViewId]:removeOutCard(response.huCard)
- end
- else
- self.playerHandCards[viewId]:onGetCard(nil,response.huCard)
- --将胡的牌收走
- self.playerHandCards[failViewId]:removeOutCard(response.huCard)
- end
-
- local function fangpaoCallback()
- self:playFangPaoAni(failViewId)
- end
- --放炮动画
- effect=MJAnimationCompnent.CreateDianPaoEffect(fangpaoCallback)
- self.ui.Items.Layout_Effect:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[failViewId]:getAnimationPostion())
-
- if failViewId==MJDefine.MyViewId and app.room.roomInfo.lastOutViewId==MJDefine.MyViewId then --修改点炮的人连续二次出牌 不删除牌
- app.room.roomInfo.lastOutViewId = nil
- end
-
- --此处仅做保留,没有实际意义
- elseif response.huType==MJDefine.MJGameHuType.HU_QIANGGANG then
- local failViewId = app.room:getViewIdByUserId(response.dpId)
- if response.redRealCard > 0 then
- --抢杠胡时,胡牌的人将胡的牌加入手中
- self.playerHandCards[viewId]:onGetCard(nil,response.redRealCard)
- --被抢杠的人回退补杠
- self.playerHandCards[failViewId]:retoreBuGang(response.redRealCard,1)
- end
- end
-
- if response.nUserId == app.room:getMyUserId() then
- self.playerHandCards[viewId]:setOutCardEnable(false)
- self:setTingCardViewVisible(false)
- --self.ui.Items.Button_Ting_Info:setVisible(false)
- self:setButtonTingInfoVisible(false)
- self.playerHandCards[viewId]:setTing(false)
- self.playerHandCards[viewId]:lockHandCard(true);
- self.playerHandCards[MJDefine.MyViewId]:hideOperate()
- else
- -- 其他人胡了倒牌
- local handCards = {}
- for k,v in pairs(self.playerHandCards[viewId]:getHandCardNodes() or {}) do
- table.insert(handCards,{card = v.value or v:getValue()})
- end
- if response.huType==MJDefine.MJGameHuType.HU_ZIMO or response.curOpType == 1 or (response.isGspHu and response.isGspHu > 0) then --如果是自摸胡 把最后一张替换为胡的牌或点杠花点炮
- handCards[#handCards] = {card = response.huCard}
- end
- self.playerHandCards[viewId]:removeAllHandCards()
- self.playerHandCards[viewId]:createOpenHandCards(handCards)
- self.playerHandCards[viewId]:moveLastOpenCard()
- end
-
- --self.playerHandCards[MJDefine.MyViewId]:hideOperate()
- end
- self:addCallBack(runHuResponse);
- end
-
- function ncmajRoomView:playHuAni(response)
- local strGameInfo = json.decode(app.room.roomInfo.strGameInfo)
- local effect = MJAnimationCompnent.CreateHuOrderEffect(response.huType,response.huOrder)
- -- if response.huType == 1 then
- -- effect=MJAnimationCompnent.CreateHuOrderEffect("zimo",response.huOrder)
- -- else
- -- effect=MJAnimationCompnent.CreateHuOrderEffect("hu",response.huOrder)
- -- end
-
- local viewId = app.room:getViewIdByUserId(response.nUserId)
- if effect then
- self.ui.Items.Layout_Effect:addChild(effect)
- effect:setTag(HU_EFFECT_TAG)
- effect:setLocalZOrder(1000)
- local pos = self.playerHandCards[viewId]:getAnimationPostion()
- if viewId==MJDefine.PlayerViewType.My then
- effect:setPosition(pos.x,pos.y-60)
- elseif viewId==MJDefine.PlayerViewType.Left then
- effect:setPosition(pos.x-20,pos.y)
- elseif viewId==MJDefine.PlayerViewType.Right then
- effect:setPosition(pos.x+10,pos.y)
- elseif viewId==MJDefine.PlayerViewType.Top then
- effect:setPosition(pos.x,pos.y+10)
- end
- end
- end
-
- function ncmajRoomView:playFangPaoAni(viewId)
- local effect = MJAnimationCompnent.CreateFangPaoEffect()
- --local viewId = app.room:getViewIdByUserId(response.nUserId)
- if effect then
- self.ui.Items.Layout_Effect:addChild(effect)
- effect:setTag(HU_EFFECT_TAG)
- effect:setLocalZOrder(1000)
- local pos = self.playerHandCards[viewId]:getAnimationPostion()
- if viewId==MJDefine.PlayerViewType.My then
- effect:setPosition(pos.x,pos.y-60)
- elseif viewId==MJDefine.PlayerViewType.Left then
- effect:setPosition(pos.x-20,pos.y)
- elseif viewId==MJDefine.PlayerViewType.Right then
- effect:setPosition(pos.x+10,pos.y)
- elseif viewId==MJDefine.PlayerViewType.Top then
- effect:setPosition(pos.x,pos.y+10)
- end
- end
- end
-
- function ncmajRoomView:onQiangDuanOperates(data)
- local function runOnQiangDuanOperates(onEnd)
- logD("ncmajRoomView:runOnQiangDuanOperates")
- local response = data.response
- if response.operates and self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:showOperate(response.operates)
- end
- if onEnd then
- onEnd()
- end
- end
- logD("ncmajRoomView:onQiangDuanOperates")
- self:addCallBack(runOnQiangDuanOperates)
- end
-
- --游戏消息
- function ncmajRoomView:bindExtendMessage()
- self:bindEvent(app.room , MJDefine.MJEvent.OutCardTings, handler(self , self.pushTing));
- self:bindEvent(app.room , MJDefine.MJEvent.HuResponse, handler(self , self.onHuResponse))
- self:bindEvent(app.room , MJDefine.MJEvent.BaoPaiResponse, handler(self , self.onBaoPai))
- self:bindEvent(app.room , MJDefine.MJEvent.BankerBaoPai, handler(self , self.onBankerBaoPai))
- self:bindEvent(app.room , MJDefine.MJEvent.SendGuo, handler(self , self.onSendGuo))
-
- self:bindEvent(app.room , MJDefine.MJEvent.QiangDuanOperates, handler(self , self.onQiangDuanOperates))
-
- self:bindEvent(app , MJDefine.MJEvent.ChangeLanguage , handler(self , self.doSound))
-
- self:bindEvent(app.room , MJDefine.MJEvent.StartPiao, handler(self , self.onStartPiao))
- self:bindEvent(app.room , MJDefine.MJEvent.PiaoResponse, handler(self , self.onPiaoResponse))
- self:bindEvent(app, MJDefine.MJEvent.ChangeViewType, handler(self, self.onEventChangeViewType ))
-
- --换三张,服务器会通过0x8122通知换牌
- self:bindEvent(app.room , MJDefine.MJEvent.NoticeSwapCard,handler(self,self.onNoticeSwapCardResponse))
- --换三张失败
- self:bindEvent(app.room , MJDefine.MJEvent.SwapCardErr,handler(self,self.onChangeCardFail))
- --换三张成功
- self:bindEvent(app.room , MJDefine.MJEvent.SwapCardSucc,handler(self,self.onChangeCardSucc))
- --换三张成功后的信息
- self:bindEvent(app.room , MJDefine.MJEvent.SwapCardSuccInfo,handler(self,self.onChangeCardInfo))
- --服务器通知定缺
- self:bindEvent(app.room , MJDefine.MJEvent.NoticeDingQue,handler(self,self.onNoticeDingQueResponse))
- --当玩家操作成功后,通过0x8131广播定缺成功
- self:bindEvent(app.room , MJDefine.MJEvent.DingQueSucc,handler(self,self.onDingQueSuccResponse))
- --当所有玩家定缺成功后,服务器会通过广播告诉玩家定缺类型
- self:bindEvent(app.room , MJDefine.MJEvent.DingQueSuccInfo,handler(self,self.onDingQueSuccInfoResponse))
- --内容和0x8106保持统一 广播桌子上所有玩家庄家起手操作
- self:bindEvent(app.room , MJDefine.MJEvent.AfterDingQue,handler(self , self.onAfterDingQue))
- --检测是否符合换三张规则
- self:bindEvent(app.room , MJDefine.MJEvent.CheckIsInSwapRule,handler(self , self.onCheckIsInSwapRule))
- --躺牌
- self:bindEvent(app.room , MJDefine.MJEvent.TangPaiResponse,handler(self,self.onTangPaiResponse))
- -- 托管
- self:bindEvent(app.room , MJDefine.MJEvent.HostingRequest, handler(self, self.onHostingRequest))
- end
-
- function ncmajRoomView:clean()
- self.playerView:init()
- -- --默认状态
- self:defaultState()
- app.room:resetRoomInfo()
- self:setBtnSitDownVisible(false)
-
- self.ui:sendMsg(app.room, MJDefine.MJEvent.CallReadyRequest)
- --
- self._gameoverview = nil
- end
-
- function ncmajRoomView:updateReady()
- local nUserId = app.room:getMyUserId()--app.user.loginInfo.uid
- if app.room.roomInfo.nGameStartCount > 0 then
- self.toolView.ui.Items.Button_Leave:setEnabled(false)
- self:setBtnSitDownVisible(false)
- else
- self.toolView.ui.Items.Button_Leave:setEnabled(true)
- end
- if app.room.roomInfo.nGameStartCount == 0 and app.room.roomInfo.nRoomOwnedUid ~= nUserId then
- self.toolView.ui.Items.Button_Dismiss:setEnabled(false)
- else
- self.toolView.ui.Items.Button_Dismiss:setEnabled(true)
- end
-
- self:checkCanDismiss()
- end
-
- -- 游戏开始
- function ncmajRoomView:onGameStartResponse()
- ncmajRoomView.super.onGameStartResponse(self)
-
- if app.room.roomInfo.isEapCreate == 1 then
- local function runEapSdkPopup(onEnd)
- local function call()
- if onEnd then
- onEnd()
- end
- end
-
- G_EapSdkMgr:showBeginLayer(call)
- end
- self:addCallBack(runEapSdkPopup);
- end
-
- self._gameoverview = nil
- end
-
- -- 大局结算
- function ncmajRoomView:onGameDaJuResponse(data)
- app.club_php:dispatchEvent({name = GAME_EVENT.CLUB_BACK_ROOM})
- if self._gameoverview then
- return
- end
- if app.room.roomInfo.needJieSuanInfo == 1 then--显示总结算
- self:showGameOverResult(data.response)
- else
- --[[local roomInfo=app.room.roomInfo
- --如果是解散直接跳转总结算
- if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_LONG_NOT_END or roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_DISBAND_GAME then
- self:showGameOverResult(data.response)
- end --]]
- local roomInfo=app.room.roomInfo
- local isNoCard = false--没有手牌
- for i,player in pairs(roomInfo.memberList) do
- if type(player.handCards) == 'table' and #player.handCards <= 0 then
- local a = #player.handCards
- isNoCard = true
- break
- end
- end
- if isNoCard then
- self:showGameOverResult(data.response)
- end
- app.room:dispatchEvent({name = GAME_EVENT.DISSMISS_CLOSE})
- end
- end
-
- -- 大局结算
- function ncmajRoomView:showGameOverResult(data)
- if self._gameoverview ~= nil then
- return
- end
- self.direcionView:stopAllActions()
- self:resetGame()
- local view=MJRoomDaJuView:new(data)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- self._gameoverview = view
- self:showGameOverAward()
- end
-
- function ncmajRoomView:onOtherLogoutResponse(data)
- -- local jushu = app.room.roomInfo.nGameStartCount or 0
- if (not data or not data.nUserId or not data.nSeatShowId) then
- return
- end
- local function test(onEnd)
- self.playerView:updatePlayerInfo(data.nSeatShowId)
- self:onUserReadyResponse()
- --更新GPS
- --self:updateAllGpsInfo()
- --self:checkGpsDistance()
- -- 是否显示邀请好友
- self.toolView:updateButton()
-
-
- logE("88888-onOtherLogoutResponse onEnd")
- if onEnd then
- onEnd()
- end
- end
- self:addCallBack(test)
- end
-
-
- function ncmajRoomView:resetGame()
- ncmajRoomView.super.resetGame(self)
- self.ui.Items.Layout_Effect:removeAllChildren()
- self.ui.Items.Layout_Effect_luobo_Lable:removeAllChildren()
- self.ui.Items.Layout_Effect_luobo:removeAllChildren()
- self.playerView:clearBao()
- self.playerView:clearAllPiao()
- --self.playerView:clearAllBoZiMo()
- self.playerView:clearAllQue()
- self.playerView:clearAllBai()
- if self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:setQueType(-1)--设置缺牌类型为空
- self.playerHandCards[MJDefine.MyViewId]:setTangSuccess(false)--躺牌状态置为false
- self.playerHandCards[MJDefine.MyViewId]:setPaoCard(false)--清空炮牌
- self.playerHandCards[MJDefine.MyViewId]:setBaoPai(0)--重置报状态
- end
- self:setTingCardVisible(false);
- self:setTingCardViewVisible(false);
- self.isTang = false
- app.room.roomInfo.lastOutViewId = 0
- self.reShowBao = nil --重连显示报操作标志
- self.guobao = nil--重连过报标志
-
- if G_LayerMain then
- G_LayerMain:showBoard(false)
- G_LayerMain:showFloat(false)
- end
- end
-
- --显示换三张
- function ncmajRoomView:showSwapCard(isOpered)--是否已经操作过
- self:stopDirection()
- local roomInfo=app.room.roomInfo
- local gameInfo=json.decode(roomInfo.strGameInfo)
-
- if not gameInfo.swapcard or tonumber(gameInfo.swapcard)==0 then return end
- isOpered = isOpered or false
-
- self:hideSwapCard()
- local ui=loadUI("mj_ncmaj/res/ui_fangjian/mj_ncmaj_swap_card.ui")
- self.ui.Items.Layout_Player:addChild(ui)
- self.swapCard=ui
- self.swapCard.Items.ImageView_bg:setVisible(isOpered)
- for i=1,4 do--先隐藏全部
- if self.swapCard.Items["Layout_swapCard_"..i] then
- self.swapCard.Items["Layout_swapCard_"..i]:setVisible(false)
- end
- self:setSwapCardSucc(false,i)
- end
- for k,v in pairs(app.room.roomInfo.memberList) do--根据人数显示
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- if self.playerHandCards[viewId] then
- if self.swapCard.Items["Layout_swapCard_"..viewId] then
- self.swapCard.Items["Layout_swapCard_"..viewId]:setVisible(true)
- end
- else
- if self.swapCard.Items["Layout_swapCard_"..viewId] then
- self.swapCard.Items["Layout_swapCard_"..viewId]:setVisible(false)
- end
- end
- end
-
- --确定换牌按钮
- ui.Items.Button_sure:registerClick(function()
- playBtnEffect()
- self.swapCard.Items.ImageView_bg:setVisible(false)
- --请求换牌
- local cards = self.playerHandCards[MJDefine.MyViewId]:getSelectedCards()
- app.room:requestSwapCards(cards)
- --[[local request = MJMessage.PiaoRequest:new()
- request.isPiao = 0
- self.ui:sendMsg(app.room,MJDefine.MJEvent.PiaoRequest,request)--]]
- end)
- end
- --隐藏换三张
- function ncmajRoomView:hideSwapCard()
- if self.swapCard then
- self.swapCard:removeFromParent()
- self.swapCard=nil
- end
- end
-
- --换三张,服务器会通过0x8122通知换牌
- function ncmajRoomView:onNoticeSwapCardResponse(response)
- local function runNoticeSwapCard(onEnd)
- logD("ncmajRoomView:onNoticeSwapCardResponse")
- local data = response.response
- self:showSwapCard(true)
- --self.playerHandCards[MJDefine.MyViewId]:initSwapCardTouchEvent()
- --弹出推荐牌
- self.playerHandCards[MJDefine.MyViewId]:resetHandCards()
- self.playerHandCards[MJDefine.MyViewId]:selectCardsByCards(data.swapCards)
- self.swapCard.Items.Button_sure:setEnabled(true)
-
- if onEnd then
- onEnd()
- end
- end
- logD("ncmajRoomView:runNoticeSwapCard")
- self:addCallBack(runNoticeSwapCard)
- end
- --换三张失败
- function ncmajRoomView:onChangeCardFail(response)
- local function runChangeCardFail(onEnd)
- logD("ncmajRoomView:onChangeCardFail")
- self:showSwapCard(true)
- self.playerHandCards[MJDefine.MyViewId]:resetHandCards()
- self.swapCard.Items.Button_sure:setEnabled(false)
-
- if onEnd then
- onEnd()
- end
- end
- logD("ncmajRoomView:runChangeCardFail")
- self:addCallBack(runChangeCardFail)
- end
- --换三张成功
- function ncmajRoomView:onChangeCardSucc(response)
- local function runChangeCardSucc(onEnd)
- logD("ncmajRoomView:onChangeCardSucc")
- local data = response.response
- local userId = data.nUserId--操作的玩家
- local viewId = app.room:getViewIdByUserId(userId)
- if viewId == MJDefine.MyViewId then
- if self.swapCard and self.swapCard.Items.ImageView_bg then
- self.swapCard.Items.ImageView_bg:setVisible(false)
- end
- self.playerHandCards[MJDefine.MyViewId]:deleteSelectedCards()
- else
- self:setSwapCardSucc(true,viewId)
- local tmpCards = {}
- for i=1,3 do
- table.insert(tmpCards,{card = 0})
- end
- self.playerHandCards[viewId]:removeHandCard(tmpCards)
- self.playerHandCards[viewId]:resetHandCards()
- end
- self.playerHandCards[viewId]:createSwapCards({0,0,0})
-
- if onEnd then
- onEnd()
- end
- end
- logD("ncmajRoomView:runChangeCardSucc--------")
- self:addCallBack(runChangeCardSucc)
- end
- --换三张成功后的信息
- function ncmajRoomView:onChangeCardInfo(response)
- local function runChangeCardInfo(onEnd)
- logD("ncmajRoomView:onChangeCardInfo")
- self:hideSwapCard()
- local data = response.response
- self:showSwapDirection(data.swapType)
- for i,v in pairs(data.swapCards) do
- for i=1,4 do
- if i == MJDefine.MyViewId and self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:onGetCard(nil,tonumber(v.card))
- elseif self.playerHandCards[i] then
- self.playerHandCards[i]:onGetCard(nil,0)
- end
- end
- end
- self.playerHandCards[MJDefine.MyViewId]:resetHandCards()
- for i=1,4 do
- if self.playerHandCards[i] then
- self.playerHandCards[i]:deleteSwapCards()
- end
- end
- self.playerHandCards[MJDefine.MyViewId]:removeTouchEventOnly()
- for i,v in pairs(data.swapCards) do
- local handCards = self.playerHandCards[MJDefine.MyViewId]:getHandCardNodes() or {}
- for j,mjCard in pairs(handCards) do
- if mjCard:getValue() == tonumber(v.card) and mjCard:getSelected() ~= MJDefine.MJStatus.Select then
- --local mjCard = self.playerHandCards[MJDefine.MyViewId]:getMjByValue(tonumber(v.card))
- --if mjCard and mjCard:getSelected() ~= MJDefine.MJStatus.Select then
- mjCard:setSelected(MJDefine.MJStatus.Select)
- mjCard:recordPostion()
- local initPos = mjCard:getPosition()
- local toPos = cc.p(initPos.x, initPos.y + 25)
- mjCard:setPosition(toPos)
- mjCard:runDeSelectAnimationWithTime(1.0)
- mjCard:runAction(cc.Sequence:create(cc.DelayTime:create(1.0),cc.CallFunc:create(function()
- mjCard:setSelected(MJDefine.MJStatus.Normal)
- end)))
- break
- end
- --end
- end
- end
- --[[self:runAction(cc.Sequence:create(cc.DelayTime:create(1.0),cc.CallFunc:create(function()
- self.playerHandCards[MJDefine.MyViewId]:initTouchEvent()
- end)))--]]
-
- if onEnd then
- onEnd()
- end
- end
- logD("ncmajRoomView:runChangeCardInfo--------")
- self:addCallBack(runChangeCardInfo)
- end
- --设置换牌成功 isSwaped:true显示有勾的,false显示换牌中
- function ncmajRoomView:setSwapCardSucc(isSwaped,viewId)
- isSwaped = isSwaped or false
- if not self.swapCard or tolua.isnull(self.swapCard) then
- return
- end
- if self.swapCard.Items["ImageView_swaping_"..viewId] then
- self.swapCard.Items["ImageView_swaping_"..viewId]:setVisible(not isSwaped)
- end
- if self.swapCard.Items["ImageView_swaped_"..viewId] then
- self.swapCard.Items["ImageView_swaped_"..viewId]:setVisible(false)--isSwaped 不显示选牌中了
- end
- end
-
- --换牌方式 1顺时针 2对家换牌 3逆时针
- function ncmajRoomView:showSwapDirection(dir)
- if not dir then return end
- self:hideSwapDirection()
- local ui=loadUI("mj_ncmaj/res/ui_fangjian/mj_ncmaj_swap_direction.ui")
- self.ui.Items.Layout_Player:addChild(ui)
- self.swapDirection=ui
- self.swapDirection.Items.Layout_ShunShiZhen:setVisible(dir == 1)
- self.swapDirection.Items.Layout_NiShiZhen:setVisible(dir == 3)
- self.swapDirection.Items.Layout_DuiJia:setVisible(dir == 2)
- self.swapDirection.Items.ImageView_s:playClip("shunshizhen")
- self.swapDirection.Items.ImageView_n:playClip("nishizhen")
- self.swapDirection.Items.Layout_DuiJia:playClip("duijia")
- self.swapDirection:runAction(cc.Sequence:create(cc.DelayTime:create(1.0),cc.CallFunc:create(function()
- self:hideSwapDirection()
- end)))
- end
-
- function ncmajRoomView:hideSwapDirection()
- if self.swapDirection then
- self.swapDirection:removeFromParent()
- self.swapDirection = nil
- end
- end
- --显示定缺界面
- function ncmajRoomView:showDingQue(tp)
- self:hideDingQue()
- local ui=loadUI("mj_ncmaj/res/ui_fangjian/mj_ncmaj_dingque.ui")
- self:addChild(ui)
- self.dingque=ui
- self:showDingQueOpEffect(tp)
-
- for i=1,4 do--先隐藏全部
- if self.dingque.Items["Layout_DingQue_"..i] then
- self.dingque.Items["Layout_DingQue_"..i]:setVisible(false)
- end
- end
- for k,v in pairs(app.room.roomInfo.memberList) do--根据人数显示
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- if self.playerHandCards[viewId] then
- if self.dingque.Items["Layout_DingQue_"..viewId] then
- self.dingque.Items["Layout_DingQue_"..viewId]:setVisible(true)
- end
- else
- if self.dingque.Items["Layout_DingQue_"..viewId] then
- self.dingque.Items["Layout_DingQue_"..viewId]:setVisible(false)
- end
- end
- end
- ui.Items.Button_Wan:registerClick(function()
- playBtnEffect()
- self:hideDingQueOp()
- local request = MJMessage.QueCard:new()
- request.queCard = 0
- logD(request.isDingQue,"发送定缺:0")
- self.ui:sendMsg(app.room, MJDefine.MJEvent.RequestDingQue, request)
- end)
-
- ui.Items.Button_Tong:registerClick(function()
- playBtnEffect()
- self:hideDingQueOp()
- local request = MJMessage.QueCard:new()
- request.queCard = 1
- logD(request.isDingQue,"发送定缺:1")
- self.ui:sendMsg(app.room, MJDefine.MJEvent.RequestDingQue, request)
- end)
-
- ui.Items.Button_Tiao:registerClick(function()
- playBtnEffect()
- self:hideDingQueOp()
- local request = MJMessage.QueCard:new()
- request.queCard = 2
- logD(request.isDingQue,"发送定缺:2")
- self.ui:sendMsg(app.room, MJDefine.MJEvent.RequestDingQue, request)
- end)
-
- end
- --隐藏定缺界面
- function ncmajRoomView:hideDingQue()
- if self.dingque then
- self.dingque:removeFromParent()
- self.dingque=nil
- end
- end
- --显示定缺界面操作按钮特效
- function ncmajRoomView:showDingQueOpEffect(tp)
- if not self.dingque or tolua.isnull(self.dingque) then
- return
- end
- self.dingque.Items.Layout_Wan_Effect:setVisible(tp==0)
- self.dingque.Items.Layout_Tong_Effect:setVisible(tp==1)
- self.dingque.Items.Layout_Tiao_Effect:setVisible(tp==2)
- self.dingque.Items.ImageView_Wan_Effect1:playClip("neiquan")
- self.dingque.Items.ImageView_Wan_Effect2:playClip("waiquan")
- self.dingque.Items.ImageView_Tong_Effect1:playClip("neiquan")
- self.dingque.Items.ImageView_Tong_Effect2:playClip("waiquan")
- self.dingque.Items.ImageView_Tiao_Effect1:playClip("neiquan")
- self.dingque.Items.ImageView_Tiao_Effect2:playClip("waiquan")
- end
- --隐藏定缺界面操作按钮
- function ncmajRoomView:hideDingQueOp()
- if not self.dingque or tolua.isnull(self.dingque) then
- return
- end
- self.dingque.Items.Button_Wan:setVisible(false)
- self.dingque.Items.Button_Tong:setVisible(false)
- self.dingque.Items.Button_Tiao:setVisible(false)
- self.dingque.Items.Layout_Wan_Effect:setVisible(false)
- self.dingque.Items.Layout_Tong_Effect:setVisible(false)
- self.dingque.Items.Layout_Tiao_Effect:setVisible(false)
- end
- --设置定缺成功 isDingque:true显示有勾的,false显示定缺中
- function ncmajRoomView:setDingQueSucc(isDingque,viewId)
- isDingque = isDingque or false
- if not self.dingque or tolua.isnull(self.dingque) then
- return
- end
- if self.dingque.Items["ImageView_dingquez_"..viewId] then
- self.dingque.Items["ImageView_dingquez_"..viewId]:setVisible(not isDingque)
- end
- if self.dingque.Items["ImageView_dingquew_"..viewId] then
- self.dingque.Items["ImageView_dingquew_"..viewId]:setVisible(isDingque)
- end
- end
-
- function ncmajRoomView:onBtnTingInfoClicked( )
- --[[playBtnEffect()
- if self.ui.Items.Layout_Ting_Tip_Card_Panel:isVisible() then
- self.ui.Items.Layout_Ting_Tip_Card_Panel:setVisible(false)
- else
- self.ui:sendMsg(app.room,MJDefine.MJEvent.Ting)
- end--]]
- playBtnEffect()
- if self._tingCardView:isVisible() then
- self:setTingCardVisible(false);
- else
- self:setTingCardVisible(true);
- end
- end
-
- function ncmajRoomView:onChangeChatEnable()
- if not self.messageView or tolua.isnull(self.messageView) then
- return
- end
- local voiceEnable = tonumber(loadUserInfo("ncmajPingBiYuYinKG")) or 1
- local propEnable = tonumber(loadUserInfo("ncmajHuDongBiaoQingKG")) or 1
- self.messageView:setVoiceEnabled(voiceEnable==1)
- self.messageView:setPropEnabled(propEnable==1)
- end
-
- function ncmajRoomView:onEventChangeViewType(data)
- self:changeGameBg(true)
-
- MJDefine.MJConfig = MJDefine.loadMJConfig(self.desktopType)
-
- self.ui:sendMsg(app.room, MJDefine.MJEvent.GetTableInfo);
- end
-
-
- --服务器通知定缺
- function ncmajRoomView:onNoticeDingQueResponse(response)
- local function runNoticeDingQue(onEnd)
- logD("ncmajRoomView:onNoticeDingQueResponse")
- local data = response.response
- self:showDingQue(data.queCard)
- for i=1,4 do--置为定缺中
- self:setDingQueSucc(false,i)
- end
- self.playerHandCards[MJDefine.MyViewId]:setHandCardsDidable()
- if onEnd then
- onEnd()
- end
- end
- logD("ncmajRoomView:runNoticeDingQue")
- self:addCallBack(runNoticeDingQue)
- end
- --当玩家操作成功后,通过0x8131广播定缺成功
- function ncmajRoomView:onDingQueSuccResponse(response)
- local function runDingQueSucc(onEnd)
- logD("ncmajRoomView:onDingQueSuccResponse")
- local data = response.response
- local userId = data.nUserId--操作的玩家
- local viewId = app.room:getViewIdByUserId(userId)
- if viewId == MJDefine.MyViewId then
- self:hideDingQueOp()
- self.playerView:showQue(data.queCard,viewId,true)
- self.playerHandCards[viewId]:setQueType(data.queCard)
- else
- self:setDingQueSucc(true,viewId)
- end
- if onEnd then
- onEnd()
- end
- end
- logD("ncmajRoomView:runDingQueSucc")
- self:addCallBack(runDingQueSucc)
- end
- --当所有玩家定缺成功后,服务器会通过广播告诉玩家定缺类型
- function ncmajRoomView:onDingQueSuccInfoResponse(response)
- local function runDingQueSuccInfo(onEnd)
- logD("ncmajRoomView:onDingQueSuccInfoResponse")
- self:hideDingQue()
- local data = response.response
- for i,v in pairs(data.dingQueInfo) do
- local userId = v.nUserId--操作的玩家
- local viewId = app.room:getViewIdByUserId(userId)
- self.playerView:showQue(v.queCard,viewId,true)
- self.playerHandCards[viewId]:setQueType(v.queCard)
- self.playerHandCards[viewId]:initTouchEvent()
- self.playerHandCards[viewId]:resetHandCards()
- end
- self.playerHandCards[MJDefine.MyViewId]:checkQueAndDisableOtherCard()
- if onEnd then
- onEnd()
- end
- end
- logD("ncmajRoomView:runDingQueSuccInfo")
- self:addCallBack(runDingQueSuccInfo)
- end
-
- function ncmajRoomView:onCheckIsInSwapRule(data)
- if not data then return end
- if not self.swapCard then return end
- self.swapCard.Items.Button_sure:setEnabled(data.canCommit)
- end
-
- --躺牌结果
- function ncmajRoomView:onTangPaiResponse(response)
- if not response then return end
- local data = response.response
- if not data then return end
- local opUserId = data.nUserId
- local viewId = app.room:getViewIdByUserId(opUserId)
- local isTang = data.isTang
- local tangCards = data.tangCards
- local paoCards = data.paoCards
- --躺的人手牌躺牌变色 其他人看到躺牌倒下
- local myUserId = app.room:getMyUserId()
-
- self.playerHandCards[MJDefine.MyViewId]:setPaoCard(true,paoCards)
- if opUserId == myUserId then
- self.isTang = true
- self.playerHandCards[viewId]:setTangSuccess(true)
- self.playerHandCards[viewId]:setTangCard(true,tangCards)
- else
- self.playerHandCards[viewId]:showTangCard(true,tangCards)
- end
- self.playerView:showBai(viewId,true)
- local effect=MJAnimationCompnent.CreateTangEffect()
- if effect then
- self.ui.Items.Layout_Player:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end
- --躺音效
- local userInfo=app.room:getUserInfoByViewId(viewId)
- MJSound.PlayTangSound(userInfo.sex)
- end
-
- -- 初始化听牌组件
- function ncmajRoomView:initTingCardView ()
- if not self._tingCardView then
- self._tingCardView = require("mj_ncmaj.luaScript.Views.Compnent.ncmajTingCardView"):new();
- self:addChild(self._tingCardView)
- self._tingCardView:setData(nil);
- self:setTingCardVisible(false);
- end
- end
-
- -- 初始化听牌按钮
- function ncmajRoomView:initTingBtnView ()
- local ncmajTingBtnView = import("mj_ncmaj.luaScript.Views.Compnent.ncmajTingBtnView");
- local btnTing = ncmajTingBtnView:new();
- btnTing:setCallback(handler(self, self.onBtnTingInfoClicked));
- btnTing:setPosition(cc.p(230, 158));
- self.btnTing = btnTing;
- self.ui.Items.Layout_Player:addChild(self.btnTing)
- end
-
- function ncmajRoomView:setButtonTingInfoVisible(isVisible)
- if self.btnTing then
- self.btnTing:setVisible(isVisible);
- end
- end
-
- function ncmajRoomView:setTingCardVisible (isVisible)
- if not self._tingCardView then
- return ;
- end
- self._tingCardView:setVisible(isVisible);
- end
-
- -- 飘操作---------------------------------------------------------------
- function ncmajRoomView:showPiao()
- self:stopDirection()
- local roomInfo=app.room.roomInfo
- local gameInfo=json.decode(roomInfo.strGameInfo)
-
- if not gameInfo.piaomode or tonumber(gameInfo.piaomode)==0 then return end
-
- self:hidePiao()
- local ui=loadUI("mj_ncmaj/res/ui_fangjian/mj_ncmaj_piao.ui")
- self.ui.Items.Layout_Player:addChild(ui)
- self.piao=ui
-
- ui.Items.Button_BuPiao:registerClick(function()
- playBtnEffect()
- self:hidePiao()
- local request = MJMessage.PiaoRequest:new()
- request.isPiao = 0
- self.ui:sendMsg(app.room,MJDefine.MJEvent.PiaoRequest,request)
- end)
-
- for i=1,5 do
- local uiButton = string.format("Button_Piao_%d",i)
- ui.Items[uiButton]:registerClick(function()
- playBtnEffect()
- self:hidePiao()
- local request = MJMessage.PiaoRequest:new()
- request.isPiao = i
- self.ui:sendMsg(app.room,MJDefine.MJEvent.PiaoRequest,request)
- end)
- end
-
- end
-
- function ncmajRoomView:hidePiao()
- if self.piao then
- self.piao:removeFromParent()
- self.piao=nil
- end
- end
-
- --显示飘操作按钮
- function ncmajRoomView:onStartPiao(response)
- local function runPiao(onEnd)
- logD("ncmajRoomView:onStartPiao")
- self:showPiao()
- if onEnd then
- onEnd()
- end
- end
- logD("ncmajRoomView:runPiao")
- self:addCallBack(runPiao)
- end
-
- --飘结果
- function ncmajRoomView:onPiaoResponse(response)
- local function runonPiaoResponse(onEnd)
- logD("ncmajRoomView:runonPiaoResponse")
- local data = response.response
- local userId = data.nUserId--操作的玩家
-
- local playersPiaostate = data.playerPiaoState--所有玩家的飘状态
- if playersPiaostate then
- for i,v in pairs(playersPiaostate) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- local myUserId = app.room:getMyUserId()
- local userInfo=app.room:getUserInfoByViewId(viewId)
-
-
- if myUserId == data.nUserId then
- else
- end
- self.playerView:showPiao(viewId,v.piaostate)
- app.room.roomInfo.memberList[v.nUserId].isPiao = v.piaostate
- if v.piaostate>0 and userId == v.nUserId then
- --飘音效
- MJSound.PlayPiaoSound(userInfo.sex)
- local effect = MJAnimationCompnent.CreatePiaoEffect()
- if effect then
- self.ui.Items.Layout_Effect_luobo:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end
- end
- end
- else
- local viewId = app.room:getViewIdByUserId(userId)
- self.playerView:showPiao(viewId,data.piaostate)
- app.room.roomInfo.memberList[userId].isPiao = data.piaostate
- if data.piaostate and data.piaostate > 0 then
- --飘音效
- local userInfo=app.room:getUserInfoByViewId(viewId)
- MJSound.PlayPiaoSound(userInfo.sex)
- local effect = MJAnimationCompnent.CreatePiaoEffect()
- if effect then
- self.ui.Items.Layout_Effect_luobo:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end
- end
- end
- if onEnd then
- onEnd()
- end
- end
- logD("ncmajRoomView:runonPiaoResponse--------")
- self:addCallBack(runonPiaoResponse)
- end
-
- function ncmajRoomView:showBaoJiao()
- self:hideBaoJiao()
- local ui=loadUI("mj_ncmaj/res/ui_fangjian/mj_ncmaj_baojiao.ui")
- self:addChild(ui)
- self.baojiao=ui
-
- ui.Items.Button_Bao:registerClick(function()
- playBtnEffect()
- self:hideBaoJiao()
- local request = MJMessage.BaoPaiRequest:new()
- request.isBaoPai = 1
- logD(request.isBaoPai,"发送爆:1")
- self.ui:sendMsg(app.room, MJDefine.MJEvent.BaoPaiRequest, request)
- end)
-
- ui.Items.Button_guo:registerClick(function()
- playBtnEffect()
- self:hideBaoJiao()
- local request = MJMessage.BaoPaiRequest:new()
- request.isBaoPai = 0
- logD(request.isBaoPai,"发送爆:0")
- self.ui:sendMsg(app.room, MJDefine.MJEvent.BaoPaiRequest, request)
- end)
-
- --[[local gameInfo =json.decode(app.room.roomInfo.strGameInfo);
- if gameInfo.baojiao then
- ui.Items.Button_Bao:setVisible(gameInfo.baojiao == 1);
- end--]]
- ui.Items.Layout_baojiao:requestDoLayout()
- ui.Items.Layout_baojiao:doLayout();
- end
-
- function ncmajRoomView:hideBaoJiao()
- if self.baojiao then
- self.baojiao:removeFromParent()
- self.baojiao=nil
- end
- end
-
- function ncmajRoomView:onHostingRequest( data )
- local response = data.response
- local userCnt = response.userCnt;
- local myUserId = app.room:getMyUserId()
- if userCnt then
- self.playerView:resetTuoGuanShow(false)
- 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 myUserId == nUserID then
- if isTuoGuan then
- self.toolView:showTuoGuan(true)
- app.room.roomInfo.hosting = 1
- else
- self.toolView:showTuoGuan(false)
- app.room.roomInfo.hosting = 0
- end
- if isTuoGuan then
- self:hidePiao()
- --self:hideBaoJiao()
- end
- end
- self.playerView:showTuoGuanByViewId(viewId,isTuoGuan)
- end
- end
- end
-
- ---
- -- 检测是否可以解散房间
- -- @param
- -- @return
- --
- function ncmajRoomView: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
- if roomInfo.isEapCreate == 1 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
-
- return ncmajRoomView
|