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.

197 lines
5.6 KiB

  1. local MJDefine=MJFramework.MJImport("mj.luaScript.MJDefine")
  2. local MJ=MJFramework.MJImport("mj.luaScript.Views.Game.MJ")
  3. local xueliuFlowView = class("xueliuFlowView", cc.UIView);
  4. function xueliuFlowView:ctor(data)
  5. xueliuFlowView.super.ctor(self);
  6. self.desktopType = MJDefine.DesktopType.TwoD;
  7. self.data = data or {};
  8. end
  9. function xueliuFlowView:loadUI( )
  10. local ui = loadUI("mj_xueliu/res/ui_fangjian/mj_xueliu_flow.ui");
  11. self.ui = ui;
  12. self:addChild(ui);
  13. end
  14. function xueliuFlowView:onEnter( )
  15. self:loadUI();
  16. self:initViews();
  17. self:initFlowView(self.data.liushuiDetail);
  18. self:bindEvent(app.room, MJDefine.MJEvent.EVENT_XIAOJU_VIEW_SHOWED, handler(self, self.onEventXiaoJuViewShowed));
  19. self:bindEvent(app.room, MJDefine.MJEvent.EVENT_DAJU_VIEW_SHOWED, handler(self, self.onEventXiaoJuViewShowed));
  20. end
  21. function xueliuFlowView:onEventXiaoJuViewShowed( )
  22. self:onBtnCloseClicked();
  23. end
  24. function xueliuFlowView:initViews ()
  25. self.ui.Items.Button_Close:registerClick(handler(self, self.onBtnCloseClicked));
  26. self.ui.Items.ScrollView_Detail:hideAllBar();
  27. self.ui.Items.Layout_1:setTouchEnabled(true);
  28. local color = self.data.totalScore >= 0 and cc.c3b(235,72,15) or cc.c3b(113,113,113);
  29. self.ui.Items.Text_Sum_Score:setString(self.data.totalScore > 0 and "+" .. self.data.totalScore or self.data.totalScore)
  30. self.ui.Items.Text_Sum_Score:setColor(color);
  31. end
  32. function xueliuFlowView:createItem(data)
  33. local ui = loadUI("mj_xueliu/res/ui_fangjian/mj_xueliu_flow_item.ui");
  34. ui.Items.ScrollView_ItemDetail:hideAllBar();
  35. ui.Items.Text_Detail:setString(data.title or "");
  36. ui.Items.Text_Score:setString(data.score or 0);
  37. local color = data.score >= 0 and cc.c3b(235,72,15) or cc.c3b(113,113,113);
  38. ui.Items.Text_Score:setColor(color);
  39. local mj = MJ:new(data.card, MJDefine.MJType.Out, MJDefine.MyViewId, self.desktopType);
  40. mj:setAnchorPoint(cc.p(0.5, 0.5));
  41. mj:setPositionY(25);
  42. mj:setScale(0.80);
  43. ui.Items.Layout_HuCard:addChild(mj);
  44. local nodes = {};
  45. for k, v in ipairs(data.seats) do
  46. if v and v ~= "" then
  47. local viewOrder = tonumber(v) + 1;
  48. local img = cc.ImageView:create();
  49. nodes[viewOrder] = img;
  50. end
  51. end
  52. local index = 0;
  53. for viewOrder, v in pairs(nodes) do
  54. index = index + 1;
  55. v:loadTexture(string.format("mj_xueliu/res/zy_fangjian/flow/xueliu_seat_%s.png", viewOrder));
  56. v:setPosition(cc.p((index - 1) * 30 - (table.nums(data.seats) - 1) * 30 / 2 + 15, 25));
  57. ui.Items.Layout_Seats:addChild(v);
  58. end
  59. return ui;
  60. end
  61. function xueliuFlowView:getDeFenType(defenType)
  62. local operateTypeName ={
  63. [0] = "",
  64. [0x01] = "自摸",
  65. [0x02] = "接炮",
  66. [0x03] = "暗杠",
  67. [0x04] = "直杠",
  68. [0x05] = "巴杠",
  69. [0x06] = "呼叫转移",
  70. [0x07] = "退还杠",
  71. [0x09] = '大叫',
  72. [0x10] = '花猪'
  73. }
  74. return operateTypeName[defenType] or "";
  75. end
  76. function xueliuFlowView:getPaiType( paiType )
  77. return MJDefine.MJGameHuStr[paiType] or "";
  78. end
  79. function xueliuFlowView:getSubPaiType(subPaiType)
  80. local subPaiTypeName = {
  81. [0] = "",
  82. [0x01] = "天胡",
  83. [0x02] = "地胡",
  84. }
  85. return subPaiTypeName[subPaiType] or "";
  86. end
  87. function xueliuFlowView:getbSubType(data)
  88. local str = ""
  89. if data.bIsJinGouDiao > 0 then
  90. str = str .. "金钩钩" .. " "
  91. end
  92. if data.bIsHaiDiLaoYue > 0 then
  93. str = str .. "海底捞月" .. " "
  94. end
  95. if data.bIsHaiDiPao > 0 then
  96. str = str .. "海底炮" .. " "
  97. end
  98. if data.bGangShangKaiHua > 0 then
  99. str = str .. "杠上开花" .. " "
  100. end
  101. if data.bGangShangPao > 0 then
  102. str = str .. "杠上炮" .. " "
  103. end
  104. if data.bQiangGangHu > 0 then
  105. str = str .. "抢杠胡" .. " "
  106. end
  107. if data.bMenQing > 0 then
  108. str = str .. "门清" .. " "
  109. end
  110. if data.bZhongZhang > 0 then
  111. str = str .. "中张" .. " "
  112. end
  113. return str
  114. end
  115. function xueliuFlowView:getItemTitle (itemData)
  116. local opType = self:getDeFenType(itemData.type) or "";
  117. local paiType = self:getPaiType(itemData.paiType) or "";
  118. local subPaiType = self:getSubPaiType(itemData.subPaiType) or "";
  119. local bSubType = self:getbSubType(itemData) or "";
  120. local genNum = tonumber(itemData.genShu) > 0 and string.format("%s根", itemData.genShu) or "";
  121. local gangType = tonumber(itemData.fanshu) > 0 and string.format("%s番", itemData.fanshu) or "";
  122. local str = ""
  123. if opType ~= "" then
  124. str = str..opType..' '
  125. end
  126. if paiType ~= "" then
  127. str = str..paiType..' '
  128. end
  129. if subPaiType ~= "" then
  130. str = str..subPaiType..' '
  131. end
  132. if bSubType ~= "" then
  133. str = str..bSubType..' '
  134. end
  135. if genNum ~= "" then
  136. str = str..genNum..' '
  137. end
  138. if gangType ~= "" then
  139. str = str..gangType..' '
  140. end
  141. return str;
  142. end
  143. function xueliuFlowView:initFlowView( data )
  144. local scrollView = self.ui.Items.ScrollView_Detail;
  145. -- scrollView:removeAllChildren();
  146. local result = {};
  147. --分数解析
  148. for k, v in ipairs(data) do
  149. local obj = {};
  150. obj.title = self:getItemTitle(v);
  151. obj.card = v.card or 0;
  152. obj.score = v.score;
  153. obj.seats = string.split(v.seat, ";");
  154. table.insert(result, obj);
  155. end
  156. for k, v in ipairs(result) do
  157. local ui = self:createItem(v);
  158. scrollView:addChild(ui);
  159. end
  160. local size = scrollView:getContentSize();
  161. size.height = 70 * table.nums(result);
  162. scrollView:setInnerContainerSize(size);
  163. end
  164. function xueliuFlowView:onBtnCloseClicked( )
  165. self:removeFromParent();
  166. self = nil;
  167. end
  168. return xueliuFlowView;