You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.8 KiB

  1. -- 单局战绩单元Layout
  2. local ZPDanJuItem = class("ZPDanJuItem")
  3. local ZPDef = ZPFramework.ZPImport("zp_base.luaScript.ZPDef")
  4. function ZPDanJuItem:ctor(gameRule, curJuShuData, jushu,zhanjiInfo, fromClub)
  5. --玩法,考虑扩展3人4人字牌
  6. self.gameRule = gameRule;
  7. self.curJuShuData = curJuShuData
  8. self.zhanjiInfo = zhanjiInfo
  9. self.jushu = jushu
  10. self.fromClub = fromClub;
  11. self.ui = loadUI("zp_base/res/ui/ui_zhanji/zipai_zhanji_danju_item_view.ui")
  12. self:initView()
  13. end
  14. function ZPDanJuItem:initView()
  15. -- 局数
  16. --编号
  17. if self.curJuShuData.flag == ZPDef.XiaoJuEndType.STOP_FLAG_NORMAL then
  18. self.ui.Items.Text_num:setText(tostring(self.jushu))
  19. elseif self.curJuShuData.flag == ZPDef.XiaoJuEndType.STOP_FLAG_HUANG_ZHUANG then
  20. self.ui.Items.Text_num:setText("黄庄")
  21. elseif self.curJuShuData.flag == ZPDef.XiaoJuEndType.STOP_FLAG_LONG_NOT_END then
  22. self.ui.Items.Text_num:setText("超时解散")
  23. elseif self.curJuShuData.flag == ZPDef.XiaoJuEndType.STOP_FLAG_DISBAND_GAME then
  24. self.ui.Items.Text_num:setText("解散游戏")
  25. end
  26. local time = os.date("%m-%d %H:%M",self.curJuShuData.endtime)
  27. self.ui.Items.Text_time:setText(tostring(time))
  28. self.ui.Items.Button:registerClick(handler(self , self.onClickRecord))
  29. self.ui.Items.Layout_Players:removeAllChildren()
  30. -- 所有的玩家
  31. local uiPlayers = self.ui.Items.Layout_Players
  32. for uid, score in pairs(self.curJuShuData.score) do
  33. local item = import("zp_base.luaScript.Views.ZhanJi.ZPZhanJiPlayer"):new(self.gameRule, uid, score)
  34. if item and item.ui then
  35. uiPlayers:addChild(item.ui)
  36. end
  37. end
  38. end
  39. function ZPDanJuItem:onClickRecord()
  40. local function showRecoreView()
  41. app.waitDialogManager:closeWaitNetworkDialog();
  42. logE("table.tostring(self.curJuShuData):"..table.tostring(self.curJuShuData))
  43. self.curJuShuData.nbound = self.zhanjiInfo.nbound
  44. self.curJuShuData.roomid = self.zhanjiInfo.roomid
  45. self.curJuShuData.gameRule = self.gameRule
  46. if not self.curJuShuData then
  47. showZiPaiPFailedResult("回放数据不存在")
  48. return
  49. end
  50. local haveOper = false
  51. if self.curJuShuData.ops then
  52. haveOper = string.len(self.curJuShuData.ops) > 0
  53. if self.curJuShuData.flag == ZiPai_XIAOJU_OVER_RESULT.STOP_FLAG_NORMAL then
  54. haveOper = true
  55. end
  56. end
  57. if not self.curJuShuData.user or not haveOper then
  58. showTooltip("游戏解散了")
  59. return
  60. end
  61. local view = ZiPaiFramework.Import("Views.Room.ZPRecordView"):new(self.curJuShuData);
  62. view:setAnchorPoint(cc.p(0.5, 0.5))
  63. app:showWaitDialog(view)
  64. end
  65. local protocolZhanJi;
  66. if self.fromClub then
  67. protocolZhanJi = app.club_zhanji
  68. else
  69. protocolZhanJi = app:getProtocolZhanJi(app.gameId)
  70. end
  71. if protocolZhanJi then
  72. app.waitDialogManager:showWaitNetworkDialog();
  73. protocolZhanJi:getZhanJiDetail(self.zhanjiInfo.pid, self.curJuShuData.subid, showRecoreView)
  74. end
  75. end
  76. return ZPDanJuItem