您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

678 行
20 KiB

  1. local MJRoomToolView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomToolView")
  2. local MJRoomMessageView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomMessageView")
  3. local MJRoomPlayerView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomPlayerView")
  4. local MJDefine=MJFramework.MJImport("mj.luaScript.MJDefine")
  5. local MJFunction=MJFramework.MJImport("mj.luaScript.MJFunction")
  6. local MJHandCardView=MJFramework.MJImport("mj.luaScript.Views.Game.MJHandCardView")
  7. local MJRoomDirection=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomDirection")
  8. local MJWanFa=MJFramework.MJImport("luaScript.SubGameDefine.MaJiang.MJWanFa")
  9. local MJAnimationCompnent=MJFramework.MJImport("mj.luaScript.Views.Compnent.MJAnimationCompnent")
  10. local MJSound=MJFramework.MJImport("mj.luaScript.MJSound")
  11. local MJRoomReplayView=MJFramework.MJFrameworkClassImprot("mj.luaScript.Views.Room.MJRoomReplayView")
  12. local zigongRoomReplayView = class("zigongRoomReplayView", MJRoomReplayView)
  13. function zigongRoomReplayView:ctor(data)
  14. zigongRoomReplayView.super.ctor(self,data)
  15. -- --玩家牌局面板
  16. -- self.playerHandCards={}
  17. -- self.data=data
  18. -- app:changeGameProtocol(app.gameId,1)
  19. end
  20. function zigongRoomReplayView:loadUI()
  21. local ui = loadUI("mj_zigong/res/ui_fangjian/mj_zigong_roomView.ui")
  22. self.ui = ui;
  23. self:addChild(ui);
  24. end
  25. function zigongRoomReplayView:onEnter()
  26. zigongRoomReplayView.super.onEnter(self)
  27. self:setCheckDefault()
  28. self.huOrder = 0
  29. self:initRuleView ()
  30. end
  31. function zigongRoomReplayView:parseData()
  32. self.piaotimes = 0--记录有几次飘操作,为了飘完后删除飘字
  33. local data = self.data
  34. --战报解析
  35. self.reports={}
  36. local ops=string.split(data.ops,"|")
  37. for k,v in pairs(ops) do
  38. local op=string.split(v,",")
  39. local nUserId=tonumber(op[1])
  40. local opType=op[2]
  41. local opStr = op[3]
  42. if opType == "ShowAction" then
  43. local opList = {}
  44. if nUserId==0 then
  45. local temp = string.split(opStr, ";")
  46. for k,v in pairs(temp) do
  47. local temp2 = string.split(v, " ")
  48. local userId = tonumber(temp2[1])
  49. table.remove(temp2,1)
  50. local operates = temp2
  51. table.insert(opList,{nUserId = userId,operates = self:margeOperates(operates) })
  52. end
  53. else
  54. local operates = string.split(opStr, " ")
  55. table.insert(opList,{nUserId = nUserId,operates = self:margeOperates(operates) })
  56. end
  57. table.insert(self.reports,{opType=opType,opList=opList})
  58. elseif opType == "BaoPai" then
  59. local opList = {}
  60. local temp2 = {}
  61. table.insert(temp2,tonumber(1))
  62. table.insert(temp2,tonumber(2))
  63. table.insert(opList,{nUserId = nUserId,operates = self:margeOperates(temp2) })
  64. table.insert(self.reports,{opType="ShowBaoOpt",opList=opList})
  65. table.insert(self.reports,{nUserId=nUserId,opType="SubmitOp",submitOp = tonumber(opStr) })
  66. local tCards = string.split(opStr, "_")
  67. local card,redNum = nil,0
  68. if tCards[1] then card = tonumber(tCards[1]) end
  69. if tCards[2] then redNum = tonumber(tCards[2]) end
  70. table.insert(self.reports,{nUserId=nUserId,opType=opType,card=card,redNum=redNum})
  71. elseif opType == "SubmitOp" then --提交的操作
  72. local temp = string.split(opStr, "_")
  73. local submitOp = tonumber(temp[1])
  74. table.insert(self.reports,{nUserId=nUserId,opType=opType,submitOp = submitOp })
  75. elseif opType == "PiaoOpt" then
  76. self.piaotimes = self.piaotimes + 1
  77. local ops = string.split(opStr, "_")
  78. local piaostate = tonumber(ops[1])
  79. table.insert(self.reports,{nUserId=nUserId,opType=opType,piaostate = piaostate })
  80. elseif "DisCard"~=opType then
  81. local tCards = string.split(opStr, "_")
  82. local card,redNum = nil,0
  83. if tCards[1] then card = tonumber(tCards[1]) end
  84. if tCards[2] then redNum = tonumber(tCards[2]) end
  85. table.insert(self.reports,{nUserId=nUserId,opType=opType,card=card,redNum=redNum})
  86. end
  87. end
  88. if self.data.ext.luoboCards then
  89. local luoboCards=MJFunction.convertToCards(self.data.ext.luoboCards)
  90. if #luoboCards > 0 then
  91. table.insert(self.reports,{opType="BaLuoBo"})
  92. end
  93. end
  94. end
  95. --合并操作 只显示一个杠
  96. function zigongRoomReplayView:margeOperates(operates)
  97. local ops = {}
  98. local isGang = false
  99. for k,v in pairs(operates) do
  100. local op = tonumber(v)
  101. if (op==MJDefine.MJOperateType.OPREATE_ZHIGANG)
  102. or (op==MJDefine.MJOperateType.OPREATE_BAGANG)
  103. or (op==MJDefine.MJOperateType.OPREATE_ANGANG) then
  104. if not isGang then
  105. table.insert(ops,op)
  106. isGang = true
  107. end
  108. else
  109. table.insert(ops,op)
  110. end
  111. end
  112. return ops
  113. end
  114. function zigongRoomReplayView:startGame()
  115. self:onGameStartResponse()
  116. --设置为回放模式
  117. for k,v in pairs(self.playerHandCards) do
  118. v:setReplay(true)
  119. end
  120. app.room.roomInfo.laizi = tonum(self.data.ext.laizi)
  121. self:onGameSendCardResponse()
  122. self.playerHandCards[MJDefine.MyViewId]:removeTouchEvent()
  123. end
  124. function zigongRoomReplayView:initHanders()
  125. zigongRoomReplayView.super.initHanders(self)
  126. self.handers ["PiaoOpt"] = handler(self,self.onPiaoRes)
  127. self.handers ["BaoPai"] = handler(self,self.onBaoPaiRes)
  128. self.handers ["DianPao"] = handler(self,self.onDianPao)
  129. self.handers ["DianPaoHu"] = handler(self,self.onPlayerHu)
  130. self.handers ["QiangGangHu"] = handler(self,self.onPlayerHu)
  131. self.handers ["ZiMoHu"] = handler(self,self.onPlayerHu)
  132. self.handers ["ShowAction"] = handler(self,self.onShowOperates)
  133. self.handers ["ShowBaoOpt"] = handler(self,self.onShowBaoOpt)
  134. self.handers ["SubmitOp"] = handler(self,self.onSubmitOperate)
  135. self.handers ["ActionWait"] = handler(self,self.onActionWait)
  136. self.handers ["BaLuoBo"]=handler(self,self.onBaLuoBo)
  137. end
  138. function zigongRoomReplayView:onActionWait(data)
  139. local response = {
  140. nUserId = data.nUserId,
  141. opType = data.card,
  142. }
  143. self:onWaitOperate({response = response})
  144. end
  145. function zigongRoomReplayView:onSubmitOperate(data)
  146. local viewId = app.room:getViewIdByUserId(data.nUserId)
  147. local Layout_Operate = self.playerHandCards[viewId].ui.Items.Layout_Operate
  148. local btn = Layout_Operate:getChildByTag(data.submitOp)
  149. if btn then
  150. local hand = cc.Sprite:create("mj/res/ui/zy_fangjian/mj_room_hand.png")
  151. btn:addChild(hand)
  152. local size = btn:getContentSize()
  153. hand:setPosition(cc.p(size.width/2+20,size.height/2-20))
  154. local action = cc.Sequence:create(cc.MoveBy:create(0.5,cc.p(-10,10)),cc.MoveBy:create(0.5,cc.p(10,-10)))
  155. hand:runAction(cc.RepeatForever:create(action))
  156. -- if data.submitOp == MJDefine.MJOperateType.OPREATE_CANCEL then
  157. btn:runAction(cc.Sequence:create(cc.DelayTime:create(1),cc.CallFunc:create(function()
  158. self.playerHandCards[viewId]:hideOperate()
  159. end)))
  160. -- end
  161. end
  162. end
  163. function zigongRoomReplayView:onShowOperates(data)
  164. local opList = data.opList
  165. for k,v in pairs(opList) do
  166. local nUserId = v.nUserId
  167. local operates = v.operates
  168. local viewId=app.room:getViewIdByUserId(nUserId)
  169. local Layout_Operate = self.playerHandCards[viewId].ui.Items.Layout_Operate
  170. Layout_Operate:removeAllChildren()
  171. Layout_Operate:setVisible(true)
  172. local x=Layout_Operate:getContentSize().width
  173. if viewId==MJDefine.PlayerViewType.Left then
  174. x = 0
  175. end
  176. table.insert(operates,1,MJDefine.MJOperateType.OPREATE_CANCEL)
  177. local y=Layout_Operate:getContentSize().height/2
  178. local function createOperate(op,isLeft)
  179. local btnOperate=cc.Button:createNode()
  180. btnOperate:setDefaults()
  181. btnOperate:setText("")
  182. btnOperate:loadTextureNormal(MJDefine.MJOperateImage[op])
  183. if isLeft then
  184. x = x + MJDefine.MJ_OPERATE_PADDING
  185. else
  186. x = x -MJDefine.MJ_OPERATE_PADDING
  187. end
  188. btnOperate:setPosition(cc.p(x,y))
  189. btnOperate:setTag(op)
  190. Layout_Operate:addChild(btnOperate)
  191. end
  192. if viewId==MJDefine.PlayerViewType.Left then
  193. for i = #operates,1,-1 do
  194. local op = tonumber(operates[i])
  195. createOperate(op,true)
  196. end
  197. else
  198. for _,strOp in pairs(operates) do
  199. local op = tonumber(strOp)
  200. createOperate(op,false)
  201. end
  202. end
  203. -- self.playerHandCards[viewId]:
  204. if viewId~=MJDefine.MyViewId then
  205. local node = self.playerView.allNodes[viewId]
  206. local pos = cc.pAdd(node.player:getPosition(),cc.p(38,66))
  207. if viewId==MJDefine.PlayerViewType.Left then
  208. Layout_Operate:setAnchorPoint(cc.p(0,0.5))
  209. elseif viewId==MJDefine.PlayerViewType.Right then
  210. pos.x = pos.x-100
  211. elseif viewId==MJDefine.PlayerViewType.Top then
  212. Layout_Operate:setAnchorPoint(cc.p(1,1))
  213. pos.y = pos.y-33*2
  214. end
  215. if viewId==MJDefine.PlayerViewType.Left or viewId==MJDefine.PlayerViewType.Right then
  216. pos.y = pos.y-104
  217. end
  218. Layout_Operate:setPosition(pos)
  219. Layout_Operate:setScale(0.7)
  220. end
  221. end
  222. end
  223. function zigongRoomReplayView:onShowBaoOpt(data)
  224. local opList = data.opList
  225. for k,v in pairs(opList) do
  226. local nUserId = v.nUserId
  227. local operates = v.operates
  228. local viewId=app.room:getViewIdByUserId(nUserId)
  229. local Layout_Operate = self.playerHandCards[viewId].ui.Items.Layout_Operate
  230. Layout_Operate:removeAllChildren()
  231. Layout_Operate:setVisible(true)
  232. local x=Layout_Operate:getContentSize().width
  233. if viewId==MJDefine.PlayerViewType.Left then
  234. x = 0
  235. end
  236. table.insert(operates,1,MJDefine.MJOperateType.OPREATE_CANCEL)
  237. local y=Layout_Operate:getContentSize().height/2
  238. local TOperateImage = {
  239. [0]="mj/res/ui/zy_fangjian/operate/mj_btn_guo.png",
  240. [1]="mj/res/ui/zy_fangjian/operate/mj_btn_bao1.png",
  241. -- [2]="mj/res/ui/zy_fangjian/operate/mj_btn_bozimo.png",
  242. }
  243. if self.data and self.data.ext then
  244. local specrule = self.data.ext.specrule or 0
  245. local bozimo = getNumBand(specrule, 0x0002) > 0
  246. if bozimo then
  247. TOperateImage[2] = "mj/res/ui/zy_fangjian/operate/mj_btn_bozimo.png"
  248. end
  249. end
  250. local function createOperate(op,isLeft)
  251. local btnOperate=cc.Button:createNode()
  252. btnOperate:setDefaults()
  253. btnOperate:setText("")
  254. btnOperate:loadTextureNormal(TOperateImage[op])
  255. if isLeft then
  256. x = x + MJDefine.MJ_OPERATE_PADDING
  257. else
  258. x = x -MJDefine.MJ_OPERATE_PADDING
  259. end
  260. btnOperate:setPosition(cc.p(x,y))
  261. btnOperate:setTag(op)
  262. Layout_Operate:addChild(btnOperate)
  263. end
  264. if viewId==MJDefine.PlayerViewType.Left then
  265. for i = #operates,1,-1 do
  266. local op = tonumber(operates[i])
  267. if TOperateImage[op] then
  268. createOperate(op,true)
  269. end
  270. end
  271. else
  272. for _,strOp in pairs(operates) do
  273. local op = tonumber(strOp)
  274. if TOperateImage[op] then
  275. createOperate(op,false)
  276. end
  277. end
  278. end
  279. -- self.playerHandCards[viewId]:
  280. if viewId~=MJDefine.MyViewId then
  281. local node = self.playerView.allNodes[viewId]
  282. local pos = cc.pAdd(node.player:getPosition(),cc.p(38,66))
  283. if viewId==MJDefine.PlayerViewType.Left then
  284. Layout_Operate:setAnchorPoint(cc.p(0,0.5))
  285. elseif viewId==MJDefine.PlayerViewType.Right then
  286. pos.x = pos.x-100
  287. elseif viewId==MJDefine.PlayerViewType.Top then
  288. Layout_Operate:setAnchorPoint(cc.p(1,1))
  289. pos.y = pos.y-33*2
  290. end
  291. if viewId==MJDefine.PlayerViewType.Left or viewId==MJDefine.PlayerViewType.Right then
  292. pos.y = pos.y-104
  293. end
  294. Layout_Operate:setPosition(pos)
  295. Layout_Operate:setScale(0.7)
  296. end
  297. end
  298. end
  299. function zigongRoomReplayView:onOperate(data)
  300. local roomInfo=app.room.roomInfo
  301. local operates={
  302. ["Peng"]=MJDefine.MJOperateType.OPREATE_PENG,
  303. ["BaGang"]=MJDefine.MJOperateType.OPREATE_BAGANG,
  304. ["AnGang"]=MJDefine.MJOperateType.OPREATE_ANGANG,
  305. ["Gang"]=MJDefine.MJOperateType.OPREATE_ZHIGANG,
  306. ["ZhiGang"]=MJDefine.MJOperateType.OPREATE_ZHIGANG,
  307. }
  308. self.fromSeatId = self.fromSeatId or roomInfo.memberList[data.nUserId].nSeatId
  309. local response={
  310. nUserId=data.nUserId,
  311. opCard=data.card,
  312. redNum = data.redNum,
  313. opType=operates[data.opType],
  314. -- operates={},
  315. nSeatId=roomInfo.memberList[data.nUserId].nSeatId,
  316. isNeedOutCard=0,
  317. fromSeatId=self.fromSeatId,
  318. }
  319. --碰了之后需要出牌
  320. if data.opType=="Peng" then
  321. response.isNeedOutCard=1
  322. end
  323. for k,v in pairs(self.playerHandCards) do
  324. v:hideOperate()
  325. end
  326. self:onOperationCodeSuccess({response=response})
  327. end
  328. function zigongRoomReplayView:onOutCard(data)
  329. local roomInfo=app.room.roomInfo
  330. local response={
  331. nUserId=data.nUserId,
  332. card=data.card,
  333. operates={},
  334. -- nSeatId=roomInfo.memberList[data.nUserId].nSeatId,
  335. }
  336. self.fromSeatId=roomInfo.memberList[data.nUserId].nSeatId
  337. local viewId=app.room:getViewIdByUserId(data.nUserId)
  338. self.playerHandCards[viewId]:hideOperate()
  339. if viewId==MJDefine.MyViewId then
  340. -- self.playerHandCards[MJDefine.MyViewId].touchMJ=self.playerHandCards[MJDefine.MyViewId]:getMjByValue(data.card)
  341. end
  342. self:onOutCardSuccess({response=response})
  343. end
  344. function zigongRoomReplayView:onBaoPaiRes(data)
  345. local response={
  346. nUserId=data.nUserId,
  347. isBaoPai=data.card,
  348. }
  349. local viewId=app.room:getViewIdByUserId(data.nUserId)
  350. self.playerHandCards[viewId]:hideOperate()
  351. self:onBaoPai({response=response})
  352. end
  353. function zigongRoomReplayView:onPiaoRes(data)
  354. local response={
  355. nUserId=data.nUserId,
  356. piaostate=data.piaostate,
  357. }
  358. local viewId=app.room:getViewIdByUserId(data.nUserId)
  359. self.playerHandCards[viewId]:hideOperate()
  360. self:onPiaoResponse({response=response})
  361. local viewId = app.room:getViewIdByUserId(data.nUserId)
  362. local ui=loadUI("mj_zigong/res/ui_fangjian/mj_zigong_replay_piao.ui")
  363. local pos = self.playerHandCards[viewId]:getAnimationPostion()
  364. ui:setPosition(pos)
  365. self.ui.Items.Layout_Effect_luobo:addChild(ui)
  366. local btn
  367. if tonumber(data.piaostate) == 1 then
  368. btn = ui.Items.Button_Piao
  369. elseif tonumber(data.piaostate) == 0 then
  370. btn = ui.Items.Button_BuPiao
  371. end
  372. if btn then
  373. local hand = cc.Sprite:create("mj/res/ui/zy_fangjian/mj_room_hand.png")
  374. btn:addChild(hand)
  375. local size = btn:getContentSize()
  376. hand:setPosition(cc.p(size.width/2+20,size.height/2-20))
  377. local action = cc.Sequence:create(cc.MoveBy:create(0.5,cc.p(-10,10)),cc.MoveBy:create(0.5,cc.p(10,-10)))
  378. hand:runAction(cc.RepeatForever:create(action))
  379. btn:runAction(cc.Sequence:create(cc.DelayTime:create(1),cc.CallFunc:create(function()
  380. ui:removeFromParent()
  381. ui = nil
  382. self.piaotimes = self.piaotimes - 1
  383. if self.piaotimes == 0 then--所有飘操作已经完成了,删除桌面上的飘字
  384. --清除桌面上的飘
  385. self.ui.Items.Layout_Effect_luobo:removeAllChildren()
  386. end
  387. end)))
  388. end
  389. end
  390. function zigongRoomReplayView:onDianPao(data)
  391. self.dpUserId = data.nUserId or 0
  392. end
  393. function zigongRoomReplayView:onPlayerHu(data)
  394. local roomInfo=app.room.roomInfo
  395. self.huOrder = self.huOrder + 1
  396. local huType = {
  397. ["ZiMoHu"] = MJDefine.MJGameHuType.HU_ZIMO,
  398. ["DianPaoHu"] = MJDefine.MJGameHuType.HU_DIANPAO,
  399. ["QiangGangHu"] = MJDefine.MJGameHuType.HU_DIANPAO,
  400. }
  401. local redRealCard = 0
  402. local isQiangGng = 0
  403. if data.opType == "QiangGangHu" then
  404. redRealCard = data.card
  405. isQiangGng =1
  406. end
  407. local response={
  408. nUserId=data.nUserId,
  409. huType = huType[data.opType],
  410. huCard = data.card,
  411. dpId = self.dpUserId,
  412. huOrder = self.huOrder,
  413. redRealCard = redRealCard,
  414. isQiangGng = isQiangGng,
  415. }
  416. local viewId=app.room:getViewIdByUserId(data.nUserId)
  417. for k,v in pairs(self.playerHandCards) do
  418. v:hideOperate()
  419. end
  420. self.playerHandCards[viewId]:hideOperate()
  421. self:onHuResponse({response=response})
  422. end
  423. function zigongRoomReplayView:onBaLuoBo()
  424. local luoboCards=MJFunction.convertToCards(self.data.ext.luoboCards)
  425. local function callback()
  426. self.ui.Items.Layout_Effect_luobo:removeAllChildren()
  427. end
  428. local function luoboNumCallBack()
  429. if self.data.ext.luobonum > 0 then
  430. local index = 1
  431. local playerNum = table.nums(self.data.ext.userExtInfo)
  432. for k,v in pairs(self.data.ext.userExtInfo) do
  433. local viewId = app.room:getViewIdByUserId(tonumber(k))
  434. local effect
  435. if index == playerNum then
  436. effect = MJAnimationCompnent.CreateLoBoLabel(v.luoboCount,callback)
  437. else
  438. effect = MJAnimationCompnent.CreateLoBoLabel(v.luoboCount)
  439. end
  440. local pos = self.playerHandCards[viewId]:getAnimationPostion()
  441. if viewId==MJDefine.PlayerViewType.My then
  442. effect:setPosition(pos.x+130,pos.y-60)
  443. elseif viewId==MJDefine.PlayerViewType.Left then
  444. effect:setPosition(pos.x-20-30,pos.y-70)
  445. elseif viewId==MJDefine.PlayerViewType.Right then
  446. effect:setPosition(pos.x+10-30,pos.y-70)
  447. elseif viewId==MJDefine.PlayerViewType.Top then
  448. effect:setPosition(pos.x+130,pos.y+10-50)
  449. end
  450. self.ui.Items.Layout_Effect_luobo_Lable:addChild(effect)
  451. index = index + 1
  452. end
  453. else
  454. callback()
  455. end
  456. end
  457. local function luoboCallBack()
  458. if luoboCards and #luoboCards>0 then
  459. local luoNum = #luoboCards
  460. --加一个黑底
  461. local layer = cc.LayerColor:create(cc.c4b(0,0,0,120))
  462. layer:setAnchorPoint(cc.p(0.5,0.5))
  463. layer:ignoreAnchorPointForPosition(false)
  464. layer:setPosition(cc.p(getWinSize().width/2,getWinSize().height/2))
  465. self.ui.Items.Layout_Effect_luobo:addChild(layer)
  466. for i,v in pairs(luoboCards) do
  467. local effect
  468. if i == #luoboCards then
  469. effect = MJAnimationCompnent.CreateLoBoEffect(v,self.desktopType,luoboNumCallBack)
  470. else
  471. effect = MJAnimationCompnent.CreateLoBoEffect(v,self.desktopType)
  472. end
  473. if MJDefine.LuoBoPos[luoNum] and MJDefine.LuoBoPos[luoNum][i] then
  474. effect:setPosition(MJDefine.LuoBoPos[luoNum][i])
  475. self.ui.Items.Layout_Effect_luobo:addChild(effect)
  476. end
  477. end
  478. else
  479. callback()
  480. end
  481. end
  482. luoboCallBack()
  483. end
  484. --出牌成功
  485. function zigongRoomReplayView:onOutCardSuccess(data)
  486. logE("zigongRoomReplayView:onOutCardSuccess(), response = ", table.tostring(data.response))
  487. --[[
  488. -- 出牌用户id
  489. , defVar("nOutCardUserId", VT_Int, -1)
  490. -- 出的牌
  491. , defVar("byOutCard", VT_UChar, -1)
  492. -- 可以的操作ma
  493. , defVar("mainOpCode", VT_Short, -1)
  494. -- 玩家操作
  495. , defVar("operations", VT_Vector(ChuPaiPlayerOperation), {})--]]
  496. local function runOnOutCardSuccess(onEnd)
  497. log("2000000000-zigongRoomReplayView - runOnOutCardSuccess---------")
  498. local viewId = app.room:getViewIdByUserId(data.response.nUserId)
  499. local card= data.response.card
  500. local operates=data.response.operates
  501. local typr = operates.opType
  502. if operates and table.nums(operates)>0 then
  503. self.operates = operates
  504. else
  505. self.operates = {}
  506. end
  507. local function callback()
  508. self.playerHandCards[MJDefine.MyViewId]:showOperate(operates,card)
  509. if onEnd then
  510. onEnd()
  511. end
  512. end
  513. -- self.lastOutCard = card
  514. self.lastOutViewId = viewId
  515. local player = app.room.roomInfo.memberList[data.response.nUserId]
  516. if self.playerHandCards[viewId] then --and (viewId~=MJDefine.MyViewId or player.isBaoPai == 1)
  517. self.playerHandCards[viewId]:onOutCard(card,callback)--onOutCard(data.response,true)
  518. app.room:dispatchEvent({name = MJDefine.MJEvent.OutCardFalg, value=card ,viewId=viewId})
  519. if viewId==MJDefine.MyViewId then
  520. self.playerHandCards[viewId]:setTing(false)
  521. end
  522. else
  523. callback()
  524. end
  525. end
  526. log("2000000000-zigongRoomReplayView - addCallBack(runOnOutCardSuccess)")
  527. self:addCallBack(runOnOutCardSuccess)
  528. end
  529. function zigongRoomReplayView:onGameEnd(data)
  530. local function runGameXiaoJuResponse(onEnd)
  531. local function callback()
  532. --self:endReplay()
  533. --:showXiaoJuView()
  534. if onEnd then
  535. onEnd()
  536. end
  537. end
  538. local roomInfo = app.room.roomInfo
  539. local hutype=self.data.ext.huTypes
  540. local hucard=data.card
  541. self.direcionView:stopAllActions()
  542. -- local resultInfo=json.decode(roomInfo.strResultInfo)
  543. --所有胡牌的人 考虑抢杠胡的问题
  544. --所有胡牌的人 考虑抢杠胡的问题
  545. local viewIds={}
  546. local failViewId=0
  547. for k,v in pairs(roomInfo.memberList) do
  548. local viewId = app.room:getViewIdByUserId(v.nUserId)
  549. if v.result==MJDefine.MJGameResultType.Win then
  550. table.insert(viewIds,viewId)
  551. --处理掉huCard, 不加入手牌
  552. --播放音效
  553. if viewId==MJDefine.MyViewId then
  554. MJSound.PlayWinGame()
  555. end
  556. elseif v.result==MJDefine.MJGameResultType.Fail then
  557. failViewId=viewId
  558. if viewId==MJDefine.MyViewId then
  559. MJSound.PlayLoseGame()
  560. end
  561. end
  562. end
  563. self:showOpenCard()
  564. local function callback()
  565. self:showXiaoJuView()
  566. if onEnd then
  567. onEnd()
  568. end
  569. end
  570. if #viewIds>0 then
  571. for k,viewId in pairs(viewIds) do
  572. local effect
  573. local resultInfo = roomInfo.resultInfos
  574. local userId = app.room:getUserIdByViewId(viewId)
  575. if k == #viewIds then --只有最后播放胡牌动画的回调一次就可以了
  576. if resultInfo[userId].result == MJDefine.MJGameHuType.HU_ZIMO then
  577. effect = MJAnimationCompnent.CreateHuEffect("zimo",callback)
  578. else
  579. effect = MJAnimationCompnent.CreateHuEffect("hu",callback)
  580. end
  581. else
  582. end
  583. if effect then
  584. self:addChild(effect)
  585. effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
  586. effect:setVisible(false)
  587. end
  588. end
  589. else
  590. if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_HUANG_ZHUANG then
  591. local effect=MJAnimationCompnent.CreateLiuJuEffect(callback)
  592. self:addChild(effect)
  593. else
  594. callback()
  595. end
  596. end
  597. end
  598. log("2000000000-MJRoomView - addCallBack(runGameXiaoJuResponse)" )
  599. self:addCallBack(runGameXiaoJuResponse);
  600. end
  601. return zigongRoomReplayView