Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

273 строки
7.8 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 ZPMessage = ZPFramework.ZPImport("zp_base.luaScript.Protocol.ZPMessage")
  5. local ZPRoomOperationView = ZPFramework.ZPFrameworkClassImprot("zp_base.luaScript.Views.Room.ZPRoomOperationView")
  6. local hejiangRoomOperationView = class("hejiangRoomOperationView", ZPRoomOperationView)
  7. function hejiangRoomOperationView:ctor( ... )
  8. hejiangRoomOperationView.super.ctor(self)
  9. end
  10. function hejiangRoomOperationView:onEnter()
  11. hejiangRoomOperationView.super.onEnter(self)
  12. end
  13. function hejiangRoomOperationView:onEnter()
  14. ZPRoomOperationView.super.onEnter(self)
  15. local ui = loadUI("zp_hejiang/res/ui/ui_fangjian/hejiang_ui_operation.ui");
  16. self.ui = ui;
  17. self:addChild(ui);
  18. self.eatViewSrcSize = self.ui.Items.ImageView_EatPanelBg:getContentSize()
  19. self.eatBiViewSrcSize = self.ui.Items.ImageView_EatPanelBg_Bi:getContentSize()
  20. self.eatSanBiViewSrcSize = self.ui.Items.ImageView_EatPanelBg_SanBi:getContentSize()
  21. --ui排序:吃碰胡过
  22. self.ui.Items.Button_1:registerClick(nil,function ()
  23. local function chi()
  24. local code = self.operationLocalCode
  25. self:touchEatOneCardCallBack(false)
  26. end
  27. local isHu = self:getIsHaveHuOp()
  28. if isHu == true then
  29. local content = string.format("确定放弃胡牌吗?")
  30. local okCallBack = function ()
  31. chi()
  32. end
  33. local cancelCallBack = function ()
  34. end
  35. showConfirmDialog(content,okCallBack,cancelCallBack)
  36. else
  37. chi()
  38. end
  39. end)
  40. self.ui.Items.Button_2:registerClick(function ()
  41. local function peng()
  42. local operateCode = {}
  43. operateCode[1] = ZPDef.OpCode.OP_PENG
  44. self:sendOperationCode(operateCode)
  45. --直接隐藏界面
  46. self:setOperatorPanelView(false)
  47. end
  48. local isHu = self:getIsHaveHuOp()
  49. if isHu == true then
  50. local content = string.format("确定放弃胡牌吗?")
  51. local okCallBack = function ()
  52. peng()
  53. end
  54. local cancelCallBack = function ()
  55. end
  56. showConfirmDialog(content,okCallBack,cancelCallBack)
  57. else
  58. peng()
  59. end
  60. end)
  61. self.ui.Items.Button_7:registerClick(function ()
  62. local function peng()
  63. local operateCode = {}
  64. operateCode[1] = ZPDef.OpCode.OP_PAO
  65. self:sendOperationCode(operateCode)
  66. --直接隐藏界面
  67. self:setOperatorPanelView(false)
  68. end
  69. local isHu = self:getIsHaveHuOp()
  70. if isHu == true then
  71. local content = "确定放弃胡牌吗?"
  72. local okCallBack = function ()
  73. peng()
  74. end
  75. local cancelCallBack = function ()
  76. end
  77. showConfirmDialog(content,okCallBack,cancelCallBack)
  78. else
  79. peng()
  80. end
  81. end)
  82. --self:hidePengBtn()
  83. self.ui.Items.Button_3:registerClick(function ()
  84. if app.room:isLittleFamily() then return end
  85. local isHu = self:getIsHaveHuOp()
  86. if isHu == true then
  87. local content = "确定放弃胡牌吗?"
  88. local okCallBack = function ()
  89. self:onClickGuo()
  90. end
  91. local cancelCallBack = function ()
  92. end
  93. showConfirmDialog(content,okCallBack,cancelCallBack)
  94. else
  95. self:onClickGuo()
  96. end
  97. end)
  98. self.ui.Items.Button_4:registerClick(function ()
  99. local operateCode = {}
  100. operateCode[1] = ZPDef.OpCode.OP_HU
  101. self:sendOperationCode(operateCode)
  102. self:setOperatorPanelView(false)
  103. end)
  104. --不爆牌
  105. self.ui.Items.Button_6:registerClick(function ()
  106. if app.room:isLittleFamily() then return end
  107. local request = ZPMessage.BaoPai:new()
  108. request.optType = 0
  109. logE("ZPRoomOperationView:baopai"..table.tostring(request))
  110. self.ui:sendMsg(app.room, "BaoPai", request, function(status, response)
  111. logE("ZPRoomOperationView baopai response = ", table.tostring(response))
  112. end)
  113. self:showBaoPaiOpView(false)
  114. end)
  115. --爆牌
  116. self.ui.Items.Button_5:registerClick(function ()
  117. if app.room:isLittleFamily() then return end
  118. local request = ZPMessage.BaoPai:new()
  119. request.optType = 1
  120. logE("ZPRoomOperationView:baopai"..table.tostring(request))
  121. self.ui:sendMsg(app.room, "BaoPai", request, function(status, response)
  122. logE("ZPRoomOperationView baopai response = ", table.tostring(response))
  123. end)
  124. self:showBaoPaiOpView(false)
  125. end)
  126. self:hideSelf()
  127. end
  128. function hejiangRoomOperationView:showOpeation(mainOpCode,viewId,card)
  129. if app.room:isLittleFamily() then return end
  130. --操作码
  131. self.operationLocalCode = mainOpCode
  132. logE("RoomView:showOpeation(mainOpCode) 1:"..mainOpCode)
  133. --操作类型
  134. local beginList = {}
  135. beginList = ZPFuc.getZPOperationType(mainOpCode,true)--,self.playerZhao[1] > 0
  136. logE("RoomView:showOpeation isCheckMustOperation before (beginList)1 :"..table.tostring(beginList))
  137. --胡牌优先规则
  138. local isHu = false
  139. for k,opType in pairs(beginList) do
  140. if opType == ZPDef.OpType.OP_TYPE_HU then
  141. isHu = true
  142. break
  143. end
  144. end
  145. --发送操作
  146. if not isHu then
  147. --自动操作判断
  148. for k,opType in ipairs(beginList) do
  149. if opType == ZPDef.OpType.OP_TYPE_MINGWEI then
  150. local operateCode = {}
  151. operateCode[1] = ZPDef.OpCode.OP_MING_SHAO
  152. self:sendOperationCode(operateCode)
  153. --直接隐藏界面
  154. self:setOperatorPanelView(false)
  155. return
  156. elseif opType == ZPDef.OpType.OP_TYPE_ANWEI then
  157. local operateCode = {}
  158. operateCode[1] = ZPDef.OpCode.OP_AN_SHAO
  159. self:sendOperationCode(operateCode)
  160. --直接隐藏界面
  161. self:setOperatorPanelView(false)
  162. return
  163. elseif opType == ZPDef.OpType.OP_TYPE_PAO then
  164. local operateCode = {}
  165. operateCode[1] = ZPDef.OpCode.OP_PAO
  166. self:sendOperationCode(operateCode)
  167. --直接隐藏界面
  168. self:setOperatorPanelView(false)
  169. return
  170. elseif opType == ZPDef.OpType.OP_TYPE_CHONG_PAO then
  171. local operateCode = {}
  172. operateCode[1] = ZPDef.OpCode.OP_PAO
  173. self:sendOperationCode(operateCode)
  174. --直接隐藏界面
  175. self:setOperatorPanelView(false)
  176. return
  177. elseif opType == ZPDef.OpType.OP_TYPE_TI then
  178. local operateCode = {}
  179. operateCode[1] = ZPDef.OpCode.OP_TI
  180. self:sendOperationCode(operateCode)
  181. --直接隐藏界面
  182. self:setOperatorPanelView(false)
  183. return
  184. elseif opType == ZPDef.OpType.OP_TYPE_PENG then
  185. local operateCode = {}
  186. operateCode[1] = ZPDef.OpCode.OP_PENG
  187. self:sendOperationCode(operateCode)
  188. --直接隐藏界面
  189. self:setOperatorPanelView(false)
  190. return
  191. end
  192. end
  193. else
  194. --是否必须操作
  195. local isCheckMustOperation = false
  196. for k,v in pairs(beginList) do
  197. if v == ZPDef.OpType.OP_TYPE_PENG or v == ZPDef.OpType.OP_TYPE_MINGWEI or v == ZPDef.OpType.OP_TYPE_ANWEI
  198. or v == ZPDef.OpType.OP_TYPE_TI or v == ZPDef.OpType.OP_TYPE_PAO
  199. or v == ZPDef.OpType.OP_TYPE_CHONG_PAO then
  200. isCheckMustOperation = true
  201. break
  202. end
  203. end
  204. if isCheckMustOperation then
  205. --获取操作类型
  206. beginList = ZPFuc.getZPOperationType(mainOpCode,false)
  207. end
  208. --[[local operateCode = {}
  209. operateCode[1] = ZPDef.OpCode.OP_HU
  210. self:sendOperationCode(operateCode)
  211. return--]]
  212. --self:setHuPanelView(true,beginList)
  213. --return
  214. end
  215. --如果没有胡,扫,提,跑,等自动操作,则显示吃碰过操作
  216. self:setOperatorPanelView(true,beginList)
  217. end
  218. --隐藏行为操作层
  219. function hejiangRoomOperationView:setOperatorPanelView(bVisible,operations)
  220. self:setVisible(bVisible)
  221. self.ui.Items.Layout_operatorPanel:setVisible(bVisible)
  222. --置灰所有 ui排序:吃碰过
  223. for i = 1 ,7 do
  224. local name = string.format("Layout_%d",i)
  225. if self.ui.Items[name] then
  226. self.ui.Items[name]:setVisible(false)
  227. end
  228. end
  229. --显示操作序列
  230. if operations then
  231. for k,v in pairs(operations) do
  232. local name = string.format("Button_%d",v)
  233. local layout = string.format("Layout_%d",v)
  234. if self.ui.Items[name] then
  235. self.ui.Items[name]:setEnabled(true)
  236. self.ui.Items[layout]:setVisible(true)
  237. end
  238. end
  239. end
  240. self.ui.Items.Layout_operatorPanel:requestDoLayout();
  241. self.ui.Items.Layout_operatorPanel:doLayout();
  242. end
  243. return hejiangRoomOperationView