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.

238 lines
7.4 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 hejiangRoomXiaoJuChaPaiView = class("hejiangRoomXiaoJuChaPaiView", ZPRoomXiaoJuChaPaiView)
  7. function hejiangRoomXiaoJuChaPaiView:ctor()
  8. hejiangRoomXiaoJuChaPaiView.super.ctor(self)
  9. end
  10. function hejiangRoomXiaoJuChaPaiView:onEnter()
  11. hejiangRoomXiaoJuChaPaiView.super.onEnter(self)
  12. end
  13. function hejiangRoomXiaoJuChaPaiView: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. local paoTiHU = false
  158. for k,v in pairs(tt) do
  159. if k == nUserId then
  160. if v.tableWeaveCard and #v.tableWeaveCard > 0 then
  161. local lastWeaveCard = v.tableWeaveCard[#v.tableWeaveCard]
  162. if (lastWeaveCard.type == ZPDef.SendCardType.KAN_THREE_SAME or lastWeaveCard.type == ZPDef.SendCardType.DIRTY_THREE_SAME
  163. or lastWeaveCard.type == ZPDef.SendCardType.DUI_THREE_SAME) and huCard == lastWeaveCard.card then
  164. local tcardlst = {huCard,huCard,huCard}
  165. table.insert(cardList,tcardlst)
  166. elseif (lastWeaveCard.type == ZPDef.SendCardType.GUN_ZI_FOUR_SAME or lastWeaveCard.type == ZPDef.SendCardType.KUAI_SHUI_FOUR_SAME
  167. or lastWeaveCard.type == ZPDef.SendCardType.CHI_PAI_TI or lastWeaveCard.type == ZPDef.SendCardType.CHI_PAI_SHAO_PAO
  168. or lastWeaveCard.type == ZPDef.SendCardType.CHI_PAI_PENG_PAO) and huCard == lastWeaveCard.card then
  169. local tcardlst = {huCard,huCard,huCard,huCard}
  170. table.insert(cardList,tcardlst)
  171. end
  172. end
  173. end
  174. end
  175. end
  176. end
  177. if roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_HUANG_ZHUANG then
  178. for k,huinfo in pairs(roomInfo.hupaiInfo) do
  179. local huCard = huinfo.huCard
  180. local nUserId = huinfo.huPaiUid
  181. local cardList = roomInfo.memberList[nUserId].cardList
  182. if cardList and #cardList > 0 then
  183. local isfindJiaoPai = false
  184. for i=#cardList,1,-1 do
  185. local cardLie = cardList[i]
  186. for j=1,4 do
  187. if cardLie[j] and cardLie[j] == huCard then
  188. cardLie.jiaopaiIdx = j
  189. isfindJiaoPai = true
  190. break
  191. end
  192. end
  193. if isfindJiaoPai then
  194. break
  195. end
  196. end
  197. end
  198. end
  199. end
  200. for k,v in pairsByKeys(tt) do
  201. local myUserID = app.room:getMyUserId()
  202. local nUserId = v.nUserId
  203. if myUserID ~= nUserId then
  204. local cardList = roomInfo.memberList[nUserId].cardList
  205. logE("cardList:"..table.tostring(cardList))
  206. self:createHandCard(nUserId)
  207. end
  208. end
  209. app.room.roomInfo.huCardType = huType
  210. return huType
  211. end
  212. return hejiangRoomXiaoJuChaPaiView