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.

302 lines
9.9 KiB

  1. local PdkGameResult = class("PdkGameResult", cc.UIView)
  2. local PdkSoundHelper = require("pk_luzhoupdk.luaScript.Views.Room.luzhouPdkSoundHelper"):new()
  3. function PdkGameResult:ctor( o )
  4. self._data = o
  5. local ui = loadUI("pk_luzhoupdk/res/ui/ui_room/ui_lzpdk_xiaoju.ui")
  6. self.ui = ui
  7. self:addChild(ui)
  8. self:initUi()
  9. self:showPlayers()
  10. --是否是game over 前的最后一局
  11. self.btnSure:setVisible(self._data.isLast==true)
  12. self.ui.Items.btnContinue:setVisible(self._data.isLast==false)
  13. end
  14. function PdkGameResult:initUi()
  15. self.ui.Items.btnContinue:registerClick(handler(self , self.onClickContinue))
  16. self.txtRoomID = self.ui.Items.txtRoomID
  17. self.txtRoundNum = self.ui.Items.txtRoundNum
  18. self.btnSure = self.ui.Items.btnSure
  19. local roomInfo = app.room:getRoomInfo()
  20. self.dipaiCard = self._data.dipaiCard or roomInfo.dipaiCard
  21. self.txtRoomID:setString(string.format("房号:%d ", roomInfo.nTableId or 0))
  22. self.txtRoundNum:setString(string.format("%s 局数:%d/%d", os.date("%m-%d %H:%M", os.time()), self._data.gameStartCount, self._data.totalGamenum))
  23. self.ui.Items.txtRoomRule:setString(self._data.ruleString or "")
  24. self.btnSure:registerClick(handler(self , self.onClickSure))
  25. self.btnSure:setVisible(false)
  26. end
  27. function PdkGameResult:showPlayers()
  28. for i,v in ipairs(self._data.players) do
  29. v.turnScore = tonumber(v.turnScore)
  30. self.ui.Items.Layout_player:addChild(self:createItem(v))
  31. if app.room:isMyself(v.userId) then
  32. if v.turnScore > 0 then --win
  33. PdkSoundHelper:win()
  34. --self.ui.Items.ImageView_title:loadTexture("pdk_gameresult_img_title_win.png", 1)
  35. else
  36. PdkSoundHelper:lose()
  37. --self.ui.Items.ImageView_title:loadTexture("pdk_gameresult_img_title_lose.png", 1)
  38. end
  39. end
  40. end
  41. self.otherCardShow = {}
  42. if self.dipaiCard then
  43. local dipaiCard = string.split(self.dipaiCard," ")
  44. local otherPlayNum = 1
  45. for i ,v in pairs (dipaiCard) do
  46. if not self.otherCardShow[otherPlayNum] then
  47. self.otherCardShow[otherPlayNum] = {}
  48. end
  49. if v and tonumber(v) then
  50. table.insert(self.otherCardShow[otherPlayNum],tonumber(v))
  51. if #self.otherCardShow[otherPlayNum] == 13 then
  52. otherPlayNum = otherPlayNum + 1
  53. end
  54. end
  55. end
  56. end
  57. for i,v in pairs(self.otherCardShow) do
  58. if #v > 3 then
  59. local cards = pokerSortPdkCards(v)
  60. local tmp = {}
  61. for i,v in pairs(cards) do
  62. table.insert(tmp,v.cid)
  63. end
  64. self.ui.Items.Layout_player:addChild(self:createItemWithNoPlayer(tmp))
  65. end
  66. end
  67. if #self.otherCardShow > 0 and #self.otherCardShow[#self.otherCardShow] > 0 and #self.otherCardShow[#self.otherCardShow] <= 3 then
  68. self.ui.Items.Layout_Bottom_1:setVisible(true)
  69. for i=1,3 do
  70. local cardItem = string.format("ImageView_card_%d",i)
  71. self.ui.Items[cardItem]:setVisible(false)
  72. end
  73. for i=1,#self.otherCardShow[#self.otherCardShow] do
  74. local cardItem = string.format("ImageView_card_%d",i)
  75. local fileName = pokerPng(self.otherCardShow[#self.otherCardShow][i])
  76. self.ui.Items[cardItem]:loadTextureFromPlist(fileName);
  77. self.ui.Items[cardItem]:setVisible(true)
  78. end
  79. else
  80. self.ui.Items.Layout_Bottom_1:setVisible(false)
  81. self.ui.Items.btnSure:setPositionX(640)
  82. self.ui.Items.btnContinue:setPositionX(640)
  83. end
  84. end
  85. function PdkGameResult:onClickContinue( sender )
  86. playBtnEffect()
  87. self.ui:sendMsg(app.room, "callReadyRequestPdk", function() print("根本没调用") end)
  88. performWithDelay(self, function()
  89. app.room:dispatchEvent({name = "pdkNormalEvent_show_game_over"})
  90. self:removeFromParent()
  91. end, 0.1)
  92. end
  93. function PdkGameResult:onClickSure( sender )
  94. playBtnEffect()
  95. app.room:dispatchEvent({name = "pdkNormalEvent_show_game_over"})
  96. self:removeFromParent()
  97. end
  98. function PdkGameResult:createItem( info )
  99. info.turnScore = tonumber(info.turnScore)
  100. local node = loadUI("pk_luzhoupdk/res/ui/ui_room/ui_lzpdk_xiaojuitem.ui")
  101. autoAdapt(node)
  102. self.startX = 1
  103. self.curCardNum = 0
  104. node.Items.Layout_card:removeAllChildren()
  105. node.Items.ImageView_line:setVisible(false)
  106. node.Items.ImageView_flag:setVisible(false)--黑关(13张) 小关(10-12张)
  107. node.Items.txtNick:setString(getSubStringNickname(info.nickname or ""))
  108. node.Items.txtID:setString("ID:"..info.userId)
  109. --显示隐藏游戏内选手id(主办人和管理员不限制,只针对海选赛) -- todo lwq
  110. -- begin
  111. local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
  112. if app.club_php.clubID and app.club_php.clubID ~= 0 then
  113. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  114. --隐私数据
  115. local clubInfo = app.club_php.clubList[app.club_php.clubID]
  116. self.cliext = clubInfo.groupext and clubInfo.groupext.cliext
  117. if not self.cliext or not self.cliext.is_hideUid or (self.cliext and self.cliext.is_hideUid == 1) then
  118. if clubInfo.role == ClubDefine.Job.Creator or clubInfo.role == ClubDefine.Job.Manager then
  119. node.Items.txtID:setVisible(true)
  120. else
  121. node.Items.txtID:setVisible(false)
  122. end
  123. end
  124. end
  125. end
  126. if info.userId == tonumber(app.user.loginInfo.uid) then
  127. node.Items.txtID:setVisible(true)
  128. end
  129. -- end
  130. node.Items.txtLeft:setString("剩牌:"..info.leftNum)
  131. local bombinfo = string.format("炸弹:%d/%d",info.bombTimes,info.allBombTimes)
  132. node.Items.txtBomb:setString(bombinfo)
  133. setPlayerHeadImage(info.userId, info.headimgurl, node.Items.imgHead)
  134. if info.turnScore > 0 then--win
  135. --node.Items.ImageView:loadTexture("pdk_gameresult_img_yellow_bg.png", 1)
  136. node.Items.ImageView:setVisible(true)
  137. local txtColor = cc.c3b(255, 228, 128)
  138. --node.Items.txtLeft:setColor(txtColor)
  139. --node.Items.txtBomb:setColor(txtColor)
  140. --node.Items.txtScore:setColor(txtColor)
  141. local fntConfg = node.Items.txtLeft:getFontConfig()
  142. fntConfg.effectColor = {a=255, r=132, g=59, b=11}
  143. node.Items.txtLeft:setFontConfig(fntConfg)
  144. node.Items.txtBomb:setFontConfig(fntConfg)
  145. node.Items.txtScore:setText("+"..info.turnScore)
  146. else
  147. --node.Items.ImageView:loadTexture("pdk_gameresult_img_blue_bg.png", 1)
  148. node.Items.ImageView:setVisible(false)
  149. local fntConfg = node.Items.txtLeft:getFontConfig()
  150. node.Items.txtScore:setFntFile("res/fonts/dt_jian_num.fnt")
  151. node.Items.txtScore:setText(""..info.turnScore)
  152. end
  153. local groupCard = string.split(info.groupCardInfo,",")
  154. for i,v in pairs(groupCard) do
  155. local tgcard = string.split(v," ")
  156. self:showCards(node,tgcard,true)
  157. end
  158. --local leftCard = string.split(info.handCards," ")
  159. local leftCardNum = 0
  160. if info.leftCards and #info.leftCards > 0 then
  161. self:showCards(node,info.leftCards,false,true)
  162. leftCardNum = #info.leftCards
  163. elseif info.handCards and #info.handCards > 0 then
  164. self:showCards(node,info.handCards,false,true)
  165. leftCardNum = #info.handCards
  166. end
  167. local isDismiss = true--是否是解散的
  168. if app.room.dismissInfo and next(app.room.dismissInfo) ~= nil then
  169. for i,v in pairs(app.room.dismissInfo) do
  170. if v>2 then
  171. isDismiss = false
  172. break
  173. end
  174. end
  175. else
  176. isDismiss = false
  177. end
  178. if not isDismiss then
  179. if leftCardNum == 13 then
  180. node.Items.ImageView_flag:setVisible(true)
  181. node.Items.ImageView_flag:loadTexture("lzpdk_xiaoju_heiguan.png", 1)
  182. elseif leftCardNum <= 12 and leftCardNum >= 10 then
  183. node.Items.ImageView_flag:setVisible(true)
  184. end
  185. end
  186. return node
  187. end
  188. function PdkGameResult:createItemWithNoPlayer( info )
  189. local node = loadUI("pk_luzhoupdk/res/ui/ui_room/ui_lzpdk_xiaojuitem.ui")
  190. self.startX = 1
  191. self.curCardNum = 0
  192. node.Items.Layout_card:removeAllChildren()
  193. node.Items.ImageView_line:setVisible(false)
  194. node.Items.ImageView_flag:setVisible(false)--黑关(13张) 小关(10-12张)
  195. node.Items.txtNick:setVisible(false)
  196. node.Items.txtID:setVisible(false)
  197. node.Items.txtLeft:setVisible(false)
  198. node.Items.txtBomb:setVisible(false)
  199. node.Items.ImageView:setVisible(false)
  200. node.Items.txtScore:setVisible(false)
  201. node.Items.imgHead:setVisible(false)
  202. if #info > 0 then
  203. self:showCards(node,info,false,true)
  204. end
  205. return node
  206. end
  207. function PdkGameResult:showCards(node,data,isShowLine,isGray)
  208. if not data then return end
  209. local num = table.nums(data)
  210. for dipaiK,dipaiV in pairs(data) do
  211. local cardImg = cc.ImageView:createNode();
  212. cardImg:setAnchorPoint(cc.p(0,0));
  213. if dipaiV and dipaiV ~= "" then
  214. local fileName = pokerPng(dipaiV)
  215. cardImg:loadTextureFromPlist(fileName);
  216. cardImg:setScale(0.35)
  217. local x = self.startX + self.curCardNum*50
  218. local tarPos = cc.p(x ,7)
  219. cardImg:setPosition(tarPos);
  220. node.Items.Layout_card:addChild(cardImg);
  221. if num > 1 and isShowLine and true == isShowLine then
  222. isShowLine = false
  223. local imgaeLine = node.Items.ImageView_line:getCopied()
  224. imgaeLine:setSize(cc.size((num-1)*50,10))
  225. imgaeLine:setPosition(x+25,90)
  226. node.Items.Layout_card:addChild(imgaeLine)
  227. end
  228. if isGray and true == isGray then
  229. cardImg:setColor(cc.c3b(0xb3, 0xaa, 0xaa))--DOWN_COLOR
  230. end
  231. self.curCardNum = self.curCardNum + 1
  232. end
  233. end
  234. end
  235. return PdkGameResult
  236. --[[
  237. --[[
  238. "self._data" = {
  239. "bankSeatId" = 0
  240. "gameStartCount" = 1
  241. "leftCards" = {
  242. 1 = 12
  243. 2 = 24
  244. 3 = 9
  245. 4 = 53
  246. 5 = 44
  247. 6 = 4
  248. 7 = 58
  249. 8 = 10
  250. 9 = 61
  251. 10 = 5
  252. 11 = 56
  253. 12 = 23
  254. 13 = 37
  255. 14 = 8
  256. 15 = 25
  257. 16 = 54
  258. }
  259. "players" = {
  260. 1 = {
  261. "bSpring" = 0
  262. "bombTimes" = 0
  263. "haveRedTen" = 0
  264. "totalScore" = 9
  265. "turnScore" = 9
  266. "userId" = 1023496
  267. "leftNum"
  268. }
  269. 2 = {
  270. "bSpring" = 0
  271. "bombTimes" = 0
  272. "haveRedTen" = 0
  273. "totalScore" = -9
  274. "turnScore" = -9
  275. "userId" = 1023544
  276. "leftNum"
  277. }
  278. }
  279. "totalGamenum" = 10
  280. }
  281. ]]