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.

163 lines
5.7 KiB

  1. local PdkGameResult = class("PdkGameResult", cc.UIView)
  2. local PdkSoundHelper = require("pk_paodekuai.luaScript.Views.Room.PdkSoundHelper"):new()
  3. function PdkGameResult:ctor( o )
  4. self._data = o
  5. local ui = loadUI("pk_paodekuai/res/ui/ui_room/ui_pdk_gameresult.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.txtRoomID:setString(string.format("房号:%d ", roomInfo.nTableId or 0))
  21. self.txtRoundNum:setString(string.format("%s 局数:%d/%d", os.date("%m-%d %H:%M", os.time()), self._data.gameStartCount, self._data.totalGamenum))
  22. self.ui.Items.txtRoomRule:setString(self._data.ruleString or "")
  23. self.btnSure:registerClick(handler(self , self.onClickSure))
  24. self.btnSure:setVisible(false)
  25. end
  26. function PdkGameResult:showPlayers()
  27. for i,v in ipairs(self._data.players) do
  28. v.turnScore = tonumber(v.turnScore)
  29. self.ui.Items.Layout_player:addChild(self:createItem(v))
  30. if app.room:isMyself(v.userId) then
  31. if v.turnScore > 0 then --win
  32. PdkSoundHelper:win()
  33. self.ui.Items.ImageView_title:loadTexture("pk_paodekuai/res/ui/zy_gameresult/pdk_gameresult_img_title_win.png", 0)
  34. else
  35. PdkSoundHelper:lose()
  36. self.ui.Items.ImageView_title:loadTexture("pk_paodekuai/res/ui/zy_gameresult/pdk_gameresult_img_title_lose.png", 0)
  37. end
  38. end
  39. end
  40. end
  41. function PdkGameResult:onClickContinue( sender )
  42. playBtnEffect()
  43. self.ui:sendMsg(app.room, "callReadyRequestPdk", function() print("根本没调用") end)
  44. performWithDelay(self, function()
  45. app.room:dispatchEvent({name = "pdkNormalEvent_show_game_over"})
  46. self:removeFromParent()
  47. end, 0.1)
  48. end
  49. function PdkGameResult:onClickSure( sender )
  50. playBtnEffect()
  51. app.room:dispatchEvent({name = "pdkNormalEvent_show_game_over"})
  52. self:removeFromParent()
  53. end
  54. function PdkGameResult:createItem( info )
  55. info.turnScore = tonumber(info.turnScore)
  56. local node = loadUI("pk_paodekuai/res/ui/ui_room/ui_pdk_gameresult_item.ui")
  57. node.Items.txtNick:setString(getSubStringNickname(info.nickname or ""))
  58. node.Items.txtID:setString("ID:"..info.userId)
  59. --显示隐藏游戏内选手id(主办人和管理员不限制,只针对海选赛) -- todo lwq
  60. -- begin
  61. local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
  62. if app.club_php.clubID and app.club_php.clubID ~= 0 then
  63. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  64. --隐私数据
  65. local clubInfo = app.club_php.clubList[app.club_php.clubID]
  66. self.cliext = clubInfo.groupext and clubInfo.groupext.cliext
  67. if not self.cliext or not self.cliext.is_hideUid or (self.cliext and self.cliext.is_hideUid == 1) then
  68. if clubInfo.role == ClubDefine.Job.Creator or clubInfo.role == ClubDefine.Job.Manager then
  69. node.Items.txtID:setVisible(true)
  70. else
  71. node.Items.txtID:setVisible(false)
  72. end
  73. end
  74. end
  75. end
  76. if info.userId == tonumber(app.user.loginInfo.uid) then
  77. node.Items.txtID:setVisible(true)
  78. end
  79. -- end
  80. node.Items.txtLeft:setString(""..info.leftNum)
  81. node.Items.txtBomb:setString(""..info.bombTimes)
  82. node.Items.ImageView_chuntian:setVisible(info.bSpring==1)
  83. node.Items.ImageView_fanchuntian:setVisible(info.bSpring==2)
  84. node.Items.ImageView_zhaniao:setVisible(info.haveRedTen==1 and self._data.isZhaniao)
  85. setPlayerHeadImage(info.userId, info.headimgurl, node.Items.imgHead)
  86. if info.turnScore > 0 then--win
  87. node.Items.ImageView:loadTexture("pk_paodekuai/res/ui/zy_gameresult/pdk_gameresult_img_yellow_bg.png", 0)
  88. local txtColor = cc.c3b(255, 228, 128)
  89. node.Items.txtLeft:setColor(txtColor)
  90. node.Items.txtBomb:setColor(txtColor)
  91. node.Items.txtScore:setColor(txtColor)
  92. local fntConfg = node.Items.txtLeft:getFontConfig()
  93. fntConfg.effectColor = {a=255, r=132, g=59, b=11}
  94. node.Items.txtLeft:setFontConfig(fntConfg)
  95. node.Items.txtBomb:setFontConfig(fntConfg)
  96. node.Items.txtScore:setText("+"..info.turnScore)
  97. else
  98. node.Items.ImageView:loadTexture("pk_paodekuai/res/ui/zy_gameresult/pdk_gameresult_img_blue_bg.png", 0)
  99. local fntConfg = node.Items.txtLeft:getFontConfig()
  100. node.Items.txtScore:setText(""..info.turnScore)
  101. end
  102. return node
  103. end
  104. return PdkGameResult
  105. --[[
  106. --[[
  107. "self._data" = {
  108. "bankSeatId" = 0
  109. "gameStartCount" = 1
  110. "leftCards" = {
  111. 1 = 12
  112. 2 = 24
  113. 3 = 9
  114. 4 = 53
  115. 5 = 44
  116. 6 = 4
  117. 7 = 58
  118. 8 = 10
  119. 9 = 61
  120. 10 = 5
  121. 11 = 56
  122. 12 = 23
  123. 13 = 37
  124. 14 = 8
  125. 15 = 25
  126. 16 = 54
  127. }
  128. "players" = {
  129. 1 = {
  130. "bSpring" = 0
  131. "bombTimes" = 0
  132. "haveRedTen" = 0
  133. "totalScore" = 9
  134. "turnScore" = 9
  135. "userId" = 1023496
  136. "leftNum"
  137. }
  138. 2 = {
  139. "bSpring" = 0
  140. "bombTimes" = 0
  141. "haveRedTen" = 0
  142. "totalScore" = -9
  143. "turnScore" = -9
  144. "userId" = 1023544
  145. "leftNum"
  146. }
  147. }
  148. "totalGamenum" = 10
  149. }
  150. ]]