Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

3722 linhas
110 KiB

  1. local ZPDef = ZPFramework.ZPImport("zp_base.luaScript.ZPDef")
  2. local ZPRoomView = ZPFramework.ZPFrameworkClassImprot("zp_base.luaScript.Views.Room.ZPRoomView")
  3. local PokerUtil = require("zp_doushisi.luaScript.Views.Room.doushisiPokerUtil")
  4. local ZPMessage = ZPFramework.ZPImport("zp_base.luaScript.Protocol.ZPMessage")
  5. local PokerCardNode = require("zp_doushisi.luaScript.Views.Room.doushisiCardNode")
  6. local DoushisiRoomConfig = require("zp_doushisi.luaScript.Views.Room.doushisiRoomConfig")
  7. local ZPFuc = ZPFramework.ZPImport("zp_base.luaScript.ZPFunctions")
  8. local ZPRoomQuickStartView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomQuickStartView")
  9. local ZPRoomPlayerView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomPlayerView")
  10. local ZPRoomToolView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomToolView")
  11. local ZPRoomXiaoJuChaPaiView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomXiaoJuChaPaiView")
  12. local DouShiSiRoomOperationView=ZPFramework.ZPImport("zp_doushisi.luaScript.Views.Room.doushisiRoomOperationView")
  13. local doushisiRoomXiaoJuView=ZPFramework.ZPImport("zp_doushisi.luaScript.Views.Room.doushisiRoomXiaoJuView")
  14. local doushisiRoomSettingView=ZPFramework.ZPImport("zp_doushisi.luaScript.Views.Room.doushisiRoomSettingView")
  15. local ZPRoomCountAllView=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomCountAllView")
  16. local ZPWanFa=ZPFramework.ImportWanFa("luaScript.SubGameDefine.ZiPai.ZPWanFa")
  17. local QiPaiView = require("zp_doushisi.luaScript.Views.Room.doushisiQiPaiView")
  18. local GroupCardView = require("zp_doushisi.luaScript.Views.Room.doushisiGroupCardView")
  19. local ZPSound = ZPFramework.ZPImport("zp_base.luaScript.ZPSound")
  20. local CENTER_X=640*g_radio_x
  21. local CENTER_Y=360*g_radio_y
  22. local doushisiRoomView = class("doushisiRoomView", ZPRoomView)
  23. function doushisiRoomView:ctor()
  24. doushisiRoomView.super.ctor(self)
  25. self._selfCards = {}
  26. for i = 1,ZPDef.GameMaxPlayer do
  27. self._selfCards[i] = {}
  28. end
  29. --是否是起手操作的标志
  30. self.isQiShou = true
  31. --操作牌数组
  32. self.opOutCard = {}
  33. --摸牌
  34. self.moValue = 0
  35. --要吃的那张牌
  36. self.chiCard = 0
  37. --是否包赔
  38. self.isBaopei = 0
  39. --是否是必吃的牌
  40. self.isBiChi = 0 --是否必吃
  41. --点击过后是否需要提示包赔
  42. self.isTishi = false
  43. --弃牌的缩放大小
  44. self.littleCardScale = 0.4
  45. --报叫的状态
  46. self.baoJiaoStatus = 0
  47. self.outCardScale = 0.5
  48. self.qiPaiView = {}
  49. self.touchPoker = nil
  50. end
  51. function doushisiRoomView:onEnter()
  52. doushisiRoomView.super.onEnter(self)
  53. end
  54. function doushisiRoomView:loadRoomUI()
  55. local ui = loadUI("zp_doushisi/res/ui/ui_fangjian/doushisi_ui_fangjian.ui");
  56. self.ui = ui;
  57. self:addChild(ui);
  58. end
  59. function doushisiRoomView:initBaseNode()
  60. --自己的出生坐标,视图是4
  61. self.boxPosList4 = {}
  62. local weaveCardPos4 = self.ui.Items.Layout_StartPos:getPosition()
  63. for i = 1, self.lieShuMax do
  64. --矩形3
  65. self.boxPosList4[i] = cc.p(weaveCardPos4.x + 90 * (i - 1),weaveCardPos4.y)--手牌间隙改这里
  66. end
  67. self.leftCardNumPos = self.ui.Items.TextBMFont_leftCardNum:getPosition()
  68. --坐标记录
  69. self.srcOutCardPosList = {}
  70. self.scorePosList = {}
  71. for k = 1,ZPDef.GameMaxPlayer do
  72. local name = string.format("Layout_outCardPoint_%d",k)
  73. local imgName = string.format("ImageView_outCardImg_%d",k)
  74. self.ui.Items[name]:setScale(self.outCardScale)
  75. self.srcOutCardPosList[k] = self.ui.Items[imgName]:getPosition()
  76. --操作分数坐标
  77. --name = string.format("TextBMFont_Score_%d",k)
  78. --self.scorePosList[k] = self.ui.Items[name]:getPosition()
  79. end
  80. --初始化扎鸟
  81. self.PlayerView:initPlayerPiaoFenByRule()
  82. local timestr = os.date("%y-%m-%d %H:%M:%S")
  83. self.ui.Items.Text_systemTime:setText(timestr)
  84. --定时器
  85. if not self.Time then
  86. self.Time = cc.Director:getInstance():getScheduler():scheduleScriptFunc(function()
  87. local timestr = os.date("%y-%m-%d %H:%M:%S")
  88. self.ui.Items.Text_systemTime:setText(timestr)--(getTimeString())
  89. end,1.0,false)
  90. end
  91. --创建弃牌层
  92. for i = 1, ZPDef.GameMaxPlayer do
  93. self.qiPaiView[i] = QiPaiView:new(i)
  94. self.qiPaiView[i]:setPosition(DoushisiRoomConfig.DISCARD_START_POS[i])
  95. self.ui.Items.Layout_QiPai:addChild(self.qiPaiView[i])
  96. end
  97. --[[ for i = 1, ZPDef.GameMaxPlayer do
  98. local touNode = string.format("Layout_tuopai_%d",i)
  99. self.ui.Items[touNode]:setVisible(false)
  100. end--]]
  101. for i = 1, ZPDef.GameMaxPlayer do
  102. self.opOutCard[i] = GroupCardView:new(i)
  103. self.opOutCard[i]:setPosition(DoushisiRoomConfig.GROUPCARD_START_POS[i])
  104. self.ui.Items.Layout_GroupCard:addChild(self.opOutCard[i])
  105. end
  106. self.ui.Items.ImageView_tou_tip:setVisible(false)
  107. end
  108. function doushisiRoomView:initToolLayer()
  109. --人物头像层
  110. self.PlayerView = ZPRoomPlayerView:new()
  111. self.ui.Items.Layout_Player:addChild(self.PlayerView)
  112. --操作界面(吃碰杠胡)
  113. self.operationView = DouShiSiRoomOperationView:new()
  114. --self.operationView:setVisible(false)
  115. self.ui.Items.Layout_Tool:addChild(self.operationView)
  116. --加载工具层
  117. self.toolView = ZPRoomToolView:new()
  118. self.ui.Items.Layout_Tool:addChild(self.toolView)
  119. local headInfos = {}
  120. for k,v in pairs(self.PlayerView.allNodes) do
  121. if k == 2 then
  122. local pos = cc.pAdd(v.player:getPosition(),cc.p(150,30))
  123. table.insert(headInfos,{headPos=pos})
  124. elseif k == 4 then
  125. local pos = cc.pAdd(v.player:getPosition(),cc.p(40,40))
  126. table.insert(headInfos,{headPos=pos})
  127. elseif k == 3 then
  128. local pos = cc.pAdd(v.player:getPosition(),cc.p(40,40))
  129. table.insert(headInfos,{headPos=pos})
  130. elseif k == 1 then
  131. local pos = cc.pAdd(v.player:getPosition(),cc.p(0,40))
  132. table.insert(headInfos,{headPos=pos})
  133. end
  134. end
  135. self.playerPos = headInfos
  136. -- 小局查牌界面
  137. self.xiaojuChaPaiView = ZPRoomXiaoJuChaPaiView:new(self.colorType)
  138. self.xiaojuChaPaiView:setVisible(false)
  139. --亮牌界面确定
  140. local function cb()
  141. --显示小局结算
  142. if self.xiaojuView then
  143. self.xiaojuView:setVisible(true)
  144. end
  145. end
  146. self.xiaojuChaPaiView:setQueDingCallBack(cb)
  147. self.xiaojuChaPaiView:showHuCardCallBack(handler(self , self.onShowHuCard))
  148. self:addChild(self.xiaojuChaPaiView)
  149. end
  150. -- 设置房间信息
  151. function doushisiRoomView:setRoomInfo()
  152. self.ui.Items.ListView:removeAllChildren()
  153. self.ui.Items.ListView:getInnerContainer():setAutoSize(true)
  154. local rules = ZPWanFa.getClubRuleInfo(app.room.roomInfo.strGameInfo)
  155. for k,v in pairs(rules) do
  156. local text = self.ui.Items.Text_Rule:getCopied()
  157. text:setVisible(true)
  158. text:setString(tostring(v.value[1]))
  159. self.ui.Items.ListView:addChild(text)
  160. end
  161. self.ui.Items.ListView:jumpToTopOnSizeChanged();
  162. end
  163. --显示提牌按钮
  164. function doushisiRoomView:showTiPaiBtn(vis)
  165. vis = vis or false
  166. self.ui.Items.Button_tipai:setVisible(false)
  167. end
  168. function doushisiRoomView:onGameReconnection()
  169. --logE("ZiPai当前版本号:"..ZPFuc.getZPCurVersion())
  170. --更新房间基础数据
  171. self:updateRoomBaseData()
  172. local roomInfo = app.room.roomInfo;
  173. --self:updateAllGpsInfo()
  174. --self:checkGpsDistance(nil,roomInfo.nGameStartCount==0)
  175. --self:checkMyGpsNeedUpdate();
  176. --断线重连
  177. if roomInfo.nGameStartCount > 0 then
  178. local function runOnGameReconnection(onEnd)
  179. self.isQiShou = false
  180. local roomInfo = app.room.roomInfo;
  181. self.ui.Items.ImageView_handTempCard:stopAllActions()
  182. --显示庄家
  183. self:updateBanker()
  184. self:showOwner()
  185. self:showXiaojia()
  186. local myUserID = app.room:getMyRecordUserId()
  187. --解散状态
  188. local isDismiss = false
  189. local uid = 0
  190. for k,v in pairs(roomInfo.arrayTableInfo) do
  191. local viewId = app.room:getViewIdByUserId(k)
  192. local nOffLineState = v.nOnlineStatus
  193. --显示离线
  194. self.PlayerView:setPlayerOffLine(nOffLineState ~= 1,viewId)
  195. local viewId = app.room:getViewIdByUserId(k)
  196. --记录玩家解散状态 0:初始状态, 1:发起解散 2: 同意解散 3:不同意解散
  197. app.room.dismissInfo[k] = v.nDisbandStatus;
  198. app.room.roomInfo.memberList[k].nDisbandStatus = v.nDisbandStatus;
  199. --有人发起解散时才显示解散界面
  200. if v.nDisbandStatus == 1 then
  201. isDismiss = true
  202. uid = k
  203. end
  204. end
  205. --有人发起解散时才显示解散界面
  206. if isDismiss then
  207. app.room.roomInfo.nDismissStateTime = roomInfo.nDismissStateTime;
  208. app.room.roomInfo.nDismissToTalTime = roomInfo.nDismissToTalTime;
  209. local view = require("luaScript.Views.Room.RoomDismissView"):new(uid,app.room.roomInfo.memberList,roomInfo.nDismissStateTime)
  210. view:setAnchorPoint(cc.p(0.5, 0.5));
  211. app:showWaitDialog(view);
  212. end
  213. --如果一局结束,玩家点了准备,不再显示牌信息
  214. if ZPDef.ReconnectState.GAME_STATUS_ROUND_OVER == roomInfo.nStatus and roomInfo.memberList[myUserID].nPlayerFlag == 1
  215. or ZPDef.ReconnectState.GAME_STATUS_GAME_OVER == roomInfo.nStatus and roomInfo.memberList[myUserID].nPlayerFlag == 1
  216. then --游戏为停止或开始状态
  217. self:onUserReadyResponse()
  218. self.ui.Items.Button_tipai:setVisible(false)
  219. if onEnd then
  220. onEnd()
  221. end
  222. return
  223. end
  224. --胡牌类型
  225. local huType = ZPDef.ReconnectHuType.NO_HU
  226. --状态显示
  227. if ZPDef.ReconnectState.GAME_STATUS_ROUND_OVER == roomInfo.nStatus
  228. or ZPDef.ReconnectState.GAME_STATUS_GAME_OVER == roomInfo.nStatus then --游戏为停止或开始状态
  229. for hi,hv in pairs(app.room.roomInfo.hupaiInfo) do
  230. if hv.huPaiUid > -1 then
  231. app.room.roomInfo.baopeiUserid =app.room:getUserIdBySeatId(hv.BaoPeiUid)
  232. app.room.roomInfo.fourNormolNum = hv.fourNormolNum
  233. app.room.roomInfo.threeNormolNum = hv.threeNormolNum
  234. end
  235. end
  236. self.ui.Items.Button_tipai:setVisible(false)
  237. --显示小局结算亮牌画布
  238. self:setLiangPaiVisible(true)
  239. --显示底牌
  240. self.xiaojuChaPaiView:showDiPai()
  241. --亮手牌
  242. huType = self.xiaojuChaPaiView:liangShouPai(true)
  243. local function nextCallBackFun()
  244. self:resetGameData()
  245. end
  246. self.xiaojuView = doushisiRoomXiaoJuView:new(nextCallBackFun,true,self.colorType)
  247. self:addChild(self.xiaojuView)
  248. --播放黄庄动画
  249. if roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_HUANG_ZHUANG then
  250. local userInfo=app.room:getUserInfo(app.user.loginInfo.uid)
  251. if userInfo then
  252. ZPSound.PlayHuangZhuang(userInfo.sex)
  253. end
  254. self.xiaojuChaPaiView:PlayHuangZhuangAni(false)
  255. end
  256. self.xiaojuView:setVisible(true)
  257. self:setBtnSitDownVisible(false)
  258. end
  259. local diPaiMax = table.nums(roomInfo.dipaiList)
  260. for k,v in pairs(roomInfo.arrayTableInfo) do
  261. local viewId = app.room:getViewIdByUserId(k)
  262. local nScore = v.nTotalMoney or 0
  263. --玩家分数
  264. self.PlayerView:setPlayerScore(viewId,nScore)
  265. --扎鸟
  266. --self.PlayerView:setPlayerPiaoFen(viewId,v.nZhaBirdScore)
  267. --恢复手牌
  268. if k == myUserID then
  269. self:createCard(false,myUserID,nil)
  270. end
  271. --恢复爆牌动画
  272. if v.nBaoPaiStatus == 2 and not (ZPDef.ReconnectState.GAME_STATUS_ROUND_OVER == roomInfo.nStatus
  273. or ZPDef.ReconnectState.GAME_STATUS_GAME_OVER == roomInfo.nStatus) and viewId == self:getMeViewId() then
  274. --self.PlayerView:playBaoAnim(viewId)
  275. self.baoJiaoStatus = 1 --已经报叫
  276. local nBankerSeatId = app.room.roomInfo.nBankSeatId
  277. local toujiaViewId = app.room:getViewIdBySeatId(nBankerSeatId)
  278. local nSeatId = roomInfo.showCardSeatId
  279. local curOpViewId = app.room:getViewIdBySeatId(nSeatId)
  280. if ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_BAO == roomInfo.nStatus
  281. or ZPDef.ReconnectState.GAME_STATUS_WAIT_BANKER_OUTCARD == roomInfo.nStatus
  282. and viewId == toujiaViewId then --当前是庄家出牌并且自己的ID是头家 这时候放开出牌,其他时候手牌全锁
  283. elseif (ZPDef.ReconnectState.GAME_STATUS_WAIT_OUT_CARDS == roomInfo.nStatus or ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_TOU == roomInfo.nStatus)
  284. and curOpViewId == viewId then --如果报叫后进了牌,则只能打进的牌
  285. app.room.roomInfo.tingCards = {}
  286. table.insert(app.room.roomInfo.tingCards, app.room.roomInfo.curEnterCard)
  287. else
  288. app.room.roomInfo.tingCards = {}
  289. end
  290. self:lockMyHandCards()
  291. end
  292. if v.nBaoPaiStatus == 2 then
  293. self.PlayerView:setPlayerBaoJiaoVisible(viewId,true)
  294. end
  295. local hushu = 0
  296. --恢复组合牌
  297. for key,value in pairs(v.tableWeaveCard) do
  298. local isShow = true
  299. local card = value.opcard
  300. local optype = value.type
  301. local list = value.card
  302. --上面吃或不吃不要用if else因为还可能都不成立
  303. --创建桌面操作牌
  304. self:recontactDoOperation(viewId,list,optype)
  305. end
  306. self.tableHuXiList[viewId] = hushu
  307. --self.PlayerView:setPlayerHuXi(viewId,hushu)
  308. --self.PlayerView:setPlayerHuXi("油:"..tostring(hushu))
  309. if viewId ~= self:getMeViewId() then
  310. self.PlayerView:setLeftCardNum(viewId,true,tonumber(v.leftCardNum))
  311. else
  312. self.myHandCardNums = tonumber(v.leftCardNum)
  313. end
  314. end
  315. --恢复弃牌
  316. for k,v in pairs(roomInfo.arrayTableInfo) do
  317. local viewId = app.room:getViewIdByUserId(v.nUserId)
  318. for key,value in pairs(v.desertedArea) do
  319. --普通弃牌
  320. self:playQiPaiAni(false,value.card,viewId,nil,false)
  321. end
  322. end
  323. --听牌显示
  324. local max = table.nums(app.room.roomInfo.tingCards)
  325. if max > 0 then
  326. --self:setTingCardViewVisible(true,app.room.roomInfo.tingCards)
  327. end
  328. --显示玩家剩余手牌
  329. if app.room.roomInfo.offLineInfo and next(app.room.roomInfo.offLineInfo) ~= nil then
  330. for i,v in pairs(app.room.roomInfo.offLineInfo) do
  331. if v.extInfo then
  332. local extIf = json.decode(v.extInfo)
  333. if extIf.HuShu and v.nUserId then
  334. local viewId = app.room:getViewIdByUserId(v.nUserId)
  335. end
  336. end
  337. end
  338. end
  339. --吃后巴后油牌
  340. local viewId = app.room:getViewIdBySeatId(roomInfo.showCardSeatId)
  341. if app.room.roomInfo.disCard and ZPDef.ReconnectState.GAME_STATUS_WAIT_OUT_CARDS == roomInfo.nStatus and viewId == self:getMeViewId() then
  342. self:lockYouPai(app.room.roomInfo.disCard)
  343. end
  344. local myViewId = self:getMeViewId()
  345. --状态显示
  346. if ZPDef.ReconnectState.GAME_STATUS_ROUND_OVER == roomInfo.nStatus
  347. or ZPDef.ReconnectState.GAME_STATUS_GAME_OVER == roomInfo.nStatus then --游戏为停止或开始状态
  348. self.PlayerView:hideLeftCard()
  349. --所有的暗偎默认亮起一张
  350. --self:showLastAnWeiPai()
  351. --点炮显示
  352. --self:showPaoImage()
  353. for hi,hv in pairs(app.room.roomInfo.hupaiInfo) do
  354. if hv.huPaiUid > -1 then
  355. local winerViewId = app.room:getViewIdByUserId(hv.huPaiUid)
  356. app.room.roomInfo.huType = hv.huTypes
  357. app.room.roomInfo.baopeiUserid =app.room:getUserIdBySeatId(hv.BaoPeiUid)
  358. self:playHuEffect(winerViewId,nil,true)
  359. end
  360. end
  361. --完成手牌展示
  362. for k,v in pairs(roomInfo.arrayTableInfo) do
  363. local cardData = roomInfo.memberList[v.nUserId].cardList
  364. local viewId = app.room:getViewIdByUserId(v.nUserId)
  365. local lens = table.nums(cardData)
  366. local cardLens = table.nums(self._selfCards[viewId])
  367. if viewId == 1 or viewId == 2 then
  368. cardData = {}
  369. local lens = table.nums(roomInfo.memberList[v.nUserId].cardList)
  370. local list = roomInfo.memberList[v.nUserId].cardList
  371. for i = 1,lens do
  372. cardData[i] = table.remove(list,#list)
  373. end
  374. end
  375. for i = lens+1, cardLens do
  376. if self._selfCards[viewId][i] then
  377. self._selfCards[viewId][i]:setVisible(false)
  378. end
  379. end
  380. if self._selfCards[viewId] then
  381. for i = 1, lens do
  382. if self._selfCards[viewId][i] then
  383. self._selfCards[viewId][i]:setCard(cardData[i])
  384. end
  385. end
  386. end
  387. end
  388. local viewId = self:getMeViewId()
  389. self:setCircleCardLeftPanelView(true,viewId,diPaiMax)
  390. self.PlayerView:setAllClockVisible(false)
  391. elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_TIAN_HU == roomInfo.nStatus
  392. or ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_AFTER_TURN_OVER == roomInfo.nStatus
  393. or ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_TOU == roomInfo.nStatus
  394. or ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_AFTER_OUTCARD == roomInfo.nStatus
  395. or ZPDef.ReconnectState.GAME_STATUS_WAIT_QIANGBA == roomInfo.nStatus then -- 天胡,翻牌后等待玩家操作中,出牌后等待玩家操作中
  396. local nSeatId = roomInfo.showCardSeatId
  397. local nCard = roomInfo.showCard
  398. local operateCode = roomInfo.mainOpCode
  399. local viewId = app.room:getViewIdBySeatId(nSeatId)
  400. local nUserId = app.room:getUserIdBySeatId(nSeatId)
  401. local opCardList = {}
  402. local curOpeateid = roomInfo.curOpreateID --当前操作ID
  403. local curOpView = app.room:getViewIdBySeatId(curOpeateid)
  404. --记录真实数据
  405. self.outCard = nCard
  406. self.EatOperationCode = operateCode
  407. self.moPaiViewId = viewId
  408. if ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_TIAN_HU == roomInfo.nStatus then --等待天胡
  409. local hasGuo = true
  410. self.isQiShou = true
  411. self.isGodHand = true
  412. local curOpView = app.room:getViewIdBySeatId(curOpeateid)
  413. local operationCardlist = {}
  414. if #roomInfo.startOpList.BacardList > 0 then
  415. operationCardlist[ZPDef.OpCode.OP_BA_QI_SHOU] = {}
  416. for k,v in pairs(roomInfo.startOpList.BacardList or {}) do
  417. table.insert(operationCardlist[ZPDef.OpCode.OP_BA_QI_SHOU],v)
  418. end
  419. end
  420. --操作码
  421. if #roomInfo.startOpList.ToucardList > 0 then
  422. operationCardlist[ZPDef.OpCode.OP_TOU_QI_SHOU] = {}
  423. local toulist = {}
  424. for k,v in pairs(roomInfo.startOpList.ToucardList or {}) do
  425. for _,value in pairs(v.cardlist) do
  426. table.insert(toulist,value)
  427. end
  428. table.insert(operationCardlist[ZPDef.OpCode.OP_TOU_QI_SHOU],toulist)
  429. toulist = {}
  430. end
  431. end
  432. local retHu1 = bit32.band(operateCode,ZPDef.OpCode.OP_TIAN_HU)
  433. if self.isQiShou and retHu1 > 0 then
  434. hasGuo = false
  435. end
  436. if curOpView == self:getMeViewId() then
  437. if operateCode > 0 then
  438. self:showOpeation(operateCode,operationCardlist,self.isQiShou,hasGuo) --天胡没有过
  439. end
  440. end
  441. self.ui.Items.ImageView_tou_tip:setVisible(true)
  442. elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_TOU == roomInfo.nStatus then --玩家进牌状态
  443. self.isQiShou = false
  444. self.isGodHand = true
  445. local operationCardlist = {}
  446. if #roomInfo.startOpList.BacardList > 0 then
  447. operationCardlist[ZPDef.OpCode.OP_BA_ZHUA] = {}
  448. for k,v in pairs(roomInfo.startOpList.BacardList or {}) do
  449. table.insert(operationCardlist[ZPDef.OpCode.OP_BA_ZHUA],v)
  450. end
  451. end
  452. --操作码
  453. if #roomInfo.startOpList.ToucardList > 0 then
  454. operationCardlist[ZPDef.OpCode.OP_TOU_ZHUA] = {}
  455. local toulist = {}
  456. for k,v in pairs(roomInfo.startOpList.ToucardList or {}) do
  457. for _,value in pairs(v.cardlist) do
  458. table.insert(toulist,value)
  459. end
  460. table.insert(operationCardlist[ZPDef.OpCode.OP_TOU_ZHUA],toulist)
  461. toulist = {}
  462. end
  463. end
  464. if roomInfo.startOpList.ishu == 1 then
  465. operationCardlist[ZPDef.OpCode.OP_HU] = {}
  466. table.insert(operationCardlist[ZPDef.OpCode.OP_HU],0) --自摸的时候发0
  467. end
  468. if operateCode > 0 then
  469. self:showOpeation(operateCode,operationCardlist,self.isQiShou,true) --天胡没有过
  470. end
  471. elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_AFTER_OUTCARD == roomInfo.nStatus then
  472. --是否已经操作过 0表示没有,非0表示已经提交了操作
  473. self.isQiShou = false
  474. self.isGodHand = true
  475. if roomInfo.isBaopeiCard == 1 then
  476. self.isBiChi = 2
  477. end
  478. if operateCode ~= 0 and roomInfo.isSubmitOp == 0 then
  479. opCardList[ZPDef.OpCode.OP_HU] = {}
  480. table.insert(opCardList[ZPDef.OpCode.OP_HU],nCard)
  481. opCardList[ZPDef.OpCode.OP_PENG] = {}
  482. local penglist = {}
  483. for k,v in pairs(roomInfo.pengCardlist or {}) do
  484. for _,val in pairs(v.cardlist or {}) do
  485. table.insert(penglist,val)
  486. end
  487. table.insert(opCardList[ZPDef.OpCode.OP_PENG],penglist)
  488. penglist = {}
  489. end
  490. opCardList[ZPDef.OpCode.OP_CHI] = {}
  491. for k,v in ipairs(roomInfo.chiPaiList) do
  492. table.insert(opCardList[ZPDef.OpCode.OP_CHI],v)
  493. end
  494. self:showOpeation(operateCode,opCardList,self.isQiShou,true)
  495. self:setOutCardVisible(true,viewId,nCard,false,nil,true)
  496. elseif roomInfo.isSubmitOp == 1 or roomInfo.isSubmitOp == 0 or roomInfo.isSubmitOp == 2 then
  497. self:setOutCardVisible(true,viewId,nCard,false,nil,true)
  498. end
  499. elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_AFTER_TURN_OVER == roomInfo.nStatus then
  500. self.isGodHand = true
  501. if roomInfo.isSubmitOp == 1 then
  502. operateCode = 0
  503. self:playMoPaiAni(diPaiMax,nCard,viewId,operateCode,roomInfo.showCardFlag,nil,true)
  504. elseif roomInfo.isSubmitOp == 0 then --自己摸牌翻牌
  505. local isBaoPeiCard = false
  506. if roomInfo.isBaopeiCard == 1 then
  507. self.isBiChi = 2
  508. end
  509. if roomInfo.isBaopeiGuo == 1 then
  510. self.isTishi = true
  511. end
  512. self:playMoPaiAni(diPaiMax,nCard,viewId,operateCode,roomInfo.showCardFlag,nil,true,isBaoPeiCard,roomInfo.chiPaiList,roomInfo.pengCardlist)
  513. elseif roomInfo.isSubmitOp == 2 then --比牌不显示出牌或者摸牌
  514. operateCode = 0
  515. self:playMoPaiAni(diPaiMax,nCard,viewId,operateCode,roomInfo.showCardFlag,nil,true)
  516. self.operationView:touchEatOneCardCallBack(true)
  517. end
  518. elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_QIANGBA == roomInfo.nStatus then
  519. if operateCode ~= 0 and roomInfo.isSubmitOp == 0 then
  520. opCardList[ZPDef.OpCode.OP_HU] = {}
  521. table.insert(opCardList[ZPDef.OpCode.OP_HU],nCard)
  522. self:showOpeation(operateCode,opCardList,false,true)
  523. end
  524. end
  525. --显示剩余牌
  526. --如果有出的牌,则闹钟显示在该玩家,如果没有则显示在等待操作的玩家
  527. if nCard > 0 then
  528. self:setCircleCardLeftPanelView(true,viewId,diPaiMax)
  529. else
  530. self:setCircleCardLeftPanelView(true,curOpView,diPaiMax)
  531. end
  532. elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OUT_CARDS == roomInfo.nStatus or ZPDef.ReconnectState.GAME_STATUS_WAIT_BANKER_OUTCARD == roomInfo.nStatus then --等待玩家出牌中
  533. --显示底牌
  534. self.isQiShou = false
  535. self.isGodHand = true
  536. local viewId = app.room:getViewIdBySeatId(roomInfo.showCardSeatId)
  537. --显示剩余牌
  538. self:setCircleCardLeftPanelView(true,viewId,diPaiMax)
  539. if viewId == self:getMeViewId() then
  540. self.isGodHand = false
  541. self:setGuideView(true)
  542. self.bOutCard = true
  543. end
  544. elseif ZPDef.ReconnectState.GAME_STATUS_AUTO_DISCSRD == roomInfo.nStatus then --玩家自动弃牌中
  545. self.isQiShou = false
  546. self.isGodHand = true
  547. local nSeatId = roomInfo.showCardSeatId
  548. local nCard = roomInfo.disCard
  549. local viewId = app.room:getViewIdBySeatId(nSeatId)
  550. --显示剩余牌
  551. self:setCircleCardLeftPanelView(true,viewId,diPaiMax)
  552. --弃牌
  553. self:playQiPaiAni(true,nCard,viewId,nil)
  554. elseif ZPDef.ReconnectState.GAME_STATUS_WAIT_OP_BAO == roomInfo.nStatus then --等待玩家爆牌中
  555. --爆牌中
  556. self.isGodHand = true
  557. local viewId = app.room:getViewIdBySeatId(roomInfo.showCardSeatId)
  558. self:setCircleCardLeftPanelView(true,viewId,diPaiMax)
  559. for k,v in pairs(roomInfo.arrayTableInfo) do
  560. local viewId = app.room:getViewIdByUserId(k)
  561. local nBankerSeatId = app.room.roomInfo.nBankSeatId
  562. local toujiaviewId = app.room:getViewIdBySeatId(nBankerSeatId)
  563. if viewId == self:getMeViewId() and viewId ~= toujiaviewId then
  564. app.room.roomInfo.tingCards = {}
  565. end
  566. --等待爆牌状态
  567. if v.nBaoPaiStatus == 1 and k == app.user.loginInfo.uid then
  568. self.operationView:showBaoPaiOpView(true)
  569. end
  570. end
  571. self.ui.Items.ImageView_tou_tip:setVisible(true)
  572. end
  573. if onEnd then
  574. onEnd()
  575. end
  576. end
  577. log("2000000000-ZPRoomView - self:addCallBack(runOnGameReconnection)" )
  578. self:addCallBack(runOnGameReconnection)
  579. else
  580. --未开局正常坐下这里会进来
  581. for k,v in pairs(roomInfo.memberList or {}) do
  582. local viewId = app.room:getViewIdByUserId(k)
  583. local nOffLineState = v.nOnlineStatus or 1
  584. --显示离线
  585. self.PlayerView:setPlayerOffLine(nOffLineState ~= 1,viewId)
  586. end
  587. --未开局重连坐下
  588. for k,v in pairs(roomInfo.arrayTableInfo or {}) do
  589. local viewId = app.room:getViewIdByUserId(k)
  590. local nOffLineState = v.nOnlineStatus
  591. --显示离线
  592. self.PlayerView:setPlayerOffLine(nOffLineState ~= 1,viewId)
  593. end
  594. self.ui.Items.Layout_fapaiqi:setVisible(false)
  595. end
  596. end
  597. --断线重连
  598. function doushisiRoomView:recontactDoOperation(viewId,list,optype)
  599. logD("doushisiRoomView recontactDoOperation")
  600. if optype == ZPDef.SendCardType.TOU_THREE_SAME or optype == ZPDef.SendCardType.CHI_PAI_PENG then
  601. for k,v in ipairs(list) do
  602. self.opOutCard[viewId]:addGroupCard(v,1)
  603. end
  604. elseif optype == ZPDef.SendCardType.BA_FOUR_SAME then
  605. for k,v in ipairs(list) do
  606. self.opOutCard[viewId]:addGroupCard(v,1)
  607. end
  608. elseif optype == ZPDef.SendCardType.TWO_SUM_CHI then
  609. for k,v in ipairs(list) do
  610. self.opOutCard[viewId]:addGroupCard(v,1)
  611. end
  612. end
  613. end
  614. -- 立即开始
  615. function doushisiRoomView:onQuickStartResponse(event)
  616. log("2000000000-doushisiRoomView - runnQuickStartResponse()" )
  617. if not event or not event.response then
  618. return
  619. end
  620. logE("onQuickStartResponse() response = ", event.response)
  621. local response = event.response
  622. --app.room.roomInfo.nShowDismiss = true
  623. local isStart = true
  624. local selectNums = table.nums(app.room.quickStartInfo)
  625. for i,v in pairs(app.room.quickStartInfo) do
  626. if v > 1 then
  627. --有人投过票
  628. isStart = false
  629. end
  630. end
  631. if tolua.isnull(self.quickStartView) then
  632. for i,v in pairs(app.room.quickStartInfo) do
  633. if v == 1 then
  634. self.quickStartView = ZPRoomQuickStartView:new(i);
  635. self.quickStartView:setAnchorPoint(cc.p(0.5, 0.5));
  636. app:showWaitDialog(self.quickStartView);
  637. log("onQuickStartResponse() v = 1 "..i )
  638. return
  639. else
  640. local startuid = 0
  641. for i,v in pairs(app.room.quickStartInfo) do
  642. if v == 1 then
  643. startuid = i
  644. end
  645. end
  646. self.quickStartView = ZPRoomQuickStartView:new(startuid);
  647. self.quickStartView:setAnchorPoint(cc.p(0.5, 0.5));
  648. app:showWaitDialog(self.quickStartView);
  649. log("onQuickStartResponse() v ~= 1 "..i )
  650. return
  651. end
  652. end
  653. end
  654. end
  655. --更新房间基础数据
  656. function doushisiRoomView:updateRoomBaseData()
  657. --初始化背景
  658. local ZiPaigameBgPicture = "gameBgPicture"..(ZPDef.GameID or app.gameId)
  659. local idx2 = tonumber(loadUserInfo(ZiPaigameBgPicture)) or 2
  660. self:setTableImg(idx2)
  661. local roomInfo = app.room.roomInfo;
  662. -- 房间号
  663. self.ui.Items.Text_roomNum:setText(tostring(roomInfo.nShowTableId));
  664. --局数
  665. self:updateGameNums()
  666. --房间玩法
  667. --local ruleAll = ZPFuc.getRuleInfo();
  668. --self.toolView.ui.Items.Text_Rule:setText(ruleAll)
  669. self:setRoomInfo()
  670. self:onUserReadyResponse()
  671. for i = 1,ZPDef.GameMaxPlayer do
  672. self.PlayerView:updatePlayerInfo(i)
  673. end
  674. -- 是否显示邀请好友
  675. self:setWetChatVisible(table.nums(app.room.roomInfo.memberList) < ZPFuc.getCreateRoomPlayerNum())
  676. self.toolView:showFastStart(true)
  677. if isReviewVersion() then
  678. self:setWetChatVisible(false);
  679. end
  680. -- 更新玩家手牌列表时,按需显示
  681. if app.room.roomInfo.nGameStartCount > 0 then
  682. self:setWetChatVisible(false)
  683. end
  684. if app.room.roomInfo.nGameStartCount == 0 then
  685. self.ui.Items.Button_tipai:setVisible(false)
  686. end
  687. end
  688. function doushisiRoomView:setTableImg(idx)
  689. local name = string.format("zp_doushisi/res/ui/zy_fangjian/bg/fangjian_di_%d.jpg",idx)
  690. --桌布
  691. self.ui.Items.ImageView_bg:loadTexture(name)
  692. local cacheGameBgPic = "gameBgPicture"..(ZPDef.GameID or app.gameId)
  693. saveUserInfo(cacheGameBgPic,idx)
  694. end
  695. function doushisiRoomView:loadTextureCache()
  696. doushisiRoomView.super.loadTextureCache(self)
  697. ZPFuc.loadSpriteFromFile("zp_doushisi/res/ui/zy_fangjian/cards/zy_dss_handcards.plist")
  698. ZPFuc.loadSpriteFromFile("zp_doushisi/res/ui/zy_fangjian/cards/zy_dss_outCard.plist")
  699. ZPFuc.loadSpriteFromFile("zp_doushisi/res/ui/zy_fangjian/cards/zy_dss_hu_cards.plist")
  700. end
  701. --改变外发光颜色
  702. function doushisiRoomView:changeOutCardLight(isMoPai)
  703. end
  704. --隐藏提示界面
  705. function doushisiRoomView:setGuideView(bVisible)
  706. if app.room:isLittleFamily() then
  707. bVisible = false
  708. end
  709. self.ui.Items.Layout_tips:setVisible(false)
  710. self.ui.Items.Button_OutCard:setVisible(false)
  711. self.ui.Items.Button_OutCard:setEnabled(false)
  712. self.ui.Items.ImageView_OutCard_tip:setVisible(bVisible)
  713. --[[ if bVisible then
  714. self.ui.Items.ImageView_3:playClip("tip")
  715. end--]]
  716. end
  717. --隐藏出牌点
  718. function doushisiRoomView:setOutCardVisible(bVisible,viewId,card,isSend,onEnd,isNoShowAni)
  719. for i = 1 ,ZPDef.GameMaxPlayer do
  720. local name = string.format("Layout_outCardPoint_%d",i)
  721. self.ui.Items[name]:setVisible(false)
  722. end
  723. --重置出牌坐标
  724. self:resetOutCardPoint()
  725. --显示出牌
  726. if bVisible then
  727. self.isMoPaiOperator = false
  728. self:changeOutCardLight(false)
  729. local name = string.format("Layout_outCardPoint_%d",viewId)
  730. local mLayout = self.ui.Items[name]
  731. mLayout:setVisible(true)
  732. local imgName = string.format("ImageView_outCardImg_%d",viewId)
  733. local fileName = PokerUtil.pokerPng(card,ZPDef.CardType.CARD_TYPE_HAND)
  734. local mSprite = self.ui.Items[imgName]
  735. local srcPos = mSprite:getPosition()
  736. self.ui.Items[imgName]:loadTextureFromPlist(fileName)
  737. local beginPos
  738. local time = self.gameSpeedConfig.CHU_PAI_TIME
  739. if viewId == self:getMeViewId() then
  740. beginPos = self.ui.Items.ImageView_handTempCard:getPosition()
  741. beginPos = mSprite:getParent():convertToNodeSpace(beginPos)
  742. else
  743. if viewId == 1 then
  744. beginPos = cc.p(srcPos.x + 400,srcPos.y)
  745. elseif viewId == 2 then
  746. beginPos = cc.p(srcPos.x,srcPos.y + 200)
  747. elseif viewId == 3 then
  748. beginPos = cc.p(srcPos.x - 400,srcPos.y)
  749. end
  750. end
  751. mSprite:setPosition(beginPos)
  752. mSprite:setScale(0)
  753. if isNoShowAni then
  754. mSprite:setScale(1)
  755. mSprite:setPosition(srcPos)
  756. if onEnd then
  757. onEnd()
  758. end
  759. return
  760. end
  761. local spawn = cc.Spawn:create(cc.ScaleTo:create(time,1,1),cc.MoveTo:create(time,srcPos))
  762. local seq = cc.Sequence:create(spawn,cc.CallFunc:create(function ()
  763. if isSend then
  764. local request = ZPMessage.OutCard:new()
  765. request.nCard = card
  766. --默认包赔为0
  767. request.baoPei = 0
  768. logE("doushisiRoomView:setOutCardVisible"..table.tostring(request))
  769. self.ui:sendMsg(app.room, "sendOutCard", request, function(status, response)
  770. logE("doushisiRoomView sendOutCard() response = ", table.tostring(response))
  771. end)
  772. end
  773. if onEnd then
  774. onEnd()
  775. end
  776. end))
  777. mSprite:runAction(seq)
  778. end
  779. end
  780. function doushisiRoomView:initGameButton()
  781. --出牌按钮
  782. self.ui.Items.Button_OutCard:registerClick(function()
  783. local value = self.ui.Items.ImageView_handTempCard.value
  784. --send sender
  785. self.isGodHand = true;
  786. self.touchPoker:setOpacity(0)
  787. self:setCardNormal()
  788. self:sendOutCard(value)
  789. self.bOutCard = false
  790. end)
  791. --提牌按钮
  792. self.ui.Items.Button_tipai:registerClick(function()
  793. self:requestFlashHandCard()
  794. end)
  795. --暂时屏蔽提牌功能
  796. self:showTiPaiBtn(true)
  797. --点击空白
  798. self.ui.Items.Layout_Touch:registerClick(nil,function()
  799. --[[ local list = {13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13}
  800. for i = 1,ZPDef.GameMaxPlayer do
  801. for k,v in pairs(list) do
  802. self.opOutCard[i]:addGroupCard(v,1)
  803. end
  804. end--]]
  805. --[[ for i = 1 ,ZPDef.GameMaxPlayer do
  806. self:setOutCardVisible(true,i,13,false,nil,true)
  807. end--]]
  808. --[[ for i = 1,ZPDef.GameMaxPlayer do
  809. self.PlayerView.allNodes[i].player:setVisible(true)
  810. end
  811. local fapaiList = {
  812. [1] = {
  813. list = {0,0,0,0,0,0,0,0},
  814. num = 8,
  815. viewId = 4,
  816. },
  817. [2] = {
  818. list = {0,0,0,0,0,0,0},
  819. num = 8,
  820. viewId = 3,
  821. },
  822. [3] = {
  823. list = {0,0,0,0,0,0,0},
  824. num = 8,
  825. viewId = 2,
  826. },
  827. [4] = {
  828. list = {0,0,0,0,0},
  829. num = 8,
  830. viewId = 1,
  831. }
  832. }
  833. --self:sendCards(fapaiList)
  834. self:runAction(cc.Sequence:create(cc.CallFunc:create(function()
  835. self:sendCards(fapaiList)
  836. end),cc.DelayTime:create(0.8),cc.CallFunc:create(function()
  837. local viewId = self:getMeViewId()
  838. local lens = table.nums(self._selfCards[viewId])
  839. self.handCardItem = self._selfCards[viewId]
  840. for i = 1,lens do
  841. local card = self._selfCards[viewId][i]:getVal()
  842. table.insert(self.handCardValueLocal,card)
  843. end
  844. --注册点击
  845. self:registerCardTouch()
  846. if onEnd then
  847. onEnd()
  848. end
  849. end)))--]]
  850. --隐藏工具界面 详情
  851. if self.toolView.ui.Items.ImageView_Rule_bg then
  852. self.toolView.ui.Items.ImageView_Rule_bg:setVisible(false)
  853. end
  854. self.ui.Items.Layout_Rule:setVisible(false)
  855. self.ui.Items.Button_wanfa:setVisible(true)
  856. end)
  857. -- 玩法
  858. self.ui.Items.Button_wanfa:registerClick(function ()
  859. playBtnEffect()
  860. self.ui.Items.Layout_Rule:setVisible(not self.ui.Items.Layout_Rule:isVisible())
  861. self.ui.Items.Button_wanfa:setVisible(false)
  862. end)
  863. if app.room.roomInfo.nGameStartCount and app.room.roomInfo.nGameStartCount > 0 then
  864. self.ui.Items.Layout_Rule:setVisible(false)
  865. else
  866. self.ui.Items.Layout_Rule:setVisible(true)
  867. self.ui.Items.Button_wanfa:setVisible(false)
  868. self.ui.Items.Layout_Rule:runAction(cc.Sequence:create(
  869. cc.DelayTime:create(2),
  870. cc.CallFunc:create(function()
  871. self.ui.Items.Layout_Rule:setVisible(false)
  872. self.ui.Items.Button_wanfa:setVisible(true)
  873. end)))
  874. end
  875. self.ui.Items.Text_Rule:setVisible(false)
  876. local bar = self.ui.Items.ListView:getVBar()
  877. bar:setVisible(false)
  878. end
  879. function doushisiRoomView:showXiaojia()
  880. self.PlayerView:hideXiaoJia()
  881. --只显示当前的庄家座位号
  882. local nBankerSeatId = app.room.roomInfo.xiaoSeatId
  883. local viewId = app.room:getViewIdBySeatId(nBankerSeatId)
  884. self.PlayerView:setPlayerXiaoJiaVisible(viewId,true)
  885. end
  886. --更新头家家
  887. function doushisiRoomView:updateBanker()
  888. --隐藏所有的庄家头家标志
  889. self.PlayerView:setBankerVisible()
  890. self.PlayerView:hideTouJia()
  891. --只显示当前的庄家座位号
  892. local nBankerSeatId = app.room.roomInfo.nBankSeatId
  893. local viewId = app.room:getViewIdBySeatId(nBankerSeatId)
  894. if self.PlayerView:setPlayerTouJiaVisible(viewId,true) then
  895. else
  896. showTooltip("头家椅子号"..nBankerSeatId.."不匹配")
  897. end
  898. end
  899. -- 游戏开始
  900. function doushisiRoomView:onGameStartResponse()
  901. local function runGameStartResponse(onEnd)
  902. log("2000000000-doushisiRoomView - runGameStartResponse()" )
  903. self.ui.Items.Layout_fapaiqi:setVisible(true)
  904. local actualNum = app.room:getActualPlayerNum()
  905. --重置玩家数据
  906. self:resetGameData()
  907. app.room.roomInfo.tingCards = {}
  908. app.room.roomInfo.disCard = {}
  909. if not tolua.isnull(self.quickStartView) then
  910. self.quickStartView:removeView()
  911. self.quickStartView = nil
  912. end
  913. --写入数据
  914. for k,v in pairs(app.room.roomInfo.memberList) do
  915. v.nPlayerFlag = 2
  916. end
  917. --更新玩家状态状态
  918. self:onUserReadyResponse()
  919. -- 隐藏邀请好友
  920. self:setWetChatVisible(false)
  921. self.toolView:showFastStart(false)
  922. -- 更新局数
  923. self:updateGameNums()
  924. --更新位置
  925. app.room:updateUserSeateShowId()
  926. for k,v in pairs(app.room.roomInfo.memberList) do
  927. local nSeatShowId = app.room:getViewIdByUserId(v.nUserId)
  928. self.PlayerView:updatePlayerInfo(nSeatShowId)
  929. end
  930. --更新庄家
  931. self:updateBanker()
  932. self:showXiaojia()
  933. --翻牌
  934. local fanpaiSeatid = app.room.roomInfo.fanpaiSeatId
  935. local fanCard = app.room.roomInfo.fanpaiValue
  936. local fanViewId = app.room:getViewIdBySeatId(fanpaiSeatid)
  937. local function callback()
  938. self:playMoPaiAni(app.room.roomInfo.leftCardNum,fanCard,1,0,1,nil,false)
  939. end
  940. local function call_func()
  941. self:setOutCardVisible(false)
  942. local toujiaId = app.room.roomInfo.nBankSeatId
  943. local toujiaViewId = app.room:getViewIdBySeatId(toujiaId)
  944. self.PlayerView:setPlayerTouJiaVisible(toujiaViewId,true)
  945. end
  946. local seq = cc.Sequence:create(cc.CallFunc:create(callback),cc.DelayTime:create(1),cc.CallFunc:create(call_func),cc.CallFunc:create(function()
  947. if onEnd then
  948. onEnd()
  949. end
  950. end))
  951. self.ui:runAction(seq)
  952. end
  953. log("2000000000-doushisiRoomView - addCallBack(runGameStartResponse)" )
  954. self:addCallBack(runGameStartResponse);
  955. end
  956. function doushisiRoomView:onGameSendCardResponse()
  957. local function runGameSendCardResponse(onEnd)
  958. self.PlayerView:stopAndHideBaoAnim()
  959. log("2000000000-doushisiRoomView - runGameSendCardResponse()" )
  960. if self.taiPaiTimer then
  961. cc.Director:getInstance():getScheduler():unscheduleScriptEntry(self.taiPaiTimer)
  962. end
  963. --显示指示器
  964. local bankerViewId = app.room:getViewIdBySeatId(app.room.roomInfo.nBankSeatId)
  965. local leftCardNum = app.room.roomInfo.leftCardNum
  966. self:setCircleCardLeftPanelView(true,bankerViewId,leftCardNum)
  967. --发牌
  968. self:createCard(true,app.user.loginInfo.uid,onEnd)
  969. print("ding piao:"..table.tostring(app.room.roomInfo.memberList))
  970. self.ui.Items.Button_tipai:setVisible(false)
  971. local xiaojiaViewId = app.room:getViewIdBySeatId(app.room.roomInfo.xiaoSeatId)
  972. local toujiaViewId = app.room:getViewIdBySeatId(app.room.roomInfo.nBankSeatId)
  973. self.toolView:showTuoGuan(app.room.roomInfo.hosting==1)
  974. end
  975. log("2000000000-doushisiRoomView - addCallBack(runGameSendCardResponse)" )
  976. self:addCallBack(runGameSendCardResponse);
  977. end
  978. function doushisiRoomView:setFaPaiQiPanelView(bVisible,viewId,leftNum)
  979. if viewId and leftNum then
  980. if not self.fapaiqiLeftCard then
  981. self.fapaiqiLeftCard = {}
  982. local bgsize = self.ui.Items.ImageView_card_bg:getContentSize()
  983. local posNum = self.ui.Items.TextBMFont_leftCardNum:getPosition()
  984. for i = 1,tonumber(leftNum) do
  985. self.fapaiqiLeftCard[i] = cc.ImageView:createNode()
  986. self.fapaiqiLeftCard[i]:loadTexture("zp_doushisi/res/ui/zy_fangjian/cardBG.png")
  987. self.ui.Items.ImageView_card_bg:addChild(self.fapaiqiLeftCard[i])
  988. self.fapaiqiLeftCard[i]:setPosition(cc.p(bgsize.width/2,bgsize.height/2+i*0.5))
  989. if i > 36 then
  990. self.fapaiqiLeftCard[i]:setVisible(false)
  991. else
  992. self.ui.Items.TextBMFont_leftCardNum:setPositionY(posNum.y + i*0.5)
  993. self.ui.Items.ImageView_zhang:setPositionY(posNum.y + i*0.5)
  994. end
  995. end
  996. else
  997. local posNum = self.ui.Items.TextBMFont_leftCardNum:getPosition()
  998. for i = #self.fapaiqiLeftCard,leftNum+1,-1 do
  999. self.fapaiqiLeftCard[i]:removeFromParent()
  1000. self.fapaiqiLeftCard[i] = nil
  1001. if i <= 36 then
  1002. self.ui.Items.TextBMFont_leftCardNum:setPositionY(posNum.y - 0.5)
  1003. self.ui.Items.ImageView_zhang:setPositionY(posNum.y - 0.5)
  1004. end
  1005. end
  1006. end
  1007. self.ui.Items.TextBMFont_leftCardNum:setText(tostring(self.leftNum))
  1008. end
  1009. end
  1010. -- 发牌
  1011. function doushisiRoomView:recoverHandCards()
  1012. local fapaiList = app.room.roomInfo.fapaiList
  1013. for round = 1,8 do
  1014. for i = 1,#fapaiList do
  1015. local cardlist = fapaiList[i].list
  1016. if cardlist and cardlist[round] then
  1017. local index = round
  1018. local card = cardlist[index]
  1019. if card then
  1020. local viewId = fapaiList[i].viewId
  1021. local num = fapaiList[i].num
  1022. self:sendOneCardNoAction(card,index,viewId,index == num, num,true)
  1023. end
  1024. end
  1025. end
  1026. end
  1027. end
  1028. -- 发一张牌
  1029. function doushisiRoomView:sendOneCardNoAction( card, i, viewId, islast, allCount ,isStart)
  1030. local node = PokerCardNode:new(ZPDef.CardType.CARD_TYPE_HAND)
  1031. node:setScale(DoushisiRoomConfig.CARD_SCALE[viewId])
  1032. local startPos = DoushisiRoomConfig.CARD_FAPAI_POS[viewId]
  1033. node:setPosition(startPos)
  1034. node:setCard(card)
  1035. if viewId == 1 or viewId == 2 then
  1036. node:setLocalZOrder(8 - i)
  1037. else
  1038. node:setLocalZOrder(i)
  1039. end
  1040. local cardNode = string.format("LayoutMain_%d",viewId)
  1041. self.ui.Items[cardNode]:addChild(node)
  1042. --self.ui.Items.Layout_HandCard:addChild(node)
  1043. local pt = cc.p(0, 0)
  1044. pt = clone(DoushisiRoomConfig.CARD_START_POS[viewId])
  1045. if viewId == self:getMeViewId() then
  1046. pt.x = CENTER_X
  1047. local midIdx = allCount/2
  1048. if i<=midIdx then--左边
  1049. pt.x = pt.x - (midIdx-i-1)*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
  1050. else--右边
  1051. pt.x = pt.x + (i-midIdx+1)*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
  1052. end
  1053. pt.x = pt.x - DoushisiRoomConfig.CARD_WIDTH/2*DoushisiRoomConfig.CARD_SCALE[viewId]
  1054. elseif viewId == 3 then
  1055. pt.x = pt.x + i*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
  1056. else
  1057. pt.x = pt.x - i*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
  1058. end
  1059. if viewId == self:getMeViewId() and islast then
  1060. if isStart and allCount == 8 then
  1061. pt.x = pt.x + DoushisiRoomConfig.CARD_WIDTH/2*DoushisiRoomConfig.CARD_SCALE[viewId]
  1062. end
  1063. if not isStart then
  1064. pt.x = pt.x + DoushisiRoomConfig.CARD_WIDTH/2*DoushisiRoomConfig.CARD_SCALE[viewId]
  1065. end
  1066. end
  1067. table.insert(self._selfCards[viewId], node)
  1068. if viewId == self:getMeViewId() then
  1069. table.insert(self.handCardRoot,node)
  1070. table.insert(self.handCardValueLocal,card)
  1071. end
  1072. --发牌的时候直接注册点击事件
  1073. self:registerCardTouch(node)
  1074. node:setPosition(pt)
  1075. return node
  1076. end
  1077. -- 发牌
  1078. function doushisiRoomView:sendCards()
  1079. local fapaiList = app.room.roomInfo.fapaiList
  1080. local delay = 0
  1081. for round = 1,8 do
  1082. for i = 1,#fapaiList do
  1083. local cardlist = fapaiList[i].list
  1084. if cardlist and cardlist[round] then
  1085. local index = round
  1086. local card = cardlist[index]
  1087. if card then
  1088. local viewId = fapaiList[i].viewId
  1089. local num = fapaiList[i].num
  1090. local ac = cc.Sequence:create(cc.DelayTime:create(delay),cc.CallFunc:create(function()
  1091. self:sendOneCard(card,index,viewId,index == num, num,true)
  1092. end))
  1093. self:runAction(ac)
  1094. delay = delay + 0.02
  1095. end
  1096. end
  1097. end
  1098. end
  1099. end
  1100. -- 发一张牌
  1101. function doushisiRoomView:sendOneCard( card, i, viewId, islast, allCount ,isStart)
  1102. local node = PokerCardNode:new(ZPDef.CardType.CARD_TYPE_HAND)
  1103. node:setScale(DoushisiRoomConfig.CARD_SCALE[viewId])
  1104. local startPos = DoushisiRoomConfig.CARD_FAPAI_POS[viewId]
  1105. node:setPosition(startPos)
  1106. node:setCard(card)
  1107. if viewId == 1 or viewId == 2 then
  1108. node:setLocalZOrder(8 - i)
  1109. else
  1110. node:setLocalZOrder(i)
  1111. end
  1112. local cardNode = string.format("LayoutMain_%d",viewId)
  1113. self.ui.Items[cardNode]:addChild(node)
  1114. --self.ui.Items.Layout_HandCard:addChild(node)
  1115. local pt = cc.p(0, 0)
  1116. pt = clone(DoushisiRoomConfig.CARD_START_POS[viewId])
  1117. if viewId == self:getMeViewId() then
  1118. pt.x = CENTER_X
  1119. local midIdx = allCount/2
  1120. if i<=midIdx then--左边
  1121. pt.x = pt.x - (midIdx-i-1)*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
  1122. else--右边
  1123. pt.x = pt.x + (i-midIdx+1)*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
  1124. end
  1125. pt.x = pt.x - DoushisiRoomConfig.CARD_WIDTH/2*DoushisiRoomConfig.CARD_SCALE[viewId]
  1126. elseif viewId == 3 then
  1127. pt.x = pt.x + i*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
  1128. else
  1129. pt.x = pt.x - i*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
  1130. end
  1131. if viewId == self:getMeViewId() and islast then
  1132. if isStart and allCount == 8 then
  1133. pt.x = pt.x + DoushisiRoomConfig.CARD_WIDTH/2*DoushisiRoomConfig.CARD_SCALE[viewId]
  1134. end
  1135. if not isStart then
  1136. pt.x = pt.x + DoushisiRoomConfig.CARD_WIDTH/2*DoushisiRoomConfig.CARD_SCALE[viewId]
  1137. end
  1138. end
  1139. local ac = nil
  1140. ac = cc.Sequence:create(cc.Spawn:create(cc.MoveTo:create(0.05, pt), cc.FadeIn:create(0.1)), cc.CallFunc:create(function ()
  1141. table.insert(self._selfCards[viewId], node)
  1142. if viewId == self:getMeViewId() then
  1143. table.insert(self.handCardRoot,node)
  1144. table.insert(self.handCardValueLocal,card)
  1145. end
  1146. playVoiceGiveCard()
  1147. end), cc.DelayTime:create((i)*0.01))
  1148. --发牌的时候直接注册点击事件
  1149. self:registerCardTouch(node)
  1150. node:runAction(ac)
  1151. return node
  1152. end
  1153. function doushisiRoomView:createCard(bShowAnimation,nUserID,onEnd)
  1154. logE("====================doushisiRoomView:createCard()===================");
  1155. local toujiaViewId = app.room:getViewIdBySeatId(app.room.roomInfo.nBankSeatId)
  1156. if bShowAnimation then
  1157. self.ui:runAction(cc.Sequence:create(cc.CallFunc:create(function()
  1158. self:sendCards()
  1159. end),cc.DelayTime:create(0.8),cc.CallFunc:create(function()
  1160. --排序
  1161. --self:RankCard()
  1162. if onEnd then
  1163. onEnd()
  1164. end
  1165. end)))
  1166. else
  1167. self:recoverHandCards()
  1168. --排序
  1169. --self:RankCard()
  1170. self:neatenCard()
  1171. if onEnd then
  1172. onEnd()
  1173. end
  1174. end
  1175. end
  1176. --注册点击事件
  1177. function doushisiRoomView:registerCardTouch(node)
  1178. local function getPosOO()
  1179. local nodeTouch = self.ui.Items.Layout_Touch;
  1180. local posTouch = nodeTouch:getWorldPosition()
  1181. local poaAnchor = nodeTouch:getAnchorPoint()
  1182. local sizeTouch = nodeTouch:getContentSize();
  1183. local posOO = { x = posTouch.x - sizeTouch.width * poaAnchor.x , y = posTouch.y - sizeTouch.height * poaAnchor.y}
  1184. return posOO;
  1185. end
  1186. local function onTouchBegan(touch)
  1187. if self.isGodHand then
  1188. return
  1189. end
  1190. if not node._canTouch then
  1191. return
  1192. end
  1193. local posOO = getPosOO()
  1194. local localPos = touch:getLocation();
  1195. local pos = cc.p(localPos.x - posOO.x, localPos.y - posOO.y);
  1196. self.touchPoker = node
  1197. local touchNode = node.imgBg
  1198. local value = touchNode.value
  1199. --v:setOpacity(0)
  1200. if value == 0 then
  1201. return
  1202. end
  1203. logE("88888888-=============onTouchBegan1================")
  1204. logE("88888888-touch value:",value)
  1205. logE("玩家点了"..value)
  1206. logE("88888888-card :"..table.tostring(self.handCardValueLocal))
  1207. logE("88888888-=============onTouchBegan2================")
  1208. self.touchPoker = node
  1209. if not node:isDoWn() then
  1210. self:setCardNormal()
  1211. local pt = touchNode:getPosition()
  1212. touchNode:setPosition(cc.p(pt.x, pt.y+40))
  1213. self.ui.Items.Button_OutCard:setEnabled(true)
  1214. else
  1215. local value = touchNode.value
  1216. if value == nil then
  1217. showTooltip("牌已经操作过!")
  1218. return
  1219. end
  1220. if not self.bOutCard then
  1221. self:setCardNormal()
  1222. self.ui.Items.Button_OutCard:setEnabled(false)
  1223. return
  1224. end
  1225. self.ui.Items.ImageView_handTempCard:setVisible(false)
  1226. touchNode:setOpacity(0)
  1227. self:sendOutCard(value)
  1228. logE("玩家出牌:"..value)
  1229. self.bOutCard = false
  1230. self.isGodHand = true;
  1231. self.ui.Items.ImageView_handTempCard.value = value
  1232. end
  1233. --临时牌
  1234. self.ui.Items.ImageView_handTempCard.value = value
  1235. self.ui.Items.ImageView_handTempCard:setVisible(false)
  1236. self.ui.Items.ImageView_handTempCard:loadTextureFromPlist(PokerUtil.pokerPng(value,ZPDef.CardType.CARD_TYPE_HAND))
  1237. self.ui.Items.ImageView_handTempCard:setPosition(pos)
  1238. end
  1239. local function onTouchMove(touch)
  1240. if self.isGodHand then
  1241. return
  1242. end
  1243. if not node._canTouch then
  1244. return
  1245. end
  1246. local touchNode = node.imgBg
  1247. local posOO = getPosOO()
  1248. local localPos = touch:getLocation();
  1249. local prePos=touch:getPreviousLocation()
  1250. local pos = cc.p(localPos.x - posOO.x, localPos.y - posOO.y);
  1251. local pos1 = cc.p(prePos.x - posOO.x, prePos.y - posOO.y)
  1252. if self._isMove then
  1253. touchNode:setOpacity(0)
  1254. self.ui.Items.ImageView_handTempCard:setVisible(true)
  1255. self.ui.Items.ImageView_handTempCard:setPosition(localPos)
  1256. return
  1257. end
  1258. local x=math.abs(pos.x-pos1.x)
  1259. local y=math.abs(pos.y-pos1.y)
  1260. if x > 5 and y > 5 and (not self._isMove) then
  1261. self._isMove = true
  1262. --touchNode:setOpacity(0)
  1263. --self.ui.Items.ImageView_handTempCard:setVisible(true)
  1264. --self.ui.Items.ImageView_handTempCard:setPosition(pos)
  1265. --touchNode:setPosition(pos)
  1266. end
  1267. end
  1268. local function onTouchEnd(touch)
  1269. if self.isGodHand then
  1270. return
  1271. end
  1272. if not node._canTouch then
  1273. return
  1274. end
  1275. local touchNode = node.imgBg
  1276. logE("88888888-=============onTouchEnd1================")
  1277. if not self.ui.Items.ImageView_handTempCard:isVisible() then
  1278. touchNode:setOpacity(255)
  1279. self.ui.Items.ImageView_handTempCard:setVisible(false)
  1280. return
  1281. end
  1282. self._isMove = false
  1283. self.ui.Items.ImageView_handTempCard:setVisible(false)
  1284. --出牌线
  1285. self:setOutCardLineVisible(false)
  1286. if not touchNode.value then
  1287. return
  1288. end
  1289. touchNode:setOpacity(255)
  1290. --回到原点动画
  1291. self:goBackWithAni(touchNode,0.15)
  1292. logE("88888888-=============onTouchEnd2================")
  1293. end
  1294. local function onTouchCancel(touch)
  1295. if self.isGodHand then
  1296. return
  1297. end
  1298. if not node._canTouch then
  1299. return
  1300. end
  1301. local touchNode = node.imgBg
  1302. --self:setColorWhite()
  1303. logE("88888888-=============onTouchCancel 1================")
  1304. --出牌线
  1305. self:setOutCardLineVisible(false)
  1306. if not self.ui.Items.ImageView_handTempCard:isVisible() then
  1307. --showTooltip("cancel 临时牌阻止了事件")
  1308. touchNode:setOpacity(255)
  1309. self.ui.Items.ImageView_handTempCard:setVisible(false)
  1310. return
  1311. end
  1312. self.ui.Items.ImageView_handTempCard:setVisible(false)
  1313. if not touchNode.value then
  1314. return
  1315. end
  1316. touchNode:setOpacity(255)
  1317. --临时牌
  1318. self.ui.Items.ImageView_handTempCard:setVisible(false)
  1319. local touchPos = touch:getLocation()
  1320. --@part:牌取消回来,出牌逻辑的实现
  1321. --判断是否大于出牌点
  1322. if touchPos.y > self.ui.Items.ImageView_line:getPosition().y and self.bOutCard then
  1323. if app.room:isLittleFamily() then
  1324. return
  1325. end
  1326. local value = touchNode.value
  1327. --比牌的时候,在比牌间隔点到了牌,拖出去报错
  1328. if value == nil then
  1329. showTooltip("牌已经操作过!")
  1330. return
  1331. end
  1332. --send sender
  1333. touchNode:setOpacity(0)
  1334. self:sendOutCard(value)
  1335. logE("玩家出牌:"..value)
  1336. self.bOutCard = false
  1337. self.isGodHand = true;
  1338. self.ui.Items.ImageView_handTempCard.value = value
  1339. else
  1340. logE("牌回到原来的位置")
  1341. --回到原点动画
  1342. self:goBackWithAni(touchNode,0.15)
  1343. end
  1344. -------------------------------------------------------
  1345. -------------------------------------------------------
  1346. logE("88888888=============onTouchCancel 2================")
  1347. logE("88888888-onTouchCancel :card :"..table.tostring(self.handCardValueLocal))
  1348. end
  1349. node:addCardTouchEventListener(onTouchBegan,onTouchMove,onTouchEnd,onTouchCancel)
  1350. end
  1351. function doushisiRoomView:setCardNormal()
  1352. self.ui.Items.Button_OutCard:setEnabled(false)
  1353. for k,v in pairs(self.handCardRoot) do
  1354. v:setNormal()
  1355. end
  1356. end
  1357. function doushisiRoomView:showOpeation(mainOpCode,card,isQiShou,hasGuo)
  1358. logD("doushisiRoomView showOpeation",mainOpCode)
  1359. self.operationView:setVisible(true)
  1360. self.operationView:setSameParame(self.outCard,self.handCardValueLocal)
  1361. local ret1 = bit32.band(mainOpCode,ZPDef.OpCode.OP_TIAN_HU)
  1362. if ret1 > 0 then
  1363. hasGuo = false
  1364. end
  1365. if self.isBiChi and self.isBiChi == 2 then
  1366. hasGuo = false
  1367. end
  1368. self.operationView:showOperation(mainOpCode,card,isQiShou,hasGuo,self.isTishi)
  1369. --检测是否少牌
  1370. --self:neatenCard(true)--无感知的整理一次手牌
  1371. self:checkCardAndRecover()
  1372. self.isTishi = false
  1373. end
  1374. --检测是否少牌,如果少牌则恢复 --目前在抓牌,出牌成功,和显示操作三个地方检测少牌情况
  1375. function doushisiRoomView:checkCardAndRecover()
  1376. end
  1377. --玩家出牌操作
  1378. function doushisiRoomView:sendOutCard(nCard)
  1379. if self.isGameOver then
  1380. return
  1381. end
  1382. --直接给用户显示出牌效果,数据删除在出牌成功后,如果出牌失败,出牌效果消失,用户可以重新出牌哦
  1383. self:setOutCardVisible(true,self:getMeViewId(),nCard,true,nil,false)
  1384. end
  1385. --弃牌
  1386. function doushisiRoomView:onQiPai(data)
  1387. local function runOnQiPai(onEnd)
  1388. self:hideOperation()
  1389. logE("2000000000-doushisiRoomView onQiPai : "..table.tostring(data.response))
  1390. local response = data.response
  1391. local nUserId = response.nUserId
  1392. local disCard = response.disCard
  1393. local viewId = app.room:getViewIdByUserId(nUserId)
  1394. self:playQiPaiAni(true,disCard,viewId,onEnd)
  1395. end
  1396. log("2000000000-doushisiRoomView - addCallBack(runOnQiPai)")
  1397. self:addCallBack(runOnQiPai)
  1398. end
  1399. --发牌后偷牌巴牌的操作
  1400. function doushisiRoomView:onUserOperateResponse(data)
  1401. local function runUserOperate(onEnd)
  1402. log("2000000000-doushisiRoomView - (runUserOperate)")
  1403. logE("runUserOperate :"..table.tostring(data.response))
  1404. self.isQiShou = true
  1405. self.isGodHand = true
  1406. if data.response.nUserId == app.room:getMyUserId() then
  1407. if data.response.mainOpCode ~= ZPDef.OpCode.OP_ERROR or data.response.mainOpCode ~= ZPDef.OpCode.OP_ERROR then
  1408. local ishu = data.response.ishu
  1409. local hasGuo = true
  1410. local operationCardlist = {}
  1411. local opeateCode = data.response.mainOpCode
  1412. self.outCard = 0
  1413. if #data.response.BacardList > 0 then
  1414. operationCardlist[ZPDef.OpCode.OP_BA_QI_SHOU] = {}
  1415. for k,v in pairs(data.response.BacardList or {}) do
  1416. table.insert(operationCardlist[ZPDef.OpCode.OP_BA_QI_SHOU],v)
  1417. end
  1418. end
  1419. --操作码
  1420. if #data.response.ToucardList > 0 then
  1421. operationCardlist[ZPDef.OpCode.OP_TOU_QI_SHOU] = {}
  1422. local toulist = {}
  1423. for k,v in pairs(data.response.ToucardList or {}) do
  1424. for _,value in pairs(v.cardlist) do
  1425. table.insert(toulist,value)
  1426. end
  1427. table.insert(operationCardlist[ZPDef.OpCode.OP_TOU_QI_SHOU],toulist)
  1428. toulist = {}
  1429. end
  1430. end
  1431. local mainOpCode = data.response.mainOpCode
  1432. local retHu = bit32.band(mainOpCode,ZPDef.OpCode.OP_HU)
  1433. local retHu1 = bit32.band(mainOpCode,ZPDef.OpCode.OP_TIAN_HU)
  1434. if ishu == 1 and self.isQiShou and retHu1 > 0 then
  1435. hasGuo = false
  1436. end
  1437. local viewId = app.room:getViewIdByUserId(data.response.nUserId)
  1438. self.operationLocalCode = opeateCode
  1439. if self.operationLocalCode > 0 then
  1440. self:showOpeation(opeateCode,operationCardlist,self.isQiShou,hasGuo)
  1441. end
  1442. --self:setTotalTuoNum(data.response.totalTuoNum)
  1443. local myViewId = self:getMeViewId()
  1444. self:setGuideView(false)
  1445. self.bOutCard = false
  1446. end
  1447. end
  1448. self.ui.Items.ImageView_tou_tip:setVisible(true)
  1449. local operations = {}
  1450. --操作码
  1451. local viewId = app.room:getViewIdByUserId(data.response.nUserId)
  1452. operations[viewId] = {}
  1453. operations[viewId].nUserId = data.response.nUserId
  1454. operations[viewId].isCanOpereate = 1
  1455. self:showDelayTimeTip(operations)
  1456. if onEnd then
  1457. onEnd()
  1458. end
  1459. end
  1460. log("2000000000-doushisiRoomView - addCallBack(runUserOperate)")
  1461. self:addCallBack(runUserOperate);
  1462. end
  1463. function doushisiRoomView:lockYouPai(list)
  1464. for _,value in ipairs(list or {}) do
  1465. for k,v in pairs(self.handCardRoot) do
  1466. if v:getVal() == value then
  1467. v:setYouIconVis(true)
  1468. v:setCardTouchEnabled(false)
  1469. end
  1470. end
  1471. end
  1472. end
  1473. function doushisiRoomView:onBroadCastBankerOutCard(data)
  1474. local function runBankerOutCardd(onEnd)
  1475. logE("2000000000-doushisiRoomView runBankerOutCardd :"..table.tostring(data.response))
  1476. local viewId = app.room:getViewIdByUserId(data.response.nUserId)
  1477. --吃后不能出的牌
  1478. self.isQiShou = false
  1479. if data.response.nUserId == app.room:getMyUserId() then
  1480. self.isGodHand = false
  1481. app.room.roomInfo.disCard = {}
  1482. for k,v in ipairs(data.response.disCard or {}) do
  1483. table.insert(app.room.roomInfo.disCard,v)
  1484. end
  1485. --[[ for k,v in ipairs(data.response.afterbadisCard or {}) do
  1486. table.insert(app.room.roomInfo.disCard,v)
  1487. end--]]
  1488. self:lockYouPai(app.room.roomInfo.disCard)
  1489. self:setGuideView(true)
  1490. self.bOutCard = true
  1491. end
  1492. self.ui.Items.ImageView_tou_tip:setVisible(false)
  1493. self:setCircleCardLeftPanelView(true,viewId,self.leftNum)
  1494. if onEnd then
  1495. onEnd()
  1496. end
  1497. end
  1498. log("2000000000-doushisiRoomView - addCallBack(runBankerOutCardd)")
  1499. self:addCallBack(runBankerOutCardd);
  1500. end
  1501. --提示报叫
  1502. function doushisiRoomView:onTingCardResult(data)
  1503. local function runTingCardResult(onEnd)
  1504. logE("2000000000-doushisiRoomView runTingCardResult :"..table.tostring(data.response))
  1505. local response = data.response
  1506. local tingCards = response.tingCards
  1507. local nBankerSeatId = app.room.roomInfo.nBankSeatId
  1508. local viewId = app.room:getViewIdBySeatId(nBankerSeatId)
  1509. self.isGodHand = true
  1510. if viewId == self:getMeViewId() then
  1511. app.room.roomInfo.tingCards = response.tingCards or {}
  1512. else
  1513. app.room.roomInfo.tingCards = {}
  1514. end
  1515. if onEnd then
  1516. onEnd()
  1517. end
  1518. local isCanBao = response.canBaoPai
  1519. if isCanBao == 1 then
  1520. self.operationView:showBaoPaiOpView(true)
  1521. end
  1522. end
  1523. log("2000000000-doushisiRoomView - addCallBack(runTingCardResult)")
  1524. self:addCallBack(runTingCardResult)
  1525. end
  1526. --爆牌结果
  1527. function doushisiRoomView:onBaoPaiResponese(data)
  1528. local function runBaoPai(onEnd)
  1529. logE("2000000000-doushisiRoomView onBaoPaiResponese :"..table.tostring(data.response))
  1530. local response = data.response
  1531. local uid = response.nUserId
  1532. local viewId = app.room:getViewIdByUserId(uid)
  1533. --玩家选择了爆牌 播放爆牌动画
  1534. if response.optType == 1 then
  1535. self:showOperatorTip(viewId,-55)
  1536. --self.PlayerView:playBaoAnim(viewId)
  1537. self.PlayerView:setPlayerBaoJiaoVisible(viewId,true)
  1538. if uid == app.room:getMyUserId() then
  1539. self.baoJiaoStatus = 1
  1540. self:lockMyHandCards()
  1541. end
  1542. end
  1543. if uid == app.room:getMyUserId() then
  1544. self:hideOperation()
  1545. end
  1546. self:runAction(cc.Sequence:create(cc.DelayTime:create(0.5),cc.CallFunc:create(function ()
  1547. if onEnd then
  1548. onEnd()
  1549. end
  1550. end)))
  1551. end
  1552. log("2000000000-doushisiRoomView - addCallBack(onBaoPaiResponese)")
  1553. self:addCallBack(runBaoPai)
  1554. end
  1555. function doushisiRoomView:lockMyHandCards()
  1556. --先把手牌全部锁了
  1557. for k,v in pairs(self.handCardRoot) do
  1558. v:setZheZhaoVis(true)
  1559. v:setCardTouchEnabled(false)
  1560. end
  1561. for _,val in pairs(app.room.roomInfo.tingCards or {}) do
  1562. for _,v in pairs(self.handCardRoot) do
  1563. if v:getVal() == val then
  1564. v:setCardTouchEnabled(true)
  1565. v:setZheZhaoVis(false)
  1566. end
  1567. end
  1568. end
  1569. end
  1570. --包赔提示
  1571. function doushisiRoomView:onOutCardIsBaoPeiResponse(data)
  1572. local baoPeiCard = data.response.bCard
  1573. local view = import("zp_doushisi.luaScript.Views.Room.doushisiRoomBaoPei"):new(baoPeiCard,0)
  1574. view:setAnchorPoint(cc.p(0.5, 0.5))
  1575. app:showWaitDialog(view)
  1576. end
  1577. function doushisiRoomView:reflashHandCards()
  1578. --[[ local handCard = self:ChangeDataToVector(self.handCardValueBak)
  1579. local sendCardResult = app.room:rankHandCard(handCard)
  1580. local newCardList
  1581. newCardList = app.room:serverCardToMyCard(sendCardResult)
  1582. self.ui.Items.LayoutMain_4:removeAllChildren()
  1583. self.handCardRoot = {}
  1584. self.handCardItem = {}
  1585. self.handCardValueLocal = {}
  1586. self.handCardValueBak = {}
  1587. local myUserID = app.room:getMyUserId()
  1588. app.room.cards[myUserID] = newCardList
  1589. self:createCard(false,myUserID,nil)--]]
  1590. end
  1591. --出牌成功
  1592. function doushisiRoomView:onOutCardSuccess(data)
  1593. local function runOnOutCardSuccess(onEnd)
  1594. logE("2000000000-doushisiRoomView runOnOutCardSuccess :"..table.tostring(data.response))
  1595. --设置出牌动画隐藏
  1596. self:setGuideView(false)
  1597. --只要出了牌就不是起手操作了
  1598. self.isQiShou = false
  1599. local response = data.response
  1600. local nUserId = response.nOutCardUserId
  1601. local card = response.byOutCard
  1602. local operateCode = response.mainOpCode
  1603. local leftHandCardNum = response.leftHandCardNum
  1604. local isBaoPei = response.isBaopei
  1605. local opCardList = response.opCardList
  1606. local pengCardList = response.CanOpPengCard
  1607. if isBaoPei == 1 then
  1608. self.isBiChi = 2
  1609. else
  1610. self.isBiChi = 0
  1611. end
  1612. local viewId = app.room:getViewIdByUserId(nUserId)
  1613. self.moPaiViewId = viewId
  1614. --隐藏出牌
  1615. self.bOutCard = false
  1616. --记录真实牌值
  1617. self.outCard = card
  1618. --记录操作码
  1619. self.EatOperationCode = operateCode
  1620. self:showDelayTimeTip()
  1621. self.PlayerView:setLeftCardNum(viewId,true,leftHandCardNum)
  1622. if viewId == self:getMeViewId() then
  1623. self.myHandCardNums = leftHandCardNum
  1624. end
  1625. --self.PlayerView:setNoOpTime(false,viewId)
  1626. logE("my userid :"..app.room:getMyUserId())
  1627. logE("out card response nUserId:"..nUserId)
  1628. local userInfo=app.room:getUserInfo(nUserId)
  1629. if userInfo then
  1630. ZPSound.PlayZPSound(userInfo.sex,card)
  1631. else
  1632. ZPSound.PlayZPSound(1,card)
  1633. end
  1634. local operationCardlist = {}
  1635. if operateCode ~= ZPDef.OpCode.OP_CANCEL and operateCode ~= ZPDef.OpCode.OP_ERROR then
  1636. operationCardlist[ZPDef.OpCode.OP_PENG] = {}
  1637. local penglist = {}
  1638. for k,v in pairs(pengCardList or {}) do
  1639. for _,val in pairs(v.cardlist or {}) do
  1640. table.insert(penglist,val)
  1641. end
  1642. table.insert(operationCardlist[ZPDef.OpCode.OP_PENG],penglist)
  1643. penglist = {}
  1644. end
  1645. operationCardlist[ZPDef.OpCode.OP_HU] = {}
  1646. table.insert(operationCardlist[ZPDef.OpCode.OP_HU],card)
  1647. operationCardlist[ZPDef.OpCode.OP_CHI] = {}
  1648. for k,v in ipairs(opCardList) do
  1649. table.insert(operationCardlist[ZPDef.OpCode.OP_CHI],v)
  1650. end
  1651. end
  1652. if nUserId ~= app.room:getMyUserId() then
  1653. if operateCode ~= ZPDef.OpCode.OP_CANCEL and operateCode ~= ZPDef.OpCode.OP_ERROR then
  1654. self:showOpeation(operateCode,operationCardlist,self.isQiShou,true)
  1655. end
  1656. --其他玩家显示
  1657. local lens = table.nums(self._selfCards[viewId])
  1658. if lens > 0 and self._selfCards[viewId][lens] then
  1659. self._selfCards[viewId][lens]:removeFromParent()
  1660. table.remove(self._selfCards[viewId],lens)
  1661. end
  1662. self:setOutCardVisible(true,viewId,card,false,onEnd)
  1663. else
  1664. self.isGodHand = true
  1665. local function rankDeletOneCard(card)
  1666. local isEnd = false
  1667. local lens = table.nums(self.handCardRoot)
  1668. for i = lens, 1, -1 do
  1669. if self.handCardRoot[i]:getVal() == card then
  1670. self.handCardRoot[i]:removeFromParent()
  1671. table.remove(self.handCardRoot, i)
  1672. isEnd = true
  1673. break
  1674. end
  1675. end
  1676. local lens =table.nums(self.handCardValueLocal)
  1677. for i = lens, 1, -1 do
  1678. if self.handCardValueLocal[i] == card then
  1679. table.remove(self.handCardValueLocal,i)
  1680. isEnd = true
  1681. break
  1682. end
  1683. end
  1684. end
  1685. if app.room.roomInfo.hosting == 1 and self.touchPoker and not tolua.isnull(self.touchPoker) then
  1686. self.touchPoker.imgBg:setOpacity(255) --把已经在移动的牌还原
  1687. self.touchPoker = nil --托管出牌服务器发什么就出什么,要把移动的牌清空
  1688. end
  1689. --说明:数据校验:弱网棋牌的通病(麻将出牌等一切可以允许玩家自己插牌的游戏,需要注意弱网情况,出牌会出现删错牌)
  1690. --判断该列是否有牌
  1691. if table.nums(self.handCardValueLocal) > 0 then
  1692. --二次校验牌数据是否是出牌数据
  1693. local recordValue = 0
  1694. if self.touchPoker then
  1695. recordValue = self.touchPoker:getVal()
  1696. end
  1697. if recordValue == card then
  1698. logE("delete card2 ============= :"..card)
  1699. local lens =table.nums(self.handCardValueLocal)
  1700. for i = lens, 1, -1 do
  1701. if self.handCardValueLocal[i] == card then
  1702. table.remove(self.handCardValueLocal,i)
  1703. isEnd = true
  1704. break
  1705. end
  1706. end
  1707. local index = 0
  1708. for i = lens, 1, -1 do
  1709. if self.handCardRoot[i]:getVal() == card and self.handCardRoot[i] == self.touchPoker then
  1710. self.handCardRoot[i]:removeFromParent()
  1711. table.remove(self.handCardRoot, i)
  1712. isEnd = true
  1713. break
  1714. end
  1715. end
  1716. else
  1717. --随机删掉手里那张牌
  1718. rankDeletOneCard(card)
  1719. end
  1720. else
  1721. --随机删掉手里那张牌
  1722. rankDeletOneCard(card)
  1723. end
  1724. if app.room.roomInfo.hosting == 1 then
  1725. self.ui.Items.ImageView_handTempCard:setVisible(false) --托管出牌的时候要把自己点击在桌面上的牌清理掉
  1726. self:setOutCardVisible(true,viewId,card,false, function () end)
  1727. end
  1728. self:rankDeletOneBakCard(card)
  1729. --self:reflashHandCards()
  1730. self:neatenCard(true)
  1731. if onEnd then
  1732. onEnd()
  1733. end
  1734. --检查是否少牌
  1735. self:checkCardAndRecover()
  1736. --设置坨数
  1737. --self:setTotalTuoNum(data.response.totoltuoNum)
  1738. local myViewId = self:getMeViewId()
  1739. if viewId == self:getMeViewId() then
  1740. self:unLockYouPai()
  1741. end
  1742. if self.baoJiaoStatus == 1 then
  1743. app.room.roomInfo.tingCards = {}
  1744. self:lockMyHandCards()
  1745. end
  1746. end
  1747. end
  1748. log("2000000000-doushisiRoomView - addCallBack(runOnOutCardSuccess)")
  1749. self:addCallBack(runOnOutCardSuccess)
  1750. end
  1751. --整理牌
  1752. function doushisiRoomView:neatenCard(isMoPai)
  1753. self:setCardNormal()
  1754. local handcardlist = self.handCardValueLocal
  1755. local resulthandData = app.room:rankHandCard(handcardlist)
  1756. local lens = table.nums(resulthandData)
  1757. for i = 1, lens do
  1758. local pos
  1759. if isMoPai then
  1760. pos = self:getMeCardPosition(i, lens + 1)
  1761. else
  1762. pos = self:getMeCardPosition(i, lens)
  1763. end
  1764. for k,v in pairs(self.handCardRoot) do
  1765. if v:getVal() == resulthandData[i] and not v._hasSet then
  1766. v:setHasSet(true)
  1767. v:setPosition(pos)
  1768. v:setLocalZOrder(i)
  1769. break
  1770. end
  1771. end
  1772. end
  1773. for k,v in pairs(self.handCardRoot) do
  1774. v:setHasSet(false)
  1775. end
  1776. end
  1777. function doushisiRoomView:getMeCardPosition(i,allCount)
  1778. local viewId = self:getMeViewId()
  1779. local pt = cc.p(0,0)
  1780. pt = clone(DoushisiRoomConfig.CARD_START_POS[viewId])
  1781. pt.x = CENTER_X
  1782. local midIdx = allCount/2
  1783. if i<=midIdx then--左边
  1784. pt.x = pt.x - (midIdx-i-1)*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
  1785. else--右边
  1786. pt.x = pt.x + (i-midIdx+1)*DoushisiRoomConfig.CARD_DLT_WIDTH*DoushisiRoomConfig.CARD_SCALE[viewId]
  1787. end
  1788. pt.x = pt.x - DoushisiRoomConfig.CARD_WIDTH/2*DoushisiRoomConfig.CARD_SCALE[viewId]
  1789. return pt
  1790. end
  1791. function doushisiRoomView:doOperation(operationType,viewId,card,onEnd,isChilaiBao)
  1792. if operationType == ZPDef.OpType.OP_TYPE_CHI then
  1793. self:Chi(viewId,card,onEnd)
  1794. if isChilaiBao and isChilaiBao == 1 then
  1795. self:showOperatorTip(viewId,-56)
  1796. else
  1797. self:showOperatorTip(viewId,operationType)
  1798. end
  1799. elseif operationType == ZPDef.OpType.OP_TYPE_PENG then
  1800. self:Peng(viewId,card,onEnd)
  1801. self:showOperatorTip(viewId,operationType)
  1802. elseif operationType == ZPDef.OpType.OP_TYPE_BA then
  1803. self:Ba(viewId,card,onEnd)
  1804. self:showOperatorTip(viewId,operationType)
  1805. elseif operationType == ZPDef.OpType.OP_TYPE_FANPAI_BA then
  1806. self:BaFan(viewId,card,onEnd)
  1807. self:showOperatorTip(viewId,operationType)
  1808. elseif operationType == ZPDef.OpType.OP_TYPE_LAI_PENG then
  1809. self:Peng(viewId,card,onEnd)
  1810. self:showOperatorTip(viewId,operationType)
  1811. elseif operationType == ZPDef.OpType.OP_TYPE_TOU then
  1812. self:Tou(viewId,card,onEnd)
  1813. self:showOperatorTip(viewId,operationType)
  1814. elseif operationType == ZPDef.OpType.OP_TYPE_HU then
  1815. self:showOperatorTip(viewId,operationType)
  1816. end
  1817. end
  1818. function doushisiRoomView:removeHandByNums(card,nums)
  1819. local nums = nums
  1820. local lens = table.nums(self.handCardRoot)
  1821. --判断是否是癞子
  1822. if math.floor(card/16) == 5 then
  1823. card = 0x5e
  1824. end
  1825. local isFind = false
  1826. local index = 0
  1827. for i = 1,lens do
  1828. if self.handCardRoot[i]:getVal() == card and nums > 0 then
  1829. nums = nums - 1
  1830. self.handCardRoot[i]:removeFromParent()
  1831. index = i
  1832. isFind = true
  1833. break
  1834. end
  1835. end
  1836. if isFind then
  1837. table.remove(self.handCardRoot,index)
  1838. table.remove(self.handCardValueLocal,index)
  1839. end
  1840. end
  1841. --用户吃(手动)
  1842. function doushisiRoomView:Chi(viewId,cards,onEnd)
  1843. logD("function do Chi")
  1844. logE("doushisiRoomView chi:",table.tostring(cards))
  1845. local chilist = {}
  1846. --吃的牌放下面
  1847. table.insert(chilist, self.chiCard)
  1848. table.insert(chilist, cards[1])
  1849. logE("doushisiRoomView chilist:",chilist)
  1850. local nUserID = app.room:getUserIdByViewId(viewId)
  1851. for k,v in ipairs(chilist) do
  1852. self.opOutCard[viewId]:addGroupCard(v,1)
  1853. end
  1854. if viewId == self:getMeViewId() then
  1855. local card = cards[1]
  1856. self:removeHandByNums(card,1)
  1857. self:neatenCard()
  1858. else
  1859. local num = 1
  1860. for i = 1, num do
  1861. local lens = table.nums(self._selfCards[viewId])
  1862. if lens > 0 and self._selfCards[viewId][lens] then
  1863. self._selfCards[viewId][lens]:removeFromParent()
  1864. table.remove(self._selfCards[viewId],lens)
  1865. end
  1866. end
  1867. end
  1868. if onEnd then
  1869. onEnd()
  1870. end
  1871. end
  1872. --用户碰(手动)
  1873. function doushisiRoomView:Peng(viewId,cards,onEnd)
  1874. logD("function do Peng")
  1875. logE("doushisiRoomView Peng:",table.tostring(cards))
  1876. local penglist = {}
  1877. --吃的牌放下面
  1878. table.insert(penglist, self.chiCard)
  1879. for _,v in pairs(cards or {}) do
  1880. table.insert(penglist, v)
  1881. end
  1882. for k,v in pairs(penglist or {}) do
  1883. self.opOutCard[viewId]:addGroupCard(v,1)
  1884. end
  1885. if viewId == self:getMeViewId() then
  1886. for k,v in pairs(cards) do
  1887. self:removeHandByNums(v,1)
  1888. end
  1889. self:neatenCard(true)
  1890. else
  1891. local num = 2
  1892. for i = 1, num do
  1893. local lens = table.nums(self._selfCards[viewId])
  1894. if lens > 0 and self._selfCards[viewId][lens] then
  1895. self._selfCards[viewId][lens]:removeFromParent()
  1896. table.remove(self._selfCards[viewId],lens)
  1897. end
  1898. end
  1899. end
  1900. if onEnd then
  1901. onEnd()
  1902. end
  1903. end
  1904. --用户偷(手动)
  1905. function doushisiRoomView:Tou(viewId,cards,onEnd)
  1906. logD("function do Tou")
  1907. logE("doushisiRoomView Tou:",table.tostring(cards))
  1908. for k,v in pairs(cards or {}) do
  1909. self.opOutCard[viewId]:addGroupCard(v,1)
  1910. end
  1911. if viewId == self:getMeViewId() then
  1912. for k,v in pairs(cards) do
  1913. self:removeHandByNums(v,1)
  1914. end
  1915. self:neatenCard(true)
  1916. else
  1917. local num = 3
  1918. for i = 1, num do
  1919. local lens = table.nums(self._selfCards[viewId])
  1920. if lens > 0 and self._selfCards[viewId][lens] then
  1921. self._selfCards[viewId][lens]:removeFromParent()
  1922. table.remove(self._selfCards[viewId],lens)
  1923. end
  1924. end
  1925. end
  1926. if onEnd then
  1927. onEnd()
  1928. end
  1929. end
  1930. --进牌之后巴(手动)
  1931. function doushisiRoomView:Ba(viewId,cards,onEnd)
  1932. logD("function do Ba")
  1933. logE("doushisiRoomView Ba:",table.tostring(cards))
  1934. local operateCode = self.operationSuccessCode
  1935. for k,v in pairs(cards or {}) do
  1936. self.opOutCard[viewId]:addBaCard(v,1)
  1937. end
  1938. if viewId == self:getMeViewId() then
  1939. for k,v in pairs(cards) do
  1940. self:removeHandByNums(v,1)
  1941. end
  1942. self:neatenCard(true)
  1943. else
  1944. local num = 1
  1945. for i = 1, num do
  1946. local lens = table.nums(self._selfCards[viewId])
  1947. if lens > 0 and self._selfCards[viewId][lens] then
  1948. self._selfCards[viewId][lens]:removeFromParent()
  1949. table.remove(self._selfCards[viewId],lens)
  1950. end
  1951. end
  1952. end
  1953. if onEnd then
  1954. onEnd()
  1955. end
  1956. end
  1957. --翻牌巴(手动)
  1958. function doushisiRoomView:BaFan(viewId,cards,onEnd)
  1959. logD("function do BaFan")
  1960. logE("doushisiRoomView BaFan:",table.tostring(cards))
  1961. local operateCode = self.operationSuccessCode
  1962. for k,v in pairs(cards or {}) do
  1963. self.opOutCard[viewId]:addBaCard(v,1)
  1964. end
  1965. if onEnd then
  1966. onEnd()
  1967. end
  1968. end
  1969. --起手偷巴操作
  1970. function doushisiRoomView:onUserOperateSuccess(data)
  1971. local function runUserOperateSuccess(onEnd)
  1972. log("2000000000-doushisiRoomView - (runUserOperateSuccess)")
  1973. logE("runUserOperateSuccess :"..table.tostring(data.response))
  1974. local response = data.response
  1975. local nUserId = response.nUserId
  1976. local opType = response.operateCodes
  1977. local opCard = response.opCard
  1978. local totoalTuoNum = response.totalTuoNum
  1979. local leftCardNum = tonumber(response.leftCardNum)
  1980. self.operationSuccessCode = opType
  1981. local viewId = app.room:getViewIdByUserId(nUserId)
  1982. if opType == ZPDef.OpCode.OP_TOU_QI_SHOU or opType == ZPDef.OpCode.OP_TOU_ZHUA then --偷
  1983. self:doOperation(ZPDef.OpType.OP_TYPE_TOU,viewId,opCard,nil)
  1984. elseif opType == ZPDef.OpCode.OP_BA_QI_SHOU or opType == ZPDef.OpCode.OP_BA_ZHUA or opType == ZPDef.OpCode.OP_BA_FAN then
  1985. self:doOperation(ZPDef.OpType.OP_TYPE_BA,viewId,opCard,nil)
  1986. end
  1987. if viewId == self:getMeViewId() then
  1988. self:hideOperation()
  1989. end
  1990. if viewId ~= 4 then
  1991. self.PlayerView:setLeftCardNum(viewId,true,leftCardNum)
  1992. else
  1993. self.myHandCardNums = leftCardNum
  1994. end
  1995. if onEnd then
  1996. onEnd()
  1997. end
  1998. end
  1999. log("2000000000-doushisiRoomView - addCallBack(runUserOperateSuccess)")
  2000. self:addCallBack(runUserOperateSuccess);
  2001. end
  2002. --弃牌动画
  2003. --断线重连的时候,不需要动画
  2004. --[[
  2005. isShowAni:是否展示弃牌动画
  2006. disCard:弃牌
  2007. viewId:视图ID
  2008. isDianPaoPeng:碰胡规则,点炮碰,弃牌要显示透明形态
  2009. ]]
  2010. function doushisiRoomView:playQiPaiAni(isShowAni,disCard,viewId,onEnd,isDianPaoPeng)
  2011. local outCardname = string.format("ImageView_outCardImg_%d",viewId)
  2012. local outCardPoint = string.format("Layout_outCardPoint_%d",viewId)
  2013. local giveupCardname = string.format("Layout_giveUp_%d",viewId)
  2014. --牌的图片
  2015. local outCardImg = self.ui.Items[outCardname]
  2016. --牌的图片父节点
  2017. local outCardLayout = self.ui.Items[outCardPoint]
  2018. local giveUpLayout = self.qiPaiView[viewId]
  2019. --[[ --弃牌的layout
  2020. local giveUpLayout = self.ui.Items[giveupCardname]
  2021. --获取弃牌节点存在的数量
  2022. local count = giveUpLayout:getChildrenCount()
  2023. --创建一张精灵
  2024. local mSprite = cc.ImageView:createNode()
  2025. mSprite:setScale(self.littleCardScale)
  2026. local finalFileName = PokerUtil.pokerPng(disCard,ZPDef.CardType.CARD_TYPE_GROUP_OUT)
  2027. mSprite:loadTextureFromPlist(finalFileName)
  2028. mSprite:setVisible(false)
  2029. mSprite:setAnchorPoint(cc.p(0,0))
  2030. mSprite.value = disCard
  2031. giveUpLayout:addChild(mSprite)--]]
  2032. --[[ local width = mSprite:getContentSize().width * self.littleCardScale;
  2033. local height = mSprite:getContentSize().height* self.littleCardScale;
  2034. local getHeightCount = function (count)
  2035. if count >= 6 then
  2036. return math.floor(count/6)
  2037. else
  2038. return 0
  2039. end
  2040. end
  2041. local x = 0
  2042. x = count % 6
  2043. local tarPos
  2044. if viewId == 1 then
  2045. local adjustPos = cc.p(width * x,height * getHeightCount(count))
  2046. tarPos = cc.p(adjustPos.x,0 - adjustPos.y)
  2047. elseif viewId == 2 then
  2048. local adjustPos = cc.p(width * x,getHeightCount(count) * height)
  2049. tarPos = cc.p(adjustPos.x,0 - adjustPos.y)
  2050. elseif viewId == 3 then
  2051. local adjustPos = cc.p(width * x,height * getHeightCount(count))
  2052. tarPos = cc.p(0 + adjustPos.x,0 - adjustPos.y)
  2053. elseif viewId == self:getMeViewId() then
  2054. local adjustPos = cc.p(width * x,height * getHeightCount(count))
  2055. tarPos = cc.p(adjustPos.x,0 - adjustPos.y)
  2056. end
  2057. mSprite:setPosition(tarPos)--]]
  2058. local tarPos = self.qiPaiView[viewId]:getQiPiaPosition()
  2059. self.qiPaiView[viewId]:addQiPaiCard(disCard,isShowAni)
  2060. --动画显示
  2061. if not isShowAni then
  2062. --mSprite:setVisible(true)
  2063. --[[ if isDianPaoPeng and isDianPaoPeng == 1 then
  2064. if self.colorType == ZPDef.ColorType.White then
  2065. mSprite:setColor(cc.c3b(255,223,125))
  2066. else
  2067. mSprite:setColor(cc.c3b(255,226,111))
  2068. end
  2069. end--]]
  2070. else
  2071. local fileName = PokerUtil.pokerPng(disCard,ZPDef.CardType.CARD_TYPE_HAND)
  2072. --弃牌
  2073. local giveSprite = cc.ImageView:createNode()
  2074. giveSprite:loadTextureFromPlist(fileName)
  2075. giveSprite:setScale(self.outCardScale)
  2076. giveUpLayout:addChild(giveSprite)
  2077. giveSprite:setVisible(false)
  2078. local spriteSizeWidth = giveSprite:getContentSize().width * self.outCardScale
  2079. local spriteSizeHeight = giveSprite:getContentSize().height * self.outCardScale
  2080. local worldPos = outCardImg:convertToWorldSpace(outCardImg:getPosition())
  2081. local nodePos = giveUpLayout:convertToNodeSpace(worldPos)
  2082. --调整上下2个玩家的坐标和牌的角度
  2083. if viewId == 2 or viewId == 4 then
  2084. --nodePos = cc.p(nodePos.x - spriteSizeWidth,nodePos.y - spriteSizeHeight/2)
  2085. --giveSprite:setEulerRotation(cc.vec3(0,0,90))
  2086. end
  2087. giveSprite:setPosition(nodePos)
  2088. local mSpawn = cc.Spawn:create(cc.MoveTo:create(self.gameSpeedConfig.QI_PAI_TIME,tarPos),cc.ScaleTo:create(self.gameSpeedConfig.QI_PAI_TIME,self.outCardScale - 0.7))
  2089. giveSprite:runAction(cc.Sequence:create(cc.DelayTime:create(0.3),cc.CallFunc:create(function()
  2090. outCardLayout:setVisible(false)
  2091. giveSprite:setVisible(true)
  2092. end),mSpawn,cc.CallFunc:create(function()
  2093. --mSprite:setVisible(true)
  2094. --[[ if isDianPaoPeng and isDianPaoPeng == 1 then
  2095. if self.colorType == ZPDef.ColorType.White then
  2096. mSprite:setColor(cc.c3b(255,223,125))
  2097. else
  2098. mSprite:setColor(cc.c3b(255,226,111))
  2099. end
  2100. end--]]
  2101. self.qiPaiView[viewId]:showAllQiPaiCard()
  2102. end),cc.RemoveSelf:create()))
  2103. --要求弃牌飞到一半,摸牌就开始摸了
  2104. --[[ mSprite:runAction(cc.Sequence:create(cc.DelayTime:create(0.4 + self.gameSpeedConfig.QI_PAI_TIME/2),cc.CallFunc:create(function ()
  2105. if onEnd then
  2106. onEnd()
  2107. end
  2108. end)))--]]
  2109. self.ui:runAction(cc.Sequence:create(cc.DelayTime:create(0.4 + self.gameSpeedConfig.QI_PAI_TIME/2),cc.CallFunc:create(function ()
  2110. if onEnd then
  2111. onEnd()
  2112. end
  2113. end)))
  2114. end
  2115. end
  2116. --出牌错误
  2117. function doushisiRoomView:onOutCardError(data)
  2118. local function runOnOutCardError(onEnd)
  2119. logE("doushisiRoomView:onOutCardError(), response = ", table.tostring(data.response))
  2120. self.isGodHand = false--出牌错误了,可以操作牌
  2121. --隐藏出牌效果
  2122. self:setOutCardVisible(false)
  2123. --恢复出的那张牌的透明度
  2124. if self.touchPoker then
  2125. self.touchPoker.imgBg:setOpacity(255)
  2126. end
  2127. self.bOutCard = true
  2128. self:neatenCard()
  2129. if onEnd then
  2130. onEnd()
  2131. end
  2132. end
  2133. log("2000000000-doushisiRoomView - addCallBack(runOnOutCardError)")
  2134. self:addCallBack(runOnOutCardError)
  2135. end
  2136. --摸牌
  2137. function doushisiRoomView:onMoPai(data)
  2138. local function runOnMoPai(onEnd)
  2139. logE("doushisiRoomView:runOnMoPai(), response = ", table.tostring(data.response))
  2140. local response = data.response
  2141. local nUserId = response.nUserId
  2142. local turnOverCard = response.turnOverCard
  2143. local code = response.mainOpCode
  2144. local leftCardNum = response.leftCardNum
  2145. --local operations = response.operations
  2146. local isBaopeiChi = response.Baopeichi
  2147. local chiOpCardlist = response.chiOpCardList
  2148. local pengOpCardlist = response.canPengOpCard
  2149. if isBaopeiChi == 1 then
  2150. self.isTishi = true
  2151. end
  2152. self.isBiChi = isBaopeiChi
  2153. local viewId = app.room:getViewIdByUserId(nUserId)
  2154. self.EatOperationCode = code
  2155. self.outCard = turnOverCard
  2156. self.moPaiViewId = viewId
  2157. self:showDelayTimeTip()
  2158. --更新剩余牌数
  2159. self:playMoPaiAni(leftCardNum,turnOverCard,viewId,code,1,onEnd,false,isBaopeiChi,chiOpCardlist,pengOpCardlist)
  2160. if self.bankerBaoPao then
  2161. self.bankerBaoPao = nil
  2162. self:showTiPaiBtn(true)
  2163. --小家不能看牌时,牌堆牌显示剩余张数
  2164. if app.room:isLittleFamily() and (not ZPFuc.getLittleIsCanLookCard()) then
  2165. self:setCircleCardLeftPanelView(true,viewId,19)
  2166. end
  2167. end
  2168. if self:getIsMeUId(nUserId) then
  2169. --检测是否少牌
  2170. self:checkCardAndRecover()
  2171. end
  2172. --[[ --结束 一定要等到摸牌动画结束才结束整个摸牌流程
  2173. if onEnd then
  2174. onEnd()
  2175. end--]]
  2176. end
  2177. log("2000000000-doushisiRoomView - addCallBack(runOnMoPai)")
  2178. self:addCallBack(runOnMoPai)
  2179. end
  2180. --播放摸牌动画
  2181. --[[
  2182. leftCardNum:剩余牌
  2183. turnOverCard: 摸的牌
  2184. viewId:视图ID
  2185. mainOpCode:操作码
  2186. showCardFlag:是否显示牌 0;不能 1:能
  2187. isNotShowAni:不显示动画
  2188. ]]
  2189. function doushisiRoomView:playMoPaiAni(leftCardNum,turnOverCard,viewId,mainOpCode,showCardFlag,onEnd,isNotShowAni,isBaopeiChi,chiOpCardList,pengOpCardlist)
  2190. self.isMoPaiOperator = true
  2191. --重置出牌坐标
  2192. self:resetOutCardPoint()
  2193. --图片
  2194. local outCardname = string.format("ImageView_outCardImg_%d",viewId)
  2195. local outCardLayoutName = string.format("Layout_outCardPoint_%d",viewId)
  2196. local mSprite = self.ui.Items[outCardname]
  2197. local srcPos = mSprite:getPosition()
  2198. local fileName = ""
  2199. local fileNameReal = PokerUtil.pokerPng(turnOverCard,ZPDef.CardType.CARD_TYPE_HAND)
  2200. self.ui.Items[outCardLayoutName]:setVisible(true)
  2201. if viewId == self:getMeViewId() then
  2202. mSprite:loadTextureFromPlist(fileNameReal)
  2203. end
  2204. --公谱出牌不串不哨立马亮牌,看到亮牌的听得到牌的音效
  2205. if mainOpCode ~= ZPDef.OpCode.OP_CANCEL and mainOpCode ~= ZPDef.OpCode.OP_ERROR then
  2206. mSprite:loadTextureFromPlist(fileNameReal)
  2207. else
  2208. if showCardFlag == 1 then
  2209. mSprite:loadTextureFromPlist(fileNameReal)
  2210. if not isNotShowAni then
  2211. local nUserId = app.room:getUserIdByViewId(viewId)
  2212. local userInfo=app.room:getUserInfo(nUserId)
  2213. if userInfo then
  2214. if turnOverCard > 0 then
  2215. ZPSound.PlayZPSound(userInfo.sex,turnOverCard)
  2216. end
  2217. end
  2218. end
  2219. else
  2220. mSprite:loadTextureFromPlist(fileName)
  2221. end
  2222. end
  2223. self:changeOutCardLight(true)
  2224. local function callback()
  2225. local operationCardlist = {}
  2226. if mainOpCode ~= ZPDef.OpCode.OP_CANCEL and mainOpCode ~= ZPDef.OpCode.OP_ERROR then
  2227. operationCardlist[ZPDef.OpCode.OP_PENG] = {}
  2228. local penglist = {}
  2229. for k,v in pairs(pengOpCardlist or {}) do
  2230. for _,val in pairs(v.cardlist or {}) do
  2231. table.insert(penglist,val)
  2232. end
  2233. table.insert(operationCardlist[ZPDef.OpCode.OP_PENG],penglist)
  2234. penglist = {}
  2235. end
  2236. operationCardlist[ZPDef.OpCode.OP_BA_FAN] = {}
  2237. table.insert(operationCardlist[ZPDef.OpCode.OP_BA_FAN],turnOverCard)
  2238. operationCardlist[ZPDef.OpCode.OP_HU] = {}
  2239. table.insert(operationCardlist[ZPDef.OpCode.OP_HU],turnOverCard)
  2240. operationCardlist[ZPDef.OpCode.OP_CHI] = {}
  2241. for k,v in ipairs(chiOpCardList or {}) do
  2242. table.insert(operationCardlist[ZPDef.OpCode.OP_CHI],v)
  2243. end
  2244. end
  2245. if mainOpCode ~= ZPDef.OpCode.OP_CANCEL and mainOpCode ~= ZPDef.OpCode.OP_ERROR then
  2246. self.EatOperationCode = mainOpCode
  2247. self:showOpeation(mainOpCode,operationCardlist,self.isQiShou,true)
  2248. end
  2249. end
  2250. if isNotShowAni then
  2251. mSprite:setPosition(srcPos)
  2252. callback()
  2253. if onEnd then
  2254. onEnd()
  2255. end
  2256. return
  2257. else
  2258. --local outCardLightName = string.format("ImageView_outCardLight_%d",viewId)
  2259. --self.ui.Items[outCardLightName]:setVisible(false)
  2260. mSprite:setScale(0)
  2261. if showCardFlag ~= 1 then
  2262. mSprite:loadTextureFromPlist(fileName)
  2263. --起始坐标调整和角度,扫为横的出来
  2264. if viewId == self:getMeViewId() then
  2265. mSprite:setEulerRotation(cc.vec3(0,0,0))
  2266. beginPos = cc.p(srcPos.x,srcPos.y + 200)
  2267. elseif viewId == 1 then
  2268. mSprite:setEulerRotation(cc.vec3(0,0,-90))
  2269. beginPos = cc.p(srcPos.x - 200 ,srcPos.y)
  2270. elseif viewId == 2 then
  2271. mSprite:setEulerRotation(cc.vec3(0,0,0))
  2272. beginPos = cc.p(srcPos.x,srcPos.y - 100)
  2273. elseif viewId == 3 then
  2274. mSprite:setEulerRotation(cc.vec3(0,0,-90))
  2275. beginPos = cc.p(srcPos.x + 200 ,srcPos.y-50)
  2276. end
  2277. mSprite:setPosition(beginPos)
  2278. --目标调整、角度
  2279. if viewId == 1 then
  2280. srcPos = cc.p(srcPos.x + 250,srcPos.y)
  2281. elseif viewId == 2 then
  2282. srcPos = cc.p(srcPos.x,srcPos.y+50)
  2283. elseif viewId == 3 then
  2284. srcPos = cc.p(srcPos.x - 250,srcPos.y-50)
  2285. elseif viewId == 4 then
  2286. srcPos = cc.p(srcPos.x,srcPos.y-100)
  2287. end
  2288. mSprite:setScale(1)
  2289. mSprite:runAction(cc.Sequence:create(cc.MoveTo:create(0.3,srcPos),cc.CallFunc:create(function ()
  2290. --self.ui.Items[outCardLightName]:setVisible(true)
  2291. end),cc.CallFunc:create(function()
  2292. --恢复原来的角度
  2293. if viewId == self:getMeViewId() then
  2294. mSprite:setEulerRotation(cc.vec3(0,0,90))
  2295. elseif viewId == 1 then
  2296. mSprite:setEulerRotation(cc.vec3(0,0,0))
  2297. elseif viewId == 2 then
  2298. mSprite:setEulerRotation(cc.vec3(0,0,90))
  2299. elseif viewId == 3 then
  2300. mSprite:setEulerRotation(cc.vec3(0,0,0))
  2301. end
  2302. self.ui.Items[outCardLayoutName]:setVisible(false)
  2303. self:setCircleCardLeftPanelView(true,viewId,leftCardNum)
  2304. callback()
  2305. if onEnd then
  2306. onEnd()
  2307. end
  2308. end)))
  2309. else
  2310. if mainOpCode ~= ZPDef.OpCode.OP_CANCEL and mainOpCode ~= ZPDef.OpCode.OP_ERROR then
  2311. local nUserId = app.room:getUserIdByViewId(viewId)
  2312. local userInfo=app.room:getUserInfo(nUserId)
  2313. if userInfo then
  2314. ZPSound.PlayZPSound(userInfo.sex,turnOverCard)
  2315. end
  2316. end
  2317. --播放摸牌动画(这里最好用出牌器的坐标进行转换,暂时这样调整吧)
  2318. if viewId == self:getMeViewId() then
  2319. beginPos = cc.p(srcPos.x,srcPos.y + 200)
  2320. elseif viewId == 1 then
  2321. beginPos = cc.p(srcPos.x - 300 ,srcPos.y)
  2322. elseif viewId == 2 then
  2323. beginPos = cc.p(srcPos.x ,srcPos.y - 200)
  2324. elseif viewId == 3 then
  2325. beginPos = cc.p(srcPos.x + 300 ,srcPos.y)
  2326. end
  2327. mSprite:setPosition(beginPos)
  2328. local mSpawn = cc.Spawn:create(cc.ScaleTo:create(self.gameSpeedConfig.MO_PAI_TIME,1.0),cc.MoveTo:create(self.gameSpeedConfig.MO_PAI_TIME,srcPos))
  2329. mSprite:runAction(cc.Sequence:create(mSpawn,cc.CallFunc:create(function ()
  2330. --self.ui.Items[outCardLightName]:setVisible(true)
  2331. --显示指示器
  2332. self:setCircleCardLeftPanelView(true,viewId,leftCardNum)
  2333. end),cc.DelayTime:create(0.15),cc.CallFunc:create(function()
  2334. callback()
  2335. if onEnd then
  2336. onEnd()
  2337. end
  2338. end)))
  2339. end
  2340. end
  2341. end
  2342. -- 操作成功
  2343. function doushisiRoomView:onOperationCodeSuccess(data)
  2344. local function runOnOperationSuccess(onEnd)
  2345. log("2000000000-doushisiRoomView - (runOnOperationSuccess)")
  2346. self:hideOperation()
  2347. logE("doushisiRoomView:onOperationCodeSuccess :"..table.tostring(data.response))
  2348. local response = data.response
  2349. local nUserID = response.nUserId
  2350. local cards = response.card
  2351. local tablecard = response.tableCard
  2352. local bIsOutCard = response.isShouldOutCard > 0
  2353. local operateCodes = response.operateCodes
  2354. local weaveCardList = response.weaveCardList
  2355. local playerList = response.playerList
  2356. local maxWeave = table.nums(weaveCardList)
  2357. local leftHandCardNum = response.leftHandCardNum
  2358. local isChilaiBao = response.isChilaiBao
  2359. self.isBaopei = isChilaiBao
  2360. --local isMoPaiOrId = -1
  2361. --app.room.roomInfo.huType = response.huType
  2362. --点炮胡时,表示为点炮用户
  2363. app.room.roomInfo.dianPaoSeatId = response.dianPaoSeatId
  2364. --碰胡规则
  2365. if maxWeave > 0 then
  2366. --isMoPaiOrId = weaveCardList[maxWeave].seatId
  2367. end
  2368. local cardlist = {}
  2369. for k,v in pairs(cards) do
  2370. table.insert(cardlist,v)
  2371. end
  2372. local card = 0
  2373. if table.nums(cardlist) == 1 then
  2374. card = cardlist[1]
  2375. end
  2376. --记录操作成功
  2377. self.operationSuccessCode = operateCodes
  2378. self.outCard = card
  2379. self.chiCard = tablecard
  2380. --视图ID
  2381. local viewId = app.room:getViewIdByUserId(nUserID)
  2382. self.PlayerView:setLeftCardNum(viewId,true,leftHandCardNum)
  2383. if viewId == self:getMeViewId() then
  2384. self.myHandCardNums = leftHandCardNum
  2385. end
  2386. --self.PlayerView:setNoOpTime(false,viewId)
  2387. if bIsOutCard then
  2388. for k,v in pairs(app.room.roomInfo.memberList) do
  2389. local operations = {}
  2390. operations[viewId] = {}
  2391. operations[viewId].nUserId = v.nUserId
  2392. operations[viewId].isCanOpereate = 0
  2393. self:showDelayTimeTip(operations)
  2394. end
  2395. end
  2396. local operations = {}
  2397. operations[viewId] = {}
  2398. operations[viewId].nUserId = nUserID
  2399. operations[viewId].isCanOpereate = bIsOutCard and 1 or 0
  2400. self:showDelayTimeTip(operations)
  2401. --隐藏handTemp
  2402. if viewId == self:getMeViewId() then
  2403. self.isGodHand = true
  2404. --出牌动画 setGuideView延迟了0.5
  2405. self:runAction(cc.Sequence:create(cc.DelayTime:create(0.5),cc.CallFunc:create(function ()
  2406. self:setColorWhite()
  2407. if operateCodes == 0 then--点击过的时候设置可以点牌
  2408. --self.isGodHand = false
  2409. end
  2410. end)))
  2411. self.ui.Items.ImageView_handTempCard:setVisible(false)
  2412. end
  2413. --显示指示器
  2414. if bIsOutCard and operateCodes ~= 0 then
  2415. self:setCircleCardLeftPanelView(true,viewId,self.leftNum)
  2416. end
  2417. --隐藏操作层
  2418. self:setOperatorPanelView(false,nil)
  2419. --判断自己是否需要出牌
  2420. if bIsOutCard and viewId == self:getMeViewId()
  2421. and operateCodes ~= 0
  2422. and operateCodes ~= ZPDef.OpCode.OP_HU then
  2423. self:runAction(cc.Sequence:create(cc.DelayTime:create(0.5),cc.CallFunc:create(function ()
  2424. self:setGuideView(true)
  2425. end)))
  2426. self.bOutCard = true
  2427. end
  2428. if self.isTianHu and viewId == self:getMeViewId() then
  2429. self.isTianHu = false
  2430. self:setGuideView(true)
  2431. self.bOutCard = true
  2432. end
  2433. --隐藏吃牌层
  2434. self.operationView:setEatCardView(false)
  2435. --执行操作
  2436. local code = operateCodes
  2437. logE("doushisiRoomView:onOperationCodeSuccess nOperationCode:"..code)
  2438. local operations = ZPFuc.getZPOperationType(code,false,false)
  2439. local operationType = operations[1]
  2440. --体验:等待0.5秒结束
  2441. if operationType ~= ZPDef.OpType.OP_TYPE_HU and operationType ~= ZPDef.OpType.OP_TYPE_CANCEL and operationType ~= nil then
  2442. --吃碰操作
  2443. --隐藏出牌层
  2444. self:setOutCardVisible(false)
  2445. self:doOperation(operationType,viewId,cardlist,onEnd,isChilaiBao)
  2446. elseif operationType == ZPDef.OpType.OP_TYPE_HU then
  2447. --胡牌操作
  2448. --1.隐藏引导出牌动画2.显示胡了哪张牌,3.播放胡牌特效
  2449. self:setGuideView(false)
  2450. local imgName = string.format("ImageView_outCardImg_%d",self.moPaiViewId)
  2451. local mSprite = self.ui.Items[imgName]
  2452. if self.outCard ~= 0 then
  2453. local fileName = PokerUtil.pokerPng(self.outCard,ZPDef.CardType.CARD_TYPE_HAND)
  2454. mSprite:loadTextureFromPlist(fileName)
  2455. end
  2456. if operateCodes ~= 0 then
  2457. if onEnd then
  2458. onEnd()
  2459. end
  2460. end
  2461. else
  2462. --self:showOperatorTip(viewId,ZPDef.OpType.OP_TYPE_CANCEL)
  2463. --过
  2464. self:doOperation(ZPDef.OpType.OP_TYPE_CANCEL,viewId,card,nil)
  2465. if onEnd then
  2466. onEnd()
  2467. end
  2468. end
  2469. end
  2470. log("2000000000-doushisiRoomView - addCallBack(runOnOperationSuccess)")
  2471. self:addCallBack(runOnOperationSuccess)
  2472. end
  2473. function doushisiRoomView:unLockYouPai()
  2474. for k,v in pairs(self.handCardRoot) do
  2475. v:setYouIconVis(false)
  2476. v:setCardTouchEnabled(true)
  2477. end
  2478. end
  2479. function doushisiRoomView:onBroadCastUserGetCard(data)
  2480. local function runUserGetCard(onEnd)
  2481. log("2000000000-doushisiRoomView - (runUserGetCard)")
  2482. logE("runUserGetCard :"..table.tostring(data.response))
  2483. local viewId = app.room:getViewIdByUserId(data.response.nUserId)
  2484. local leftcardNum = data.response.leftCardNum
  2485. local isHouZhua = data.response.isHouZhuaCard
  2486. local mocard = data.response.moCard
  2487. local function callback()
  2488. if data.response.nUserId == app.room:getMyUserId() then
  2489. --进牌后解锁油牌
  2490. --如果报叫了则不能解锁
  2491. --先刷新一遍手牌,存在上一轮摸了牌无操作也没出牌的情况
  2492. --self:neatenCard()
  2493. self:unLockYouPai()
  2494. app.room.roomInfo.disCard = {}
  2495. local moValue = data.response.moCard
  2496. self.outCard = 0 --进牌的时候点过可以发0
  2497. self.moValue = moValue
  2498. local lens = table.nums(self.handCardRoot)
  2499. local moSepAction = cc.Sequence:create(cc.CallFunc:create(function()
  2500. self:neatenCard(true)
  2501. local node = self:sendOneCard(moValue,lens+1,viewId,true,lens+1,false)
  2502. self.isGodHand = true --播放动画的时候不能点击手牌
  2503. end),
  2504. cc.DelayTime:create(0.2),
  2505. cc.CallFunc:create(function()
  2506. --self.isGodHand = false
  2507. if self.baoJiaoStatus == 1 then
  2508. app.room.roomInfo.tingCards = {}
  2509. table.insert(app.room.roomInfo.tingCards,moValue)
  2510. self:lockMyHandCards()
  2511. end
  2512. if onEnd then
  2513. onEnd()
  2514. end
  2515. end))
  2516. self:runAction(moSepAction)
  2517. else
  2518. local moValue = data.response.moCard
  2519. local lens = table.nums(self._selfCards[viewId])
  2520. self:sendOneCard(moValue,lens+1,viewId,true,lens+1,false)
  2521. if onEnd then
  2522. onEnd()
  2523. end
  2524. end
  2525. end
  2526. local HOUZHUA_TAG = 100
  2527. if isHouZhua == 1 then
  2528. local function call_func()
  2529. self:playMoPaiAni(leftCardNum,mocard,viewId,0,1,nil,false)
  2530. local name = string.format("ImageView_outCardImg_%d",viewId)
  2531. local img = self.ui.Items[name]
  2532. local size = img:getContentSize()
  2533. --后抓精灵
  2534. local mSprite = cc.ImageView:createNode()
  2535. mSprite:loadTexture("zp_doushisi/res/ui/zy_fangjian/btn_effect/effect/houzhua.png")
  2536. img:addChild(mSprite)
  2537. mSprite:setTag(HOUZHUA_TAG)
  2538. mSprite:setPosition(cc.p(size.width/2,size.height/2))
  2539. mSprite:setScale(0.8)
  2540. end
  2541. local seq = cc.Sequence:create(cc.CallFunc:create(call_func),cc.DelayTime:create(1.5),cc.CallFunc:create(function()
  2542. self:setOutCardVisible(false)
  2543. local name = string.format("ImageView_outCardImg_%d",viewId)
  2544. local img = self.ui.Items[name]
  2545. for i,child in pairs(img:getChildren()) do
  2546. local tag = child:getTag()
  2547. if tag == HOUZHUA_TAG then
  2548. child:removeFromParent()
  2549. end
  2550. end
  2551. callback()
  2552. end))
  2553. self.ui:runAction(seq)
  2554. else
  2555. callback()
  2556. end
  2557. local leftCard = data.response.tableCardNum
  2558. self:setCircleCardLeftPanelView(true,viewId,leftCard)
  2559. self.PlayerView:setLeftCardNum(viewId,true,leftcardNum)
  2560. if viewId == self:getMeViewId() then
  2561. self.myHandCardNums = leftcardNum
  2562. end
  2563. end
  2564. log("2000000000-doushisiRoomView - addCallBack(runUserGetCard)")
  2565. self:addCallBack(runUserGetCard);
  2566. end
  2567. function doushisiRoomView:onUserGetCardOperteResponse(data)
  2568. local function runonUserGetCardOperte(onEnd)
  2569. log("2000000000-doushisiRoomView - (runonUserGetCardOperte)")
  2570. logE("runonUserGetCardOperte :"..table.tostring(data.response))
  2571. if data.response.nUserId == app.room:getMyUserId() then
  2572. if data.response.mainOpCode ~= ZPDef.OpCode.OP_ERROR then
  2573. self.isGodHand = true
  2574. local operationCardlist = {}
  2575. local opeateCode = data.response.mainOpCode
  2576. local ishu = data.response.ishu
  2577. local hasGuo = true
  2578. self.outCard = 0
  2579. if #data.response.BacardList > 0 then
  2580. operationCardlist[ZPDef.OpCode.OP_BA_ZHUA] = {}
  2581. for k,v in pairs(data.response.BacardList or {}) do
  2582. table.insert(operationCardlist[ZPDef.OpCode.OP_BA_ZHUA],v)
  2583. end
  2584. end
  2585. --操作码
  2586. if #data.response.ToucardList > 0 then
  2587. operationCardlist[ZPDef.OpCode.OP_TOU_ZHUA] = {}
  2588. local toulist = {}
  2589. for k,v in pairs(data.response.ToucardList or {}) do
  2590. for _,value in pairs(v.cardlist) do
  2591. table.insert(toulist,value)
  2592. end
  2593. table.insert(operationCardlist[ZPDef.OpCode.OP_TOU_ZHUA],toulist)
  2594. toulist = {}
  2595. end
  2596. end
  2597. if ishu == 1 and self.isQiShou then
  2598. hasGuo = false
  2599. end
  2600. if not self.isQiShou and ishu == 1 then
  2601. operationCardlist[ZPDef.OpCode.OP_HU] = {}
  2602. table.insert(operationCardlist[ZPDef.OpCode.OP_HU],self.moValue)
  2603. end
  2604. local viewId = app.room:getViewIdByUserId(data.response.nUserId)
  2605. self.operationLocalCode = opeateCode
  2606. if self.operationLocalCode > 0 then
  2607. self:showOpeation(opeateCode,operationCardlist,self.isQiShou,hasGuo)
  2608. self:setGuideView(false)
  2609. self.bOutCard = false
  2610. end
  2611. end
  2612. end
  2613. local operations = {}
  2614. --操作码
  2615. local viewId = app.room:getViewIdByUserId(data.response.nUserId)
  2616. operations[viewId] = {}
  2617. operations[viewId].nUserId = data.response.nUserId
  2618. operations[viewId].isCanOpereate = 1
  2619. self:showDelayTimeTip(operations)
  2620. if onEnd then
  2621. onEnd()
  2622. end
  2623. end
  2624. log("2000000000-doushisiRoomView - addCallBack(runonUserGetCardOperte)")
  2625. self:addCallBack(runonUserGetCardOperte);
  2626. end
  2627. -- 小局结算
  2628. function doushisiRoomView:onGameXiaoJuResponse(data)
  2629. local function runGameXiaoJuResponse(onEnd)
  2630. self:hideOperation()
  2631. self.ui.Items.Button_tipai:setVisible(false)
  2632. self.PlayerView:stopAndHideBaoAnim()
  2633. self.PlayerView:hideLeftCard()
  2634. self.ui.Items.ImageView_tou_tip:setVisible(false)
  2635. --显示所有底牌
  2636. local response = data.response;
  2637. --标记单局结束
  2638. self.isGameOver = true
  2639. --禁止出牌
  2640. self.bOutCard = false
  2641. local roomInfo = app.room.roomInfo
  2642. --结束原因
  2643. roomInfo.stopFlag = response.stopFlag
  2644. --赢家uid, -1则下面6个字段是无用
  2645. roomInfo.winUserId = response.winUserId
  2646. --点炮胡时,表示为点炮用户
  2647. roomInfo.dianPaoUserId = response.dianPaoUserId
  2648. --胡的类型(如天胡、地胡 ,自摸胡等)
  2649. roomInfo.huType = response.huTypes
  2650. --多少个玩家
  2651. roomInfo.playList = response.playList
  2652. --底牌信息
  2653. roomInfo.dipaiList = response.dipaiList
  2654. --胡牌牌值
  2655. roomInfo.huCard = response.huCard
  2656. --是否大局结束,结束是1
  2657. roomInfo.isGameOver = response.isGameOver
  2658. --胡牌信息
  2659. roomInfo.hupaiInfo = response.hupaiInfo
  2660. --是否自摸胡
  2661. roomInfo.isZiMoHu = response.isZiMoHu
  2662. local function showChaPai()
  2663. runDelay(1, function ()
  2664. if not tolua.isnull(self.xiaojuView) then --如果小结算已经被移除,说明此时已经游戏游戏开始了或者结束了,则查牌界面也不用显示了
  2665. self:setLiangPaiVisible(true)
  2666. self.xiaojuView:setVisible(true)
  2667. end
  2668. end)
  2669. end
  2670. local isSomebodyHuPai = false
  2671. for i,v in pairs(roomInfo.hupaiInfo) do
  2672. local viewId = app.room:getViewIdByUserId(v.huPaiUid)
  2673. roomInfo.dianPaoUserId = v.dianPaoUid
  2674. roomInfo.baopeiUserid = app.room:getUserIdBySeatId(v.BaoPeiUid)
  2675. roomInfo.fourNormolNum = v.fourNormolNum
  2676. roomInfo.threeNormolNum = v.threeNormolNum
  2677. roomInfo.huCard = v.huCard
  2678. self.PlayerView:setPlayerHuXi(v.huPaiHuShu)
  2679. roomInfo.huType = v.huTypes
  2680. self:playHuEffect(viewId,showChaPai)
  2681. isSomebodyHuPai = true
  2682. end
  2683. --所有的暗偎默认亮起一张
  2684. --self:showLastAnWeiPai()
  2685. --完成底牌展示
  2686. self.xiaojuChaPaiView:showDiPai()
  2687. --如果大局结算了 并且不是正常结束
  2688. if roomInfo.isGameOver == 1 and not isSomebodyHuPai then
  2689. showChaPai()
  2690. end
  2691. --完成手牌展示
  2692. for k,v in pairs(roomInfo.playList) do
  2693. local cardData = app.room:serverCardToMyCard(v.handCard)
  2694. if not roomInfo.memberList[v.nUserId] then
  2695. roomInfo.memberList[v.nUserId] = {}
  2696. end
  2697. roomInfo.memberList[v.nUserId].cardList = {}
  2698. roomInfo.memberList[v.nUserId].cardList = cardData
  2699. local viewId = app.room:getViewIdByUserId(v.nUserId)
  2700. end
  2701. self.xiaojuChaPaiView:liangShouPai(false)
  2702. for k,v in pairs(roomInfo.memberList or {}) do
  2703. local cardData = v.cardList
  2704. local viewId = app.room:getViewIdByUserId(k)
  2705. if viewId == 1 or viewId == 2 then
  2706. cardData = {}
  2707. local lens = table.nums(v.cardList)
  2708. local list = v.cardList
  2709. for i = 1,lens do
  2710. cardData[i] = table.remove(list,#list)
  2711. end
  2712. end
  2713. if viewId ~= self:getMeViewId() then
  2714. if self._selfCards[viewId] then
  2715. local lens = table.nums(cardData)
  2716. local lens1 = table.nums(self._selfCards[viewId])
  2717. for i = 1, lens do
  2718. if self._selfCards[viewId][i] then
  2719. self._selfCards[viewId][i]:setCard(cardData[i])
  2720. end
  2721. end
  2722. end
  2723. end
  2724. end
  2725. --玩家分数
  2726. for k,v in pairs(roomInfo.playList) do
  2727. local viewId = app.room:getViewIdByUserId(k)
  2728. local nScore = v.nTotalMoney
  2729. local memberInfo = app.room.roomInfo.memberList[k]
  2730. --[[roomInfo.memberList[v.nUserId].nPlayerFlag = 0--]]
  2731. memberInfo.nTotalMoney = nScore
  2732. self.PlayerView:setPlayerScore(viewId,nScore)
  2733. end
  2734. --结束原因表现
  2735. if roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_HUANG_ZHUANG or (not isSomebodyHuPai and roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_TUOGUAN_DISMISS) then
  2736. showChaPai()
  2737. --播放黄庄动画
  2738. local userInfo=app.room:getUserInfo(app.user.loginInfo.uid)
  2739. if userInfo then
  2740. ZPSound.PlayHuangZhuang(userInfo.sex)
  2741. end
  2742. self.xiaojuChaPaiView:PlayHuangZhuangAni(true)
  2743. elseif roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_LONG_NOT_END then
  2744. -- showConfirmDialog("游戏长久未打完,超过房间存在时间,本局结束",function()
  2745. -- logE("超时回到大厅")
  2746. -- self:runAction(cc.Sequence:create(cc.DelayTime:create(1.0),cc.CallFunc:create(function ()
  2747. -- --房间号
  2748. -- local roomid = app.room.roomInfo.nShowTableId
  2749. -- --app:gotoView(import("luaScript.Views.Main.MainView"):new(app.gameId, roomid))
  2750. -- gotoMainView(app.gameId,roomid)
  2751. -- end)))
  2752. -- end,nil)
  2753. end
  2754. local function nextCallBackFun()
  2755. self:resetGameData()
  2756. app.room.roomInfo.tingCards = {}
  2757. end
  2758. local function showAllJieSuan()
  2759. if self.RoomCountAllViewUI then
  2760. if not self.RoomCountAllViewUI:isVisible() then
  2761. self.RoomCountAllViewUI:playAni()
  2762. end
  2763. self.RoomCountAllViewUI:setVisible(true)
  2764. self:showGameOverAward()
  2765. end
  2766. end
  2767. if app.room.roomInfo.isGameOver == 0 then
  2768. self.xiaojuView = doushisiRoomXiaoJuView:new(nextCallBackFun,false)
  2769. else
  2770. self.xiaojuView = doushisiRoomXiaoJuView:new(showAllJieSuan,false)
  2771. end
  2772. self:addChild(self.xiaojuView)
  2773. self.xiaojuView:setVisible(false)
  2774. --结束
  2775. if onEnd then
  2776. onEnd()
  2777. end
  2778. end
  2779. log("2000000000-doushisiRoomView - addCallBack(runGameXiaoJuResponse)" )
  2780. self:addCallBack(runGameXiaoJuResponse);
  2781. end
  2782. -- 大局结算
  2783. function doushisiRoomView:onGameDaJuResponse(data)
  2784. app.club_php:dispatchEvent({name = GAME_EVENT.CLUB_BACK_ROOM})
  2785. local function runGameDaJuResponse(onEnd)
  2786. local response = data.response.playList
  2787. -- 打开结算
  2788. local view = ZPRoomCountAllView:new(response,data.response.endTime);
  2789. view:setAnchorPoint(cc.p(0.5, 0.5));
  2790. local visibleSize = getVisibleSize()
  2791. view:setPosition(cc.p(visibleSize.width/2,visibleSize.height/2))
  2792. self:addChild(view);
  2793. self.RoomCountAllViewUI = view;
  2794. app.room:dispatchEvent({name = GAME_EVENT.DISSMISS_CLOSE});
  2795. if true then
  2796. view:playAni()
  2797. view:setVisible(false);
  2798. else
  2799. log("2000000000-onGameDaJuResponse --------- yichangjiesu ")
  2800. --结算直接播放动画
  2801. view:playAni()
  2802. self:showGameOverAward()
  2803. end
  2804. if onEnd then
  2805. onEnd()
  2806. end
  2807. end
  2808. log("2000000000-ZPRoomView - addCallBack(runGameDaJuResponse)")
  2809. self:addCallBack(runGameDaJuResponse);
  2810. end
  2811. function doushisiRoomView:onQiangBaResponese(data)
  2812. local function runQiangBa(onEnd)
  2813. log("2000000000-doushisiRoomView - addCallBack(onQiangBaResponese)" )
  2814. local response = data.response
  2815. local nUserId = response.nUserId
  2816. local Card = response.nCard
  2817. local code = response.mainOpCode
  2818. local viewId = app.room:getViewIdByUserId(nUserId)
  2819. local operationCardlist = {}
  2820. operationCardlist[ZPDef.OpCode.OP_HU] = {}
  2821. table.insert(operationCardlist[ZPDef.OpCode.OP_HU],Card)
  2822. if code > 0 then
  2823. self:showOpeation(code,operationCardlist,false,true)
  2824. end
  2825. if self:getIsMeUId(nUserId) then
  2826. --检测是否少牌
  2827. self:checkCardAndRecover()
  2828. end
  2829. --结束
  2830. if onEnd then
  2831. onEnd()
  2832. end
  2833. end
  2834. log("2000000000-doushisiRoomView - addCallBack(runQiangBa)")
  2835. self:addCallBack(runQiangBa)
  2836. end
  2837. ---
  2838. -- 托管通知
  2839. -- @param data
  2840. -- @return
  2841. --
  2842. function doushisiRoomView:onHostingRequest( data )
  2843. local response = data.response
  2844. if response.nUserId == app.user.loginInfo.uid then
  2845. if response.status == 1 then --托管状态
  2846. self.toolView:showTuoGuan(true)
  2847. elseif response.status == 0 then--取消托管状态
  2848. self.toolView:showTuoGuan(false)
  2849. end
  2850. end
  2851. local isTuoGuan = response.status == 1;
  2852. local viewId = app.room:getViewIdByUserId(response.nUserId)
  2853. self.PlayerView:showTuoGuanByViewId(viewId,isTuoGuan)
  2854. end
  2855. --游戏消息
  2856. function doushisiRoomView:bindGameMessage()
  2857. doushisiRoomView.super.bindGameMessage(self)
  2858. --起手操作提示
  2859. self:bindEvent(app.room , "onUserOperateResponse", handler(self , self.onUserOperateResponse));
  2860. --起手操作成功
  2861. self:bindEvent(app.room , "onBroadCastQiShouOperate", handler(self , self.onUserOperateSuccess));
  2862. --广播玩家进牌
  2863. self:bindEvent(app.room , "onBroadCastUserGetCard", handler(self , self.onBroadCastUserGetCard));
  2864. --广播头家出牌
  2865. self:bindEvent(app.room , "onBroadCastBankerOutCard", handler(self , self.onBroadCastBankerOutCard));
  2866. --通知打出的牌可能包赔
  2867. self:bindEvent(app.room , "onOutCardIsBaoPeiResponse", handler(self , self.onOutCardIsBaoPeiResponse));
  2868. --通知进牌后操作提示
  2869. self:bindEvent(app.room , "onUserGetCardOperteResponse", handler(self , self.onUserGetCardOperteResponse));
  2870. --刷新手牌
  2871. --self:bindEvent(app.room , "onReflashHandcardsResponese" , handler(self , self.onReflashHandcardsResponese));
  2872. --抢巴操作通知
  2873. self:bindEvent(app.room , "onQiangBaResponese" , handler(self , self.onQiangBaResponese));
  2874. --切换视图
  2875. --self:bindEvent(app , ZPDef.ZPEvent.ChangeViewType, handler(self, self.changeViewType))
  2876. --过巴操作
  2877. --self:bindEvent(app.room, "onGuoBaResponse", handler(self, self.onGuoBaResponse))
  2878. -- 托管
  2879. self:bindEvent(app.room , ZPDef.ZPEvent.HostingRequest, handler(self, self.onHostingRequest))
  2880. end
  2881. function doushisiRoomView:resetGameData()
  2882. logE("===========重置游戏数据===============")
  2883. self.handCardRoot = {}
  2884. self.handCardValueLocal = {}
  2885. self.handCardValueBak = {}
  2886. self:setOutCardLineVisible(false)
  2887. self:setWetChatVisible(false)
  2888. self:setBtnSitDownVisible(false)
  2889. self:setOutCardVisible(false)
  2890. self:setOperatorPanelView(false)
  2891. self:setGuideView(false)
  2892. self:setHandTempCardVisible(false)
  2893. self:setCircleCardLeftPanelView(false)
  2894. self:setLiangPaiVisible(false)
  2895. self:setTingCardViewVisible(false)
  2896. self:setDingPiaoVisible(false)
  2897. self:setLayoutScoreTipVisible(false)
  2898. if self.PlayerView then
  2899. self.PlayerView:setReadyStateVisible(false)
  2900. self.PlayerView:setBankerVisible()
  2901. self.PlayerView:setOperatorTipVisible(false)
  2902. self.PlayerView:setAllClockVisible(false)
  2903. self.PlayerView:hideLeftCard()
  2904. end
  2905. --隐藏工具界面 详情
  2906. if self.toolView.ui.Items.ImageView_Rule_bg then
  2907. self.toolView.ui.Items.ImageView_Rule_bg:setVisible(false)
  2908. end
  2909. --隐藏操作吃界面
  2910. self.operationView:setAllEatView(false)
  2911. self.ui.Items.TextBMFont_leftCardNum:setPosition(self.leftCardNumPos)
  2912. self.ui.Items.ImageView_zhang:setPositionY(self.leftCardNumPos.y)
  2913. --操作码
  2914. self.operationLocalCode = 0
  2915. self.isMoPaiOperator = false
  2916. self.isGameOver = false
  2917. self.isTianHu = false
  2918. self.isGodHand = false
  2919. --听牌重置
  2920. self.isNoCardTingPai = false
  2921. self.tingCardLocal = {}
  2922. self.tableHuXiList = {}
  2923. --弃牌
  2924. self.qiPaiList = {}
  2925. --发牌器
  2926. self.ui.Items.ImageView_card_bg:removeAllChildren()
  2927. self.fapaiqiLeftCard = nil
  2928. self.ui.Items.TextBMFont_leftCardNum:setText("0")
  2929. --庄家爆牌标志
  2930. self.bankerBaoPao = nil
  2931. --移除所有的牌局
  2932. for i = 1,ZPDef.GameMaxPlayer do
  2933. local layoutNode = string.format("ImageView_outCardImg_%d",i)
  2934. self.ui.Items[layoutNode]:removeAllChildren()
  2935. end
  2936. for i = 1,ZPDef.GameMaxPlayer do
  2937. local layoutNode = string.format("LayoutMain_%d",i)
  2938. self.ui.Items[layoutNode]:removeAllChildren()
  2939. end
  2940. self.ui.Items.Layout_Player_HuEffect:removeAllChildren()
  2941. self:clearXJChaPaiView()
  2942. for i = 1, ZPDef.GameMaxPlayer do
  2943. --[[ local giveupName = string.format("Layout_giveUp_%d",i)
  2944. local weaveCardName = string.format("Layout_player1Table_%d",i)--]]
  2945. --重置开招次数
  2946. self.playerZhao[i] = 0
  2947. --弃牌数组
  2948. self.qiPaiList[i] = {}
  2949. --[[ self.ui.Items[weaveCardName]:removeAllChildren()
  2950. self.ui.Items[giveupName]:removeAllChildren()--]]
  2951. end
  2952. self.PlayerView:setHuXizero()
  2953. if self.xiaojuView then
  2954. self.xiaojuView:removeFromParent()
  2955. self.xiaojuView = nil
  2956. end
  2957. if self.xiaojuChaPaiView then
  2958. self.xiaojuChaPaiView:setVisible(false)
  2959. end
  2960. for i = 1, ZPDef.GameMaxPlayer do
  2961. if self._selfCards[i] then
  2962. self._selfCards[i] = {}
  2963. end
  2964. end
  2965. for i = 1, #self.handCardRoot do
  2966. self.handCardRoot[i]:removeFromParent()
  2967. end
  2968. for i = 1, ZPDef.GameMaxPlayer do
  2969. self.qiPaiView[i]:reset()
  2970. end
  2971. for i = 1, ZPDef.GameMaxPlayer do
  2972. self.opOutCard[i]:reset()
  2973. end
  2974. --停止一些动画
  2975. self.ui:stopAllActions()
  2976. self.isQiShou = true
  2977. self.moValue = 0
  2978. self.isBiChi = 0
  2979. self.handCardItem = {}
  2980. self.PlayerView:hideBaoJiao()
  2981. self.baoJiaoStatus = 0
  2982. self.isTishi = false
  2983. self.moLieshu = 0
  2984. self.myHandCardNums = 0
  2985. self.touchPoker = nil
  2986. end
  2987. --胡牌特效
  2988. function doushisiRoomView:playHuEffect(viewId,onEnd,isRecontect)
  2989. logE("doushisiRoomView playHuEffect",app.room.roomInfo.huType,viewId)
  2990. local nUserID = app.room:getUserIdByViewId(viewId)
  2991. if (app.room.roomInfo.huType and app.room.roomInfo.huType >= 0) and (app.room.roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_NORMAL) then
  2992. local userInfo=app.room:getUserInfo(nUserID)
  2993. if userInfo then
  2994. ZPSound.PlayOperateSound(userInfo.sex,4)
  2995. --if ZPFuc.isZiMo(app.room.roomInfo.huType) then
  2996. --ZPSound.PlayOperateSound(userInfo.sex,11)
  2997. --else
  2998. --ZPSound.PlayOperateSound(userInfo.sex,4)
  2999. --end
  3000. end
  3001. end
  3002. local name = string.format("Layout_outCardPoint_%d",viewId)
  3003. local mLayout = self.ui.Items[name]
  3004. local huEffectUI = loadUI("zp_base/res/ui/ui_fangjian/zipai_ui_effectHu.ui")
  3005. local pos = mLayout:getPosition()
  3006. if viewId == self:getMeViewId() then
  3007. local centerPos = cc.Director:getInstance():getVisibleSize()
  3008. local pos = cc.p(centerPos.width/2,centerPos.height/2 - 70)
  3009. huEffectUI:setPosition(pos)
  3010. elseif viewId == 1 then
  3011. huEffectUI:setPosition(cc.pAdd(pos,cc.p(90,-30)))
  3012. elseif viewId == 2 then
  3013. huEffectUI:setPosition(cc.pAdd(pos,cc.p(0,20)))
  3014. elseif viewId == 3 then
  3015. huEffectUI:setPosition(cc.pAdd(pos,cc.p(-70,-30)))
  3016. end
  3017. self.ui.Items.Layout_Player_HuEffect:addChild(huEffectUI,2)
  3018. local pPos = cc.p(0,0)
  3019. for k,v in pairs(self.playerPos) do
  3020. if k == viewId then
  3021. --pPos = v.headPos
  3022. if viewId == 2 then
  3023. pPos.y = v.headPos.y + 25
  3024. pPos.x = v.headPos.x
  3025. elseif viewId == 1 then
  3026. pPos.y = v.headPos.y + 15
  3027. pPos.x = v.headPos.x
  3028. elseif viewId == 3 then
  3029. pPos.y = v.headPos.y + 15
  3030. pPos.x = v.headPos.x
  3031. elseif viewId == 4 then
  3032. pPos.y = v.headPos.y + 15
  3033. pPos.x = v.headPos.x
  3034. end
  3035. end
  3036. end
  3037. local mSpawn = cc.Spawn:create(cc.MoveTo:create(0.5,pPos),cc.ScaleTo:create(0.3,0.5))
  3038. huEffectUI:runAction(cc.Sequence:create(cc.DelayTime:create(0.5),mSpawn))
  3039. --动画展现
  3040. if app.room.roomInfo.huType and app.room.roomInfo.huType >= 0 then
  3041. local name = ""
  3042. local bankerViewId = app.room:getViewIdBySeatId(app.room.roomInfo.nBankSeatId)
  3043. local nWinerId = app.room.roomInfo.winUserId
  3044. local winerViewId = app.room:getViewIdByUserId(nWinerId)
  3045. if app.room.roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_HUANG_ZHUANG then--app.room.roomInfo.huType == 0 and
  3046. name = "zp_room_chapai_jiao.png"--显示叫(表示听牌了)
  3047. --elseif ZPFuc.isZiMo(app.room.roomInfo.huType) then
  3048. --name = "zp_room_chapai_zimo.png"
  3049. else
  3050. name = "zp_room_chapai_hu.png"--string.format(ZPDef.TipFile.HU,app.room.roomInfo.huType)
  3051. end
  3052. huEffectUI.Items.ImageView_huType:loadTextureFromPlist(name)
  3053. end
  3054. isRecontect = true--不显示动画
  3055. if isRecontect then
  3056. huEffectUI.Items.ImageView_Light:setVisible(false)
  3057. huEffectUI.Items.ImageView_Point:setVisible(false)
  3058. huEffectUI.Items.ImageView_Coin:setVisible(false)
  3059. self:showPaoImage()
  3060. self:runAction(cc.Sequence:create(cc.DelayTime:create(0.8),cc.CallFunc:create(function ()
  3061. if onEnd then
  3062. onEnd()
  3063. end
  3064. end)))
  3065. return
  3066. end
  3067. local mSpawn1 = cc.Spawn:create(cc.ScaleTo:create(0.3,1.0),cc.RotateBy:create(2,-120*6))
  3068. huEffectUI.Items.ImageView_Point:runAction(mSpawn1)
  3069. local mSpawn2 = cc.Spawn:create(cc.ScaleTo:create(0.3,1.0),cc.RotateBy:create(2,120*6))
  3070. huEffectUI.Items.ImageView_Light:runAction(mSpawn2)
  3071. huEffectUI.Items.ImageView_Coin:setScale(0)
  3072. local mSeq1 = cc.Sequence:create(cc.ScaleTo:create(0.3,1))
  3073. huEffectUI.Items.ImageView_Coin:runAction(mSeq1)
  3074. huEffectUI.Items.ImageView_huType:setScale(2)
  3075. huEffectUI.Items.ImageView_huType:setOpacity(0)
  3076. local mSeq2 = cc.Sequence:create(cc.DelayTime:create(0.6),cc.FadeIn:create(0),cc.ScaleTo:create(0.2,1.0))
  3077. huEffectUI.Items.ImageView_huType:runAction(mSeq2)
  3078. huEffectUI:runAction(cc.Sequence:create(cc.DelayTime:create(2.2),cc.CallFunc:create(function()
  3079. huEffectUI.Items.ImageView_Light:setVisible(false)
  3080. huEffectUI.Items.ImageView_Point:setVisible(false)
  3081. huEffectUI.Items.ImageView_Coin:setVisible(false)
  3082. self:showPaoImage()
  3083. if onEnd then
  3084. onEnd()
  3085. end
  3086. end)))
  3087. end
  3088. --点炮显示
  3089. function doushisiRoomView:showPaoImage()
  3090. if app.room.roomInfo.dianPaoUserId and app.room.roomInfo.dianPaoUserId >= 0 then
  3091. local dianPaoViewId = app.room:getViewIdByUserId(app.room.roomInfo.dianPaoUserId)
  3092. local name = string.format("ImageView_outCardImg_%d",dianPaoViewId)
  3093. local img = self.ui.Items[name]
  3094. local size = img:getContentSize()
  3095. --点炮精灵
  3096. local mSprite = cc.ImageView:createNode()
  3097. mSprite:loadTextureFromPlist("zp_room_chapai_dianpao.png")
  3098. img:addChild(mSprite)
  3099. mSprite:setPosition(cc.p(size.width/2,size.height/2))
  3100. end
  3101. end
  3102. function doushisiRoomView:onClickOpBtn(data)
  3103. --[[ self.isGodHand = true
  3104. --防止一直卡住的情况
  3105. local seq = cc.Sequence:create(cc.DelayTime:create(2.0),cc.CallFunc:create(function ()
  3106. self.isGodHand = false
  3107. end))
  3108. self:runAction(seq)--]]
  3109. end
  3110. function doushisiRoomView:setTingCardViewVisible(bVisible,tingCards)
  3111. end
  3112. function doushisiRoomView:showTingPaiView(touchcCard)
  3113. end
  3114. function doushisiRoomView:hideOperation()
  3115. self.operationView:hideSelf()
  3116. end
  3117. function doushisiRoomView:setColorWhite()
  3118. end
  3119. return doushisiRoomView