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.

240 lines
7.6 KiB

  1. local ZPDef = ZPFramework.ZPImport("zp_base.luaScript.ZPDef")
  2. local ZPFuc = ZPFramework.ZPImport("zp_base.luaScript.ZPFunctions")
  3. local ZPSound = ZPFramework.ZPImport("zp_base.luaScript.ZPSound")
  4. local ZPRoomCard=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomCard")
  5. local ZPRoomXiaoJuChaPaiView = ZPFramework.ZPFrameworkClassImprot("zp_base.luaScript.Views.Room.ZPRoomXiaoJuChaPaiView")
  6. local luzhouRoomXiaoJuChaPaiView = class("luzhouRoomXiaoJuChaPaiView", ZPRoomXiaoJuChaPaiView)
  7. function luzhouRoomXiaoJuChaPaiView:ctor()
  8. luzhouRoomXiaoJuChaPaiView.super.ctor(self)
  9. end
  10. function luzhouRoomXiaoJuChaPaiView:onEnter()
  11. luzhouRoomXiaoJuChaPaiView.super.onEnter(self)
  12. end
  13. function luzhouRoomXiaoJuChaPaiView:liangShouPai(isRecontect)
  14. --胡牌类型
  15. local huType = ZPDef.ReconnectHuType.NO_HU
  16. --房间信息
  17. local roomInfo = app.room.roomInfo
  18. --正常结束取值
  19. local tt = roomInfo.playList
  20. --重连取值
  21. if isRecontect then
  22. tt = roomInfo.arrayTableInfo
  23. end
  24. if (roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_NORMAL) then
  25. --胡的牌
  26. local huCard = roomInfo.huCard
  27. --出牌者ID或者点炮的ID,自摸这个是nil,有人点炮这个是有值的
  28. local showViewId = nil
  29. local dianPaoViewId = app.room:getViewIdByUserId(roomInfo.dianPaoUserId)
  30. --重连
  31. if isRecontect then
  32. showViewId = app.room:getViewIdBySeatId(roomInfo.showCardSeatId)
  33. else
  34. --小局结算
  35. showViewId = dianPaoViewId
  36. end
  37. for k,huinfo in pairs(roomInfo.hupaiInfo) do
  38. huCard = huinfo.huCard
  39. local nUserId = huinfo.huPaiUid
  40. local viewId = app.room:getViewIdByUserId(nUserId)
  41. --显示胡的那个牌
  42. if isRecontect then
  43. if self.showHuCardCallBack then
  44. self.showHuCardCallBack(showViewId,huCard)
  45. end
  46. end
  47. --赢家手牌
  48. local cardList = {}
  49. cardList = roomInfo.memberList[nUserId].cardList
  50. --判断赢家是否吃胡
  51. local isHandHaveHuCard = false
  52. local isFindChi = false
  53. for key,list in pairs(cardList) do
  54. for i = 1,3 do
  55. if list[i] == huCard then
  56. isHandHaveHuCard = true
  57. isFindChi = true
  58. break
  59. end
  60. end
  61. if isFindChi then
  62. break
  63. end
  64. end
  65. --是否是跑胡或提胡
  66. local paoTiHU = false
  67. --如果是吃胡
  68. if isHandHaveHuCard then
  69. huType = ZPDef.ReconnectHuType.CHI_HU
  70. --吃胡操作,去掉手里胡的那张
  71. local isFind = false
  72. if table.nums(cardList) > 0 then
  73. for i = 1,self.lieShuMax do
  74. local cardColList = cardList[i] or {}
  75. for idx,value in pairs(cardColList) do
  76. if value == huCard then
  77. table.remove(cardColList,idx)
  78. isFind = true
  79. break
  80. end
  81. end
  82. if isFind then
  83. break
  84. end
  85. end
  86. end
  87. else
  88. for k,v in pairs(tt) do
  89. if k == nUserId then
  90. for key,value in pairs(v.tableWeaveCard) do
  91. local list,operationType = ZPFuc.getZPCardList(value.card,value.type)
  92. if operationType == ZPDef.OpType.OP_TYPE_MINGWEI and huCard == value.card
  93. or operationType == ZPDef.OpType.OP_TYPE_ANWEI and huCard == value.card then
  94. huType = ZPDef.ReconnectHuType.WEI_HU
  95. elseif operationType == ZPDef.OpType.OP_TYPE_PENG and huCard == value.card then
  96. huType = ZPDef.ReconnectHuType.PENG_HU
  97. elseif operationType == ZPDef.OpType.OP_TYPE_PAO and huCard == value.card then
  98. if value.type == ZPDef.SendCardType.CHI_PAI_SHAO_PAO then --x
  99. huType = ZPDef.ReconnectHuType.WEI_PAO_HU
  100. elseif value.type == ZPDef.SendCardType.CHI_PAI_PENG_PAO then
  101. huType = ZPDef.ReconnectHuType.PENG_PAO_HU
  102. elseif value.type == ZPDef.SendCardType.KUAI_SHUI_FOUR_SAME then
  103. huType = ZPDef.ReconnectHuType.KAN_PAO_HU
  104. end
  105. paoTiHU = true
  106. elseif operationType == ZPDef.OpType.OP_TYPE_TI and huCard == value.card then
  107. if value.type == ZPDef.SendCardType.CHI_PAI_TI then
  108. huType = ZPDef.ReconnectHuType.WEI_TI_HU
  109. elseif value.type == ZPDef.SendCardType.GUN_ZI_FOUR_SAME then
  110. huType = ZPDef.ReconnectHuType.KAN_TI_HU
  111. end
  112. paoTiHU = true
  113. elseif operationType == ZPDef.OpType.OP_TYPE_CHONG_PAO and huCard == value.card then
  114. paoTiHU = true
  115. end
  116. end
  117. end
  118. end
  119. end
  120. --添加2个牌
  121. if huType == ZPDef.ReconnectHuType.WEI_HU or huType == ZPDef.ReconnectHuType.PENG_HU then
  122. local tt = {huCard,huCard}
  123. table.insert(cardList,tt)
  124. elseif huType == ZPDef.ReconnectHuType.KAN_TI_HU or huType == ZPDef.ReconnectHuType.KAN_PAO_HU
  125. or (true == paoTiHU) then
  126. local tt = {huCard,huCard,huCard}
  127. table.insert(cardList,tt)
  128. end
  129. end
  130. end
  131. if roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_HUANG_ZHUANG and not isRecontect then
  132. --胡的牌
  133. local huCard = roomInfo.huCard
  134. --出牌者ID或者点炮的ID,自摸这个是nil,有人点炮这个是有值的
  135. local showViewId = nil
  136. local dianPaoViewId = app.room:getViewIdByUserId(roomInfo.dianPaoUserId)
  137. --重连
  138. if isRecontect then
  139. showViewId = app.room:getViewIdBySeatId(roomInfo.showCardSeatId)
  140. else
  141. --小局结算
  142. showViewId = dianPaoViewId
  143. end
  144. for k,huinfo in pairs(roomInfo.hupaiInfo) do
  145. huCard = huinfo.huCard
  146. local nUserId = huinfo.huPaiUid
  147. local viewId = app.room:getViewIdByUserId(nUserId)
  148. --显示胡的那个牌
  149. if isRecontect then
  150. if self.showHuCardCallBack then
  151. self.showHuCardCallBack(showViewId,huCard)
  152. end
  153. end
  154. --赢家手牌
  155. local cardList = {}
  156. cardList = roomInfo.memberList[nUserId].cardList
  157. --桌面组合牌数量
  158. local weaveCardNum = roomInfo.memberList[nUserId].weaveCardNum or 0
  159. local paoTiHU = false
  160. for k,v in pairs(tt) do
  161. if k == nUserId then
  162. if v.tableWeaveCard and #v.tableWeaveCard > 0 then
  163. local lastWeaveCard = v.tableWeaveCard[#v.tableWeaveCard]
  164. if (lastWeaveCard.type == ZPDef.SendCardType.KAN_THREE_SAME or lastWeaveCard.type == ZPDef.SendCardType.DIRTY_THREE_SAME
  165. or lastWeaveCard.type == ZPDef.SendCardType.DUI_THREE_SAME) and huCard == lastWeaveCard.card and (weaveCardNum+#cardList<7) then
  166. local tcardlst = {huCard,huCard,huCard}
  167. table.insert(cardList,tcardlst)
  168. elseif (lastWeaveCard.type == ZPDef.SendCardType.GUN_ZI_FOUR_SAME or lastWeaveCard.type == ZPDef.SendCardType.KUAI_SHUI_FOUR_SAME
  169. or lastWeaveCard.type == ZPDef.SendCardType.CHI_PAI_TI or lastWeaveCard.type == ZPDef.SendCardType.CHI_PAI_SHAO_PAO
  170. or lastWeaveCard.type == ZPDef.SendCardType.CHI_PAI_PENG_PAO) and huCard == lastWeaveCard.card then
  171. local tcardlst = {huCard,huCard,huCard,huCard}
  172. table.insert(cardList,tcardlst)
  173. end
  174. end
  175. end
  176. end
  177. end
  178. end
  179. if roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_HUANG_ZHUANG then
  180. for k,huinfo in pairs(roomInfo.hupaiInfo) do
  181. local huCard = huinfo.huCard
  182. local nUserId = huinfo.huPaiUid
  183. local cardList = roomInfo.memberList[nUserId].cardList
  184. if cardList and #cardList > 0 then
  185. local isfindJiaoPai = false
  186. for i=#cardList,1,-1 do
  187. local cardLie = cardList[i]
  188. for j=1,4 do
  189. if cardLie[j] and cardLie[j] == huCard then
  190. cardLie.jiaopaiIdx = j
  191. isfindJiaoPai = true
  192. break
  193. end
  194. end
  195. if isfindJiaoPai then
  196. break
  197. end
  198. end
  199. end
  200. end
  201. end
  202. for k,v in pairsByKeys(tt) do
  203. local myUserID = app.room:getMyUserId()
  204. local nUserId = v.nUserId
  205. if myUserID ~= nUserId then
  206. local cardList = roomInfo.memberList[nUserId].cardList
  207. logE("cardList:"..table.tostring(cardList))
  208. self:createHandCard(nUserId)
  209. end
  210. end
  211. app.room.roomInfo.huCardType = huType
  212. return huType
  213. end
  214. return luzhouRoomXiaoJuChaPaiView