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.

839 lines
25 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 ZPWanFa=ZPFramework.ImportWanFa("luaScript.SubGameDefine.ZiPai.ZPWanFa")
  5. local changpaiRoomXiaoJuView = class("changpaiRoomXiaoJuView", cc.UIView)
  6. local tempCardVlue ={
  7. [17] = 20, --11
  8. [18] = 30, --12
  9. [49] = 40, --31
  10. [34] = 41, --22
  11. [20] = 50, --14
  12. [50] = 51, --32
  13. [21] = 60, --15
  14. [36] = 61, --24
  15. [51] = 62, --33
  16. [22] = 70, --16
  17. [82] = 71, --52
  18. [52] = 72, --34
  19. [38] = 80, --26
  20. [53] = 81, --35
  21. [68] = 82, --44
  22. [54] = 90, --36
  23. [84] = 91, --54
  24. [70] = 100, --46
  25. [85] = 101, --55
  26. [86] = 110, --56
  27. [102] = 120, --66
  28. }
  29. function changpaiRoomXiaoJuView:ctor(nextCallBackFun,isRecontect,colorType)
  30. changpaiRoomXiaoJuView.super.ctor(self);
  31. self.isRecontect = isRecontect
  32. self.nextCallBack = nextCallBackFun
  33. self.xiaojuData = app.room.roomInfo.playList
  34. self.isShow = false
  35. if self.isRecontect then
  36. self.xiaojuData = app.room.roomInfo.arrayTableInfo
  37. end
  38. self.allNode = {}
  39. self.showHu = {}
  40. self.colorType = colorType or ZPDef.ColorType.White
  41. end
  42. function changpaiRoomXiaoJuView:loadUI()
  43. local ui = loadUI("zp_changpai/res/ui/ui_fangjian/changpai_ui_xiaoju.ui");
  44. self.ui = ui;
  45. self:addChild(ui);
  46. end
  47. function changpaiRoomXiaoJuView:onEnter()
  48. changpaiRoomXiaoJuView.super.onEnter(self)
  49. self:loadUI()
  50. -- 下一局
  51. self.ui.Items.Button_Next:registerClick(handler(self , self.onClickNext))
  52. --显示总结算
  53. self.ui.Items.Button_All:registerClick(handler(self , self.onClickZongJieSuan))
  54. --查牌
  55. self.ui.Items.Button_ChaPai:registerClick(handler(self , self.onClickChaPai))
  56. --胡牌类型item,复制用
  57. self.ui.Items.Layout_hutypes:setVisible(false)
  58. --显示结束
  59. if app.room.roomInfo.isGameOver == 1 then
  60. self.ui.Items.Button_Next:setVisible(false)
  61. self.ui.Items.Button_All:setVisible(true)
  62. else
  63. self.ui.Items.Button_All:setVisible(false)
  64. end
  65. self.ui.Items.ImageView_DiCard_1:setVisible(false)
  66. --组合牌第一个点的坐标
  67. self.weaveCardPos = cc.p(180,45)
  68. self.leftCardPos = self.ui.Items.ImageView_DiCard_1:getPosition()
  69. --初始化人物信息
  70. self:initPlayerView()
  71. self:initOtherData()
  72. self:updatePlayerInfo()
  73. end
  74. function changpaiRoomXiaoJuView:initPlayerView()
  75. self.ui.Items.Layout_WeaveCard_Item:setVisible(false)
  76. for i=1,4 do
  77. local head = "ImageView_head_"..i
  78. local headBg = "ImageView_head_bg_" .. i
  79. local name = "Text_Name_"..i
  80. local id = "Text_ID_"..i
  81. local banker = "ImageView_Zhuang_"..i
  82. local winScore = "TextBMFont_WinScore_"..i
  83. local loseScore = "TextBMFont_LoseScore_"..i
  84. local layout = "Layout_Hand_"..i
  85. local winBg = "ImageView_ying_bg_"..i
  86. --local loseBg = "ImageView_pt_bg_"..i
  87. local layoutHuinfo = "Layout_HuInfo_"..i
  88. local fangPao = "ImageView_FangPao_"..i
  89. local layoutHuTypes = "Layout_huTypes_"..i
  90. local huType = "ImageView_HuType_"..i
  91. local textHuInfo = "Text_Hu_Info_"..i
  92. local textHushu = "Text_hushu_"..i
  93. local textBeishu = "Text_beishu_"..i
  94. local textFanshu = "Text_fanshu_"..i
  95. local textFanxing = "Text_fanxing_"..i
  96. local textTuoNum = "Text_TuoNum_"..i
  97. local toujia = "ImageView_toujia_"..i
  98. local baojiao = "ImageView_baojiao_"..i
  99. local xiaojia = "ImageView_xiaojia_"..i
  100. local fengding = "ImageView_fengding_"..i
  101. self.allNode[i] = {}
  102. self.allNode[i].nodeHead = self.ui.Items[head]
  103. self.allNode[i].nodeHeadBg = self.ui.Items[headBg]
  104. self.allNode[i].nodeName = self.ui.Items[name]
  105. self.allNode[i].nodeID = self.ui.Items[id]
  106. self.allNode[i].nodeBanker = self.ui.Items[banker]
  107. self.allNode[i].nodewinScore = self.ui.Items[winScore]
  108. self.allNode[i].nodeloseScore = self.ui.Items[loseScore]
  109. self.allNode[i].nodeLayout = self.ui.Items[layout]
  110. self.allNode[i].nodewinBg = self.ui.Items[winBg]
  111. --self.allNode[i].nodeloseBg = self.ui.Items[loseBg]
  112. self.allNode[i].nodelayoutHuinfo = self.ui.Items[layoutHuinfo]
  113. self.allNode[i].nodefangPao = self.ui.Items[fangPao]
  114. self.allNode[i].nodehutype = self.ui.Items[huType]
  115. self.allNode[i].nodelayoutHuTypes = self.ui.Items[layoutHuTypes]
  116. self.allNode[i].nodehuinfo = self.ui.Items[textHuInfo]
  117. self.allNode[i].nodeHushu = self.ui.Items[textHushu]
  118. self.allNode[i].nodeBeishu = self.ui.Items[textBeishu]
  119. self.allNode[i].nodefanshu = self.ui.Items[textFanshu]
  120. self.allNode[i].nodefanxing = self.ui.Items[textFanxing]
  121. self.allNode[i].nodeTuoNum = self.ui.Items[textTuoNum]
  122. self.allNode[i].nodetoujia = self.ui.Items[toujia]
  123. self.allNode[i].nodebaojiao = self.ui.Items[baojiao]
  124. self.allNode[i].nodexiaojia = self.ui.Items[xiaojia]
  125. self.allNode[i].nodefengding = self.ui.Items[fengding]
  126. self.ui.Items["Layout_Player_" .. i]:setVisible(false)
  127. end
  128. end
  129. --是否是小家uid
  130. function changpaiRoomXiaoJuView:isLittleUid(uid)
  131. if not uid then return false end
  132. if uid == 0 then return true end
  133. local viewId = app.room:getViewIdByUserId(uid)
  134. if not viewId then return false end
  135. local seatId = app.room:getSeatIdByViewId(viewId)
  136. if not seatId then return false end
  137. if app.room.roomInfo.xiaoSeatId and app.room.roomInfo.xiaoSeatId == seatId then
  138. return true
  139. else
  140. return false
  141. end
  142. end
  143. --获取最大得分
  144. function changpaiRoomXiaoJuView:getMaxTurnScore(t)
  145. local score = 0
  146. for i,j in pairs(t) do
  147. if j.nTurnScore > score then
  148. score = j.nTurnScore
  149. end
  150. end
  151. return score
  152. end
  153. function changpaiRoomXiaoJuView:updatePlayerInfo()
  154. self.isHaveUse = {}
  155. local indexPlayer = 2
  156. local maxTurnScore = self:getMaxTurnScore(self.xiaojuData)
  157. --按要求赢家要摆在第一个位置
  158. for k,v in pairsByKeys(self.xiaojuData) do
  159. local i = indexPlayer
  160. if v.nTurnScore == maxTurnScore and not self.isHaveUse[1] and (not self:isLittleUid(v.nUserId)) then
  161. i = 1
  162. elseif self:isLittleUid(v.nUserId) then
  163. i = 4
  164. else
  165. indexPlayer = indexPlayer + 1
  166. end
  167. if i== 4 and (not self:isLittleUid(v.nUserId)) then
  168. for tt=1,4 do
  169. if not self.isHaveUse[tt] then
  170. i = tt
  171. end
  172. end
  173. self.isHaveUse[i] = true
  174. elseif not self.isHaveUse[i] then
  175. self.isHaveUse[i] = true
  176. else
  177. for tt=1,4 do
  178. if not self.isHaveUse[tt] then
  179. i = tt
  180. end
  181. end
  182. self.isHaveUse[i] = true
  183. end
  184. self.ui.Items["Layout_Player_" .. i]:setVisible(true)
  185. local roomInfo = app.room.roomInfo
  186. local userInfo = app.room:getUserInfo(v.nUserId)
  187. local viewId = app.room:getViewIdByUserId(v.nUserId)
  188. local nWinerId = app.room.roomInfo.winUserId
  189. local dianPaoUserId = app.room.roomInfo.dianPaoUserId
  190. local baopeiUserId = app.room.roomInfo.baopeiUserid
  191. local bankerId = app.room:getUserIdBySeatId(app.room.roomInfo.nBankSeatId)
  192. local stopFlag = app.room.roomInfo.stopFlag
  193. local xiaojiaid = self:getXiaojiaUid()
  194. self.allNode[i].nodefangPao:setScale(1.5)
  195. if stopFlag ~= 0 then
  196. self.allNode[i].nodefanshu:setVisible(false)
  197. self.allNode[i].nodelayoutHuTypes:setVisible(false)
  198. self.allNode[i].nodefanxing:setVisible(false)
  199. self.allNode[i].nodeTuoNum:setVisible(false)
  200. self.allNode[i].nodefengding:setVisible(false)
  201. end
  202. if v.nTurnScore > 0 then
  203. self.allNode[i].nodewinScore:setText(tostring("+"..v.nTurnScore))
  204. self.allNode[i].nodeloseScore:setVisible(false)
  205. else
  206. self.allNode[i].nodeloseScore:setText(v.nTurnScore)
  207. self.allNode[i].nodewinScore:setVisible(false)
  208. self.allNode[i].nodewinBg:setVisible(false)
  209. end
  210. self.allNode[i].nodelayoutHuinfo:setVisible(false)
  211. self.allNode[i].nodehutype:setVisible(false)
  212. --先设置默认头像
  213. local width = self.allNode[i].nodeHead:getContentSize().width
  214. if v.nUserId == 0 then
  215. self.allNode[i].nodeName:setVisible(false)
  216. self.allNode[i].nodeID:setVisible(false)
  217. self.allNode[i].nodeHeadBg:setVisible(false)
  218. self.allNode[i].nodewinScore:setVisible(false)
  219. self.allNode[i].nodeloseScore:setVisible(false)
  220. else
  221. local nickname = ""
  222. if userInfo and userInfo.nickname then
  223. nickname = getSubStringNickname(userInfo.nickname)
  224. self:updateUserHead(self.allNode[i].nodeHead,v.nUserId, userInfo.sex, userInfo.headimgurl);
  225. end
  226. --名称
  227. self.allNode[i].nodeName:setText(nickname)
  228. --ID
  229. self.allNode[i].nodeID:setText(tostring("ID:"..v.nUserId))
  230. end
  231. --显示隐藏游戏内选手id(主办人和管理员不限制,只针对海选赛) -- todo lwq
  232. -- begin
  233. local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
  234. if app.club_php.clubID and app.club_php.clubID ~= 0 then
  235. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  236. --隐私数据
  237. local clubInfo = app.club_php.clubList[app.club_php.clubID]
  238. self.cliext = clubInfo.groupext and clubInfo.groupext.cliext
  239. if not self.cliext or not self.cliext.is_hideUid or (self.cliext and self.cliext.is_hideUid == 1) then
  240. if clubInfo.role == ClubDefine.Job.Creator or clubInfo.role == ClubDefine.Job.Manager then
  241. self.allNode[i].nodeID:setVisible(true)
  242. else
  243. self.allNode[i].nodeID:setVisible(false)
  244. end
  245. end
  246. end
  247. end
  248. if v.nUserId == tonumber(app.user.loginInfo.uid) then
  249. self.allNode[i].nodeID:setVisible(true)
  250. end
  251. -- end
  252. --庄家
  253. if bankerId == v.nUserId then
  254. self.allNode[i].nodeBanker:setVisible(false)
  255. self.allNode[i].nodetoujia:setVisible(true)
  256. else
  257. self.allNode[i].nodeBanker:setVisible(false)
  258. self.allNode[i].nodetoujia:setVisible(false)
  259. end
  260. --小家
  261. if xiaojiaid == v.nUserId then
  262. self.allNode[i].nodexiaojia:setVisible(true)
  263. else
  264. self.allNode[i].nodexiaojia:setVisible(false)
  265. end
  266. --报叫
  267. if v.nBaoPaiStatus == 2 then
  268. self.allNode[i].nodebaojiao:setVisible(true)
  269. else
  270. self.allNode[i].nodebaojiao:setVisible(false)
  271. end
  272. --点炮 包赔玩家
  273. if dianPaoUserId == v.nUserId or baopeiUserId == v.nUserId then
  274. if dianPaoUserId == v.nUserId then
  275. self.allNode[i].nodefangPao:setVisible(true)
  276. --更换显示方式
  277. --local ui = self:getAHutypeUi("zp_changpai/res/ui/zy_fangjian/jiesuan/dianpao.png")
  278. self.allNode[i].nodefangPao:loadTexture("zp_changpai/res/ui/zy_fangjian/jiesuan/dianpao.png")
  279. self.allNode[i].nodefangPao:setScale(1.3)
  280. local orderPos = self.allNode[i].nodefangPao:getPosition()
  281. self.allNode[i].nodefangPao:setPositionY(orderPos.y - 10)
  282. elseif baopeiUserId == v.nUserId then
  283. self.allNode[i].nodefangPao:setVisible(true)
  284. --更换显示方式
  285. ---local ui = self:getAHutypeUi("zp_changpai/res/ui/zy_fangjian/jiesuan/baopei.png")
  286. self.allNode[i].nodefangPao:loadTexture("zp_changpai/res/ui/zy_fangjian/jiesuan/baopei.png")
  287. self.allNode[i].nodefangPao:setScale(1.3)
  288. local orderPos = self.allNode[i].nodefangPao:getPosition()
  289. self.allNode[i].nodefangPao:setPositionY(orderPos.y - 10)
  290. end
  291. else
  292. self.allNode[i].nodefangPao:setVisible(false)
  293. end
  294. --组合牌展示
  295. local data = self.xiaojuData[v.nUserId]
  296. if not data then
  297. return
  298. end
  299. local isHuUid = false--是否是赢牌者uid
  300. for huk,huv in pairs(roomInfo.hupaiInfo) do
  301. if huv.huPaiUid == v.nUserId then
  302. isHuUid = true
  303. app.room.roomInfo.huCard = huv.huCard
  304. self.allNode[i].nodefangPao:setVisible(true)
  305. self.allNode[i].nodelayoutHuinfo:setVisible(false)
  306. self.allNode[i].nodefangPao:loadTexture("zp_changpai/res/ui/zy_fangjian/jiesuan/hu.png")
  307. end
  308. if huv.huPaiUid == v.nUserId then
  309. self.allNode[i].nodefanshu:setVisible(true)
  310. self.allNode[i].nodefanshu:setText(huv.huPaiHuShu.."番")
  311. local hustr = self:getHuTypesStr(huv.huPaiUid,huv.huTypes)
  312. self.allNode[i].nodelayoutHuTypes:setVisible(true)
  313. self.allNode[i].nodefanxing:setVisible(true)
  314. self.allNode[i].nodefanxing:setText(tostring(hustr))
  315. self.allNode[i].nodeTuoNum:setVisible(true)
  316. self.allNode[i].nodeTuoNum:setText(v.totalTuoNum.."坨")
  317. else
  318. self.allNode[i].nodefanshu:setVisible(false)
  319. self.allNode[i].nodelayoutHuTypes:setVisible(false)
  320. self.allNode[i].nodefanxing:setVisible(false)
  321. self.allNode[i].nodeTuoNum:setVisible(false)
  322. end
  323. if huv.huPaiUid == v.nUserId and self:IsFengDing(huv.huTypes) then
  324. self.allNode[i].nodefengding:setVisible(true)
  325. else
  326. self.allNode[i].nodefengding:setVisible(false)
  327. end
  328. end
  329. if v.nTurnScore < 0 and v.nBaoPaiStatus == 2 then
  330. self.allNode[i].nodelayoutHuTypes:setVisible(true)
  331. self.allNode[i].nodefanxing:setVisible(true)
  332. self.allNode[i].nodefanxing:setText(tostring("被杀报"))
  333. end
  334. local index = 0
  335. for key,value in pairs(data.tableWeaveCard) do
  336. local list = {}
  337. local card = value.opcard
  338. local optype = value.type
  339. if optype == ZPDef.SendCardType.TOU_THREE_SAME or optype == ZPDef.SendCardType.CHI_PAI_PENG then
  340. list = {card,card,card}
  341. elseif optype == ZPDef.SendCardType.BA_FOUR_SAME then
  342. list = {card,card,card,card}
  343. elseif optype == ZPDef.SendCardType.TWO_SUM_CHI then
  344. list = value.card
  345. end
  346. if list then
  347. self:createWeaveCard(value,list,index,false,self.allNode[i].nodeLayout,v.nUserId)
  348. end
  349. index = index + 1
  350. end
  351. if table.nums(data.tableWeaveCard) > 0 then
  352. index = index + 1
  353. end
  354. local handcardList = {}
  355. for k,value in pairs(data.handCard) do
  356. local card = value.opcard
  357. local list = value.card
  358. if list then
  359. table.insert(handcardList,list)
  360. end
  361. end
  362. table.sort(handcardList,function(a,b)
  363. local index = a[1]
  364. local numA = tempCardVlue[index]
  365. local index1 = b[1]
  366. local numB = tempCardVlue[index1]
  367. if numA ~= nil and numB ~= nil then
  368. return numA < numB
  369. end
  370. end)
  371. --只显示一次胡变为opCard
  372. local showOneTime = true
  373. for k,value in pairs(handcardList) do
  374. local list = value
  375. if list then
  376. local lens = table.nums(list)
  377. if lens > 4 and lens <= 8 then
  378. local templist = {}
  379. for i = 5,lens do
  380. table.insert(templist,list[i])
  381. end
  382. self:createWeaveCard(value,list,index,true,self.allNode[i].nodeLayout,v.nUserId)
  383. index = index + 1
  384. self:createWeaveCard(value,templist,index,true,self.allNode[i].nodeLayout,v.nUserId)
  385. index = index + 1
  386. elseif lens > 8 and lens <= 12 then
  387. local templist = {}
  388. local templist1 = {}
  389. for i = 5,8 do
  390. table.insert(templist,list[i])
  391. end
  392. for i = 9,12 do
  393. table.insert(templist1,list[i])
  394. end
  395. self:createWeaveCard(value,list,index,true,self.allNode[i].nodeLayout,v.nUserId)
  396. index = index + 1
  397. self:createWeaveCard(value,templist,index,true,self.allNode[i].nodeLayout,v.nUserId)
  398. index = index + 1
  399. self:createWeaveCard(value,templist1,index,true,self.allNode[i].nodeLayout,v.nUserId)
  400. index = index + 1
  401. elseif lens > 12 and lens <= 16 then
  402. local templist = {}
  403. local templist1 = {}
  404. local templist2 = {}
  405. for i = 5,8 do
  406. table.insert(templist,list[i])
  407. end
  408. for i = 9,12 do
  409. table.insert(templist1,list[i])
  410. end
  411. for i = 13,16 do
  412. table.insert(templist2,list[i])
  413. end
  414. self:createWeaveCard(value,list,index,true,self.allNode[i].nodeLayout,v.nUserId)
  415. index = index + 1
  416. self:createWeaveCard(value,templist,index,true,self.allNode[i].nodeLayout,v.nUserId)
  417. index = index + 1
  418. self:createWeaveCard(value,templist1,index,true,self.allNode[i].nodeLayout,v.nUserId)
  419. index = index + 1
  420. self:createWeaveCard(value,templist2,index,true,self.allNode[i].nodeLayout,v.nUserId)
  421. index = index + 1
  422. else
  423. self:createWeaveCard(value,list,index,true,self.allNode[i].nodeLayout,v.nUserId)
  424. index = index + 1
  425. end
  426. end
  427. end
  428. --本局结束
  429. if app.room.roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_NORMAL then
  430. if #roomInfo.hupaiInfo > 0 then
  431. if v.nTurnScore > 0 then
  432. if v.nUserId == app.user.loginInfo.uid then
  433. ZPSound.PlayWinGame()
  434. end
  435. else
  436. if v.nUserId == app.user.loginInfo.uid then
  437. ZPSound.PlayLoseGame()
  438. end
  439. end
  440. end
  441. end
  442. --indexPlayer = indexPlayer + 1
  443. if isHuUid and true == isHuUid then
  444. self:showHuCardBox(self.allNode[i].nodeLayout,app.room.roomInfo.huCard)
  445. end
  446. end
  447. self.ui.Items.Layout_Player:doLayout()
  448. self.ui.Items.Layout_Player:requestDoLayout()
  449. self:showDiPai()
  450. end
  451. function changpaiRoomXiaoJuView:getAHutypeUi(ht,filename)
  452. local ui = self.ui.Items.Layout_hutypes:getCopied()
  453. ui.Items = getUIItems(ui);
  454. ui:setVisible(true)
  455. if not ht then
  456. ht = 0
  457. end
  458. local name = string.format(ZPDef.TipFile.HU,ht)
  459. if filename then
  460. name = filename
  461. end
  462. ui.Items.ImageView_hutype:loadTextureFromPlist(name)
  463. return ui
  464. end
  465. function changpaiRoomXiaoJuView:showDiPai()
  466. local dipaiSize = table.nums(app.room.roomInfo.dipaiList);
  467. if dipaiSize <= 0 then
  468. self.ui.Items.Layout_Bottom_1:setVisible(false)
  469. else
  470. self.ui.Items.Layout_Bottom_1:setVisible(true)
  471. end
  472. self.ui.Items.Layout_Bottom_1:setVisible(false)
  473. --[[if app.room:getActualPlayerNum() == 2 then
  474. local y = self.ui.Items.Layout_Bottom_1:getPositionY()
  475. self.ui.Items.Layout_Bottom_1:setPositionY(y+40)
  476. end--]]
  477. local tIndex = 0
  478. for dipaiK,dipaiV in pairsByKeys(app.room.roomInfo.dipaiList) do
  479. local mLayout = cc.Layout:createNode()
  480. mLayout:setAnchorPoint(cc.p(0.5,0.5))
  481. mLayout:setSize(cc.size(30,30))
  482. local cardImg = cc.ImageView:createNode();
  483. cardImg:setAnchorPoint(cc.p(0.5,0.5));
  484. cardImg:setScale(0.8)
  485. local fileName = ZPFuc.getZPCardImgByValue(dipaiV.chessCards,ZPDef.CardType.CARD_TYPE_QUIT,self.colorType)
  486. cardImg:loadTextureFromPlist(fileName);
  487. local row = math.floor(tIndex/22)
  488. --cardImg:setPosition(self.leftCardPos.x + (tIndex%25)*45,self.leftCardPos.y-row*60)
  489. cardImg:setPosition(cc.p(15,15))
  490. mLayout:addChild(cardImg)
  491. self.ui.Items.Layout_dipai:addChild(mLayout);
  492. tIndex = tIndex + 1;
  493. end
  494. end
  495. function changpaiRoomXiaoJuView:getHuTypeAndBeiShuStr(huType,beishu)
  496. local strRul = ""
  497. return strRul
  498. end
  499. --判断是否是赢家uid
  500. function changpaiRoomXiaoJuView:getIsWinUid(uid)
  501. for huk,huv in pairs(app.room.roomInfo.hupaiInfo) do
  502. if huv.huPaiUid == uid then
  503. return true
  504. end
  505. end
  506. return false
  507. end
  508. function changpaiRoomXiaoJuView:createWeaveCard(value,list,index,isHand,node,userID)
  509. local sendCardType = value.type
  510. local huxi = value.hushu
  511. local opCard = value.opcard
  512. local ui = self.ui.Items.Layout_WeaveCard_Item:getCopied()
  513. ui.Items = getUIItems(ui);
  514. ui:setVisible(true)
  515. local max = table.nums(list)
  516. local idx = max
  517. for i = 1,4 do
  518. local name = "ImageView_Card_"..i
  519. local hu = "ImageView_card_hu_"..i
  520. ui.Items[hu]:setVisible(false)
  521. if i > max then
  522. ui.Items[name]:setVisible(false)
  523. else
  524. if list[i] == app.room.roomInfo.huCard and not self.isShow then
  525. --[[--吃胡一定是手牌
  526. if app.room.roomInfo.huCardType and app.room.roomInfo.huCardType == ZPDef.ReconnectHuType.CHI_HU and isHand then
  527. self.isShow = true
  528. --其他类型的胡牌在组合牌上
  529. elseif app.room.roomInfo.huCardType and app.room.roomInfo.huCardType ~= ZPDef.ReconnectHuType.CHI_HU and not isHand then
  530. self.isShow = true
  531. elseif app.room.roomInfo.huCardType and app.room.roomInfo.huCardType == 0 and isHand then--叫牌的时候
  532. self.isShow = true
  533. end--]]
  534. if app.room.roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_HUANG_ZHUANG then
  535. if true == isHand or #list == 4 or (#list == 3 and list[1]==list[2] and list[2]==list[3]) then
  536. self.isShow = true
  537. end
  538. else
  539. if app.room.roomInfo.huCardType == ZPDef.ReconnectHuType.CHI_HU and not isHand then
  540. else
  541. self.isShow = true
  542. end
  543. end
  544. end
  545. local fileName = ZPFuc.getZPCardImgByValue(list[i],ZPDef.CardType.CARD_TYPE_QUIT,self.colorType)
  546. ui.Items[name]:loadTextureFromPlist(fileName)
  547. ui.Items[name].cardValue = list[i]
  548. --[[if self.isShow == true then
  549. --ui.Items[name]:setColor(cc.c3b(248,193,103))
  550. if not self.showHu[userID] then
  551. self.isShow = false
  552. self.showHu[userID] = true
  553. if self:getIsWinUid(userID) then
  554. ui.Items[hu]:setVisible(true)
  555. end
  556. end
  557. self.isShow = false
  558. end--]]
  559. end
  560. end
  561. --不管是不是手牌都要显示
  562. if self:getWeaveTypeFile(sendCardType) ~= "" then--and (not isHand)
  563. --ui.Items.ImageView_tip:loadTextureFromPlist(self:getWeaveTypeFile(sendCardType))
  564. ui.Items.ImageView_tip:setVisible(false)
  565. else
  566. ui.Items.ImageView_tip:setVisible(false)
  567. end
  568. ui.Items.TextBMFont_youshu:setVisible(false)
  569. --ui.Items.TextBMFont_youshu:setText(huxi)
  570. ui:setPosition(cc.p(self.weaveCardPos.x + index * 35,self.weaveCardPos.y))
  571. --self.ui.Items.Layout_1:addChild(ui)
  572. node:addChild(ui)
  573. end
  574. --在胡牌的那张牌上面显示胡字
  575. function changpaiRoomXiaoJuView:showHuCardBox(node,hucard)
  576. if not node then return end
  577. local cardUI = node:getChildren()
  578. if cardUI and type(cardUI) == 'table' then
  579. local endPos = cardUI[#cardUI]:getPosition()
  580. for i = #cardUI ,1,-1 do
  581. local tui = cardUI[i]
  582. for k = 1,4 do
  583. local name = "ImageView_Card_"..k
  584. local hu = "ImageView_card_hu_"..k
  585. if tui.Items[name] and tui.Items[name]:isVisible() and tui.Items[name].cardValue == hucard then
  586. --把带胡字的那一列放到最后去
  587. tui.Items[hu]:setVisible(true)
  588. local pos1 = tui:getPosition()
  589. tui:setPosition(endPos)
  590. cardUI[#cardUI]:setPosition(pos1)
  591. return
  592. end
  593. end
  594. end
  595. end
  596. end
  597. --[[
  598. 获取组合类型文件
  599. ]]
  600. function changpaiRoomXiaoJuView:getWeaveTypeFile(sendCardType)
  601. if sendCardType == ZPDef.SendCardType.TWO_SEVEN_TEN
  602. or sendCardType == ZPDef.SendCardType.ONE_FIVE_TEN
  603. or sendCardType == ZPDef.SendCardType.ONE_TWO_THREE
  604. or sendCardType == ZPDef.SendCardType.DA_ZI_TWO_AND_ONE
  605. or sendCardType == ZPDef.SendCardType.SHUN_ZI then
  606. return ZPDef.XiaoJuWeaveCardType.CHI
  607. elseif sendCardType == ZPDef.SendCardType.DUI_THREE_SAME then
  608. return ZPDef.XiaoJuWeaveCardType.PENG
  609. elseif sendCardType == ZPDef.SendCardType.KAN_THREE_SAME or sendCardType == ZPDef.SendCardType.DIRTY_THREE_SAME then
  610. return ZPDef.XiaoJuWeaveCardType.WEI
  611. elseif sendCardType == ZPDef.SendCardType.KUAI_SHUI_FOUR_SAME or sendCardType == ZPDef.SendCardType.CHI_PAI_PENG_PAO or sendCardType == ZPDef.SendCardType.CHI_PAI_SHAO_PAO then
  612. return ZPDef.XiaoJuWeaveCardType.ZHAO
  613. elseif sendCardType == ZPDef.SendCardType.GUN_ZI_FOUR_SAME or sendCardType == ZPDef.SendCardType.CHI_PAI_TI then
  614. return ZPDef.XiaoJuWeaveCardType.LONG
  615. elseif sendCardType == ZPDef.SendCardType.ZHUANG_ZI then
  616. return ZPDef.XiaoJuWeaveCardType.JIANG
  617. elseif sendCardType == ZPDef.SendCardType.KANPAI_LOCAL then
  618. return ZPDef.XiaoJuWeaveCardType.KAN
  619. else
  620. local txt = string.format("发牌类型为:"..sendCardType)
  621. --showTooltip(txt)
  622. return ""
  623. end
  624. end
  625. function changpaiRoomXiaoJuView:initOtherData()
  626. local roomInfo = app.room.roomInfo
  627. local winUserId = app.room.roomInfo.winUserId
  628. --规则
  629. self.ui.Items.Text_Rule:setText(ZPWanFa.getRuleInfo(roomInfo.strGameInfo))
  630. --时间
  631. self.ui.Items.Text_Time:setText(getTimeString())
  632. --房号
  633. self.ui.Items.Text_RoomNum:setText("房号:"..tostring(app.room.roomInfo.nShowTableId))
  634. end
  635. function changpaiRoomXiaoJuView:updateUserHead(nodeHead,nUserId, sex, headimgurl)
  636. setPlayerHeadImage(nUserId, headimgurl, nodeHead);
  637. end
  638. -- 查牌
  639. function changpaiRoomXiaoJuView:onClickChaPai()
  640. playBtnEffect()
  641. self:setVisible(false)
  642. end
  643. -- 下一局
  644. function changpaiRoomXiaoJuView:onClickNext()
  645. playBtnEffect()
  646. self.ui:sendMsg(app.room, "callReadyRequest");
  647. if self.nextCallBack then
  648. self.nextCallBack()
  649. end
  650. end
  651. function changpaiRoomXiaoJuView:onClickZongJieSuan()
  652. playBtnEffect()
  653. if self.nextCallBack then
  654. self.nextCallBack()
  655. end
  656. end
  657. function changpaiRoomXiaoJuView:getAHutypeTextUi(text)
  658. local hutext = cc.Text:createNode()
  659. hutext:setDefaults()
  660. local config = hutext:getFontConfig()
  661. config.fontSize = 22
  662. config.texColor = cc.c3b(255,240,179)--cc.c4b(251,213,130,255)
  663. hutext:setFontConfig(config)
  664. hutext:setText(tostring(text))
  665. return hutext
  666. end
  667. function changpaiRoomXiaoJuView:getXiaojiaUid()
  668. return app.room:getUserIdBySeatId(app.room.roomInfo.xiaoSeatId)
  669. end
  670. function changpaiRoomXiaoJuView:IsFengDing(huType)
  671. local ret = getNumBand(huType,ZPDef.HuType.FENGDING)
  672. if ret > 0 then
  673. return true
  674. end
  675. return false
  676. end
  677. --显示胡牌类型
  678. function changpaiRoomXiaoJuView:getHuTypesStr(huUid,huType)
  679. local strSpec = ""
  680. if huType > 0 then
  681. local ret = getNumBand(huType,ZPDef.HuType.TIAN_HU)
  682. if ret > 0 then
  683. strSpec = strSpec.."天胡x2 "
  684. end
  685. local ret = getNumBand(huType,ZPDef.HuType.LONG_HU)
  686. if ret > 0 then
  687. strSpec = strSpec.."龙胡x1 "
  688. end
  689. local ret = getNumBand(huType,ZPDef.HuType.TUO_HONG_HU)
  690. if ret > 0 then
  691. if huUid == self:getXiaojiaUid() then
  692. strSpec = strSpec.."坨坨红x1 "
  693. else
  694. strSpec = strSpec.."坨坨红x3 "
  695. end
  696. end
  697. local ret = getNumBand(huType,ZPDef.HuType.HEI_LONG_HU)
  698. if ret > 0 then
  699. strSpec = strSpec.."黑龙x1 "
  700. end
  701. local ret = getNumBand(huType,ZPDef.HuType.CHI_PIAO)
  702. if ret > 0 then
  703. strSpec = strSpec.."吃飘x1 "
  704. end
  705. local ret = getNumBand(huType,ZPDef.HuType.XIAO_HU)
  706. if ret > 0 then
  707. strSpec = strSpec.."小胡 "
  708. end
  709. local ret = getNumBand(huType,ZPDef.HuType.TUO_HEI_HU)
  710. if ret > 0 then
  711. if huUid == self:getXiaojiaUid() then
  712. strSpec = strSpec.."坨坨黑x1 "
  713. else
  714. strSpec = strSpec.."坨坨黑x3 "
  715. end
  716. end
  717. local ret = getNumBand(huType,ZPDef.HuType.BAO_HU)
  718. if ret > 0 then
  719. strSpec = strSpec.."报叫x1 "
  720. end
  721. end
  722. --另加番
  723. if app.room.roomInfo.fourHongNum > 0 or app.room.roomInfo.fourNormolNum > 0 then
  724. local num = app.room.roomInfo.fourHongNum + app.room.roomInfo.fourNormolNum
  725. strSpec = strSpec.."四张x"..num.." "
  726. end
  727. if app.room.roomInfo.threeHongNum > 0 or app.room.roomInfo.fourHongNum > 0 then
  728. local num = app.room.roomInfo.fourHongNum + app.room.roomInfo.threeHongNum
  729. strSpec = strSpec.."冲番牌x"..num.." "
  730. end
  731. return strSpec
  732. end
  733. return changpaiRoomXiaoJuView