25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

301 lines
9.9 KiB

  1. local PdkGameResult = class("PdkGameResult", cc.UIView)
  2. local PdkSoundHelper = require("pk_hejiangpdk.luaScript.Views.Room.hejiangPdkSoundHelper"):new()
  3. function PdkGameResult:ctor( o )
  4. self._data = o
  5. local ui = loadUI("pk_hejiangpdk/res/ui/ui_room/ui_hjpdk_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))
  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. local node = loadUI("pk_luzhoupdk/res/ui/ui_room/ui_lzpdk_xiaojuitem.ui")
  100. autoAdapt(node)
  101. self.startX = 1
  102. self.curCardNum = 0
  103. node.Items.Layout_card:removeAllChildren()
  104. node.Items.ImageView_line:setVisible(false)
  105. node.Items.ImageView_flag:setVisible(false)--黑关(13张) 小关(10-12张)
  106. node.Items.txtNick:setString(getSubStringNickname(info.nickname or ""))
  107. node.Items.txtID:setString("ID:"..info.userId)
  108. --显示隐藏游戏内选手id(主办人和管理员不限制,只针对海选赛) -- todo lwq
  109. -- begin
  110. local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
  111. if app.club_php.clubID and app.club_php.clubID ~= 0 then
  112. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  113. --隐私数据
  114. local clubInfo = app.club_php.clubList[app.club_php.clubID]
  115. self.cliext = clubInfo.groupext and clubInfo.groupext.cliext
  116. if not self.cliext or not self.cliext.is_hideUid or (self.cliext and self.cliext.is_hideUid == 1) then
  117. if clubInfo.role == ClubDefine.Job.Creator or clubInfo.role == ClubDefine.Job.Manager then
  118. node.Items.txtID:setVisible(true)
  119. else
  120. node.Items.txtID:setVisible(false)
  121. end
  122. end
  123. end
  124. end
  125. if info.userId == tonumber(app.user.loginInfo.uid) then
  126. node.Items.txtID:setVisible(true)
  127. end
  128. -- end
  129. node.Items.txtLeft:setString("剩牌:"..info.leftNum)
  130. local bombinfo = string.format("炸弹:%d/%d",info.bombTimes,info.allBombTimes)
  131. node.Items.txtBomb:setString(bombinfo)
  132. setPlayerHeadImage(info.userId, info.headimgurl, node.Items.imgHead)
  133. if info.turnScore > 0 then--win
  134. --node.Items.ImageView:loadTexture("pdk_gameresult_img_yellow_bg.png", 1)
  135. node.Items.ImageView:setVisible(true)
  136. local txtColor = cc.c3b(255, 228, 128)
  137. --node.Items.txtLeft:setColor(txtColor)
  138. --node.Items.txtBomb:setColor(txtColor)
  139. --node.Items.txtScore:setColor(txtColor)
  140. local fntConfg = node.Items.txtLeft:getFontConfig()
  141. fntConfg.effectColor = {a=255, r=132, g=59, b=11}
  142. node.Items.txtLeft:setFontConfig(fntConfg)
  143. node.Items.txtBomb:setFontConfig(fntConfg)
  144. node.Items.txtScore:setText("+"..info.turnScore)
  145. else
  146. --node.Items.ImageView:loadTexture("pdk_gameresult_img_blue_bg.png", 1)
  147. node.Items.ImageView:setVisible(false)
  148. local fntConfg = node.Items.txtLeft:getFontConfig()
  149. node.Items.txtScore:setFntFile("res/fonts/dt_jian_num.fnt")
  150. node.Items.txtScore:setText(""..info.turnScore)
  151. end
  152. local groupCard = string.split(info.groupCardInfo,",")
  153. for i,v in pairs(groupCard) do
  154. local tgcard = string.split(v," ")
  155. self:showCards(node,tgcard,true)
  156. end
  157. --local leftCard = string.split(info.handCards," ")
  158. local leftCardNum = 0
  159. if info.leftCards and #info.leftCards > 0 then
  160. self:showCards(node,info.leftCards,false,true)
  161. leftCardNum = #info.leftCards
  162. elseif info.handCards and #info.handCards > 0 then
  163. self:showCards(node,info.handCards,false,true)
  164. leftCardNum = #info.handCards
  165. end
  166. local isDismiss = true--是否是解散的
  167. if app.room.dismissInfo and next(app.room.dismissInfo) ~= nil then
  168. for i,v in pairs(app.room.dismissInfo) do
  169. if v>2 then
  170. isDismiss = false
  171. break
  172. end
  173. end
  174. else
  175. isDismiss = false
  176. end
  177. if not isDismiss then
  178. if leftCardNum == 13 then
  179. node.Items.ImageView_flag:setVisible(true)
  180. node.Items.ImageView_flag:loadTexture("lzpdk_xiaoju_heiguan.png", 1)
  181. elseif leftCardNum <= 12 and leftCardNum >= 10 then
  182. node.Items.ImageView_flag:setVisible(true)
  183. end
  184. end
  185. return node
  186. end
  187. function PdkGameResult:createItemWithNoPlayer( info )
  188. local node = loadUI("pk_luzhoupdk/res/ui/ui_room/ui_lzpdk_xiaojuitem.ui")
  189. self.startX = 1
  190. self.curCardNum = 0
  191. node.Items.Layout_card:removeAllChildren()
  192. node.Items.ImageView_line:setVisible(false)
  193. node.Items.ImageView_flag:setVisible(false)--黑关(13张) 小关(10-12张)
  194. node.Items.txtNick:setVisible(false)
  195. node.Items.txtID:setVisible(false)
  196. node.Items.txtLeft:setVisible(false)
  197. node.Items.txtBomb:setVisible(false)
  198. node.Items.ImageView:setVisible(false)
  199. node.Items.txtScore:setVisible(false)
  200. node.Items.imgHead:setVisible(false)
  201. if #info > 0 then
  202. self:showCards(node,info,false,true)
  203. end
  204. return node
  205. end
  206. function PdkGameResult:showCards(node,data,isShowLine,isGray)
  207. if not data then return end
  208. local num = table.nums(data)
  209. for dipaiK,dipaiV in pairs(data) do
  210. local cardImg = cc.ImageView:createNode();
  211. cardImg:setAnchorPoint(cc.p(0,0));
  212. if dipaiV and dipaiV ~= "" then
  213. local fileName = pokerPng(dipaiV)
  214. cardImg:loadTextureFromPlist(fileName);
  215. cardImg:setScale(0.35)
  216. local x = self.startX + self.curCardNum*50
  217. local tarPos = cc.p(x ,7)
  218. cardImg:setPosition(tarPos);
  219. node.Items.Layout_card:addChild(cardImg);
  220. if num > 1 and isShowLine and true == isShowLine then
  221. isShowLine = false
  222. local imgaeLine = node.Items.ImageView_line:getCopied()
  223. imgaeLine:setSize(cc.size((num-1)*50,10))
  224. imgaeLine:setPosition(x+25,90)
  225. node.Items.Layout_card:addChild(imgaeLine)
  226. end
  227. if isGray and true == isGray then
  228. cardImg:setColor(cc.c3b(0xb3, 0xaa, 0xaa))--DOWN_COLOR
  229. end
  230. self.curCardNum = self.curCardNum + 1
  231. end
  232. end
  233. end
  234. return PdkGameResult
  235. --[[
  236. --[[
  237. "self._data" = {
  238. "bankSeatId" = 0
  239. "gameStartCount" = 1
  240. "leftCards" = {
  241. 1 = 12
  242. 2 = 24
  243. 3 = 9
  244. 4 = 53
  245. 5 = 44
  246. 6 = 4
  247. 7 = 58
  248. 8 = 10
  249. 9 = 61
  250. 10 = 5
  251. 11 = 56
  252. 12 = 23
  253. 13 = 37
  254. 14 = 8
  255. 15 = 25
  256. 16 = 54
  257. }
  258. "players" = {
  259. 1 = {
  260. "bSpring" = 0
  261. "bombTimes" = 0
  262. "haveRedTen" = 0
  263. "totalScore" = 9
  264. "turnScore" = 9
  265. "userId" = 1023496
  266. "leftNum"
  267. }
  268. 2 = {
  269. "bSpring" = 0
  270. "bombTimes" = 0
  271. "haveRedTen" = 0
  272. "totalScore" = -9
  273. "turnScore" = -9
  274. "userId" = 1023544
  275. "leftNum"
  276. }
  277. }
  278. "totalGamenum" = 10
  279. }
  280. ]]