Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

340 linhas
11 KiB

  1. local PKDef = PKFramework.PKImport("pk_base.luaScript.PKDef")
  2. local PKFuc = PKFramework.PKImport("pk_base.luaScript.PKFunctions")
  3. local PKSound = PKFramework.PKImport("pk_base.luaScript.PKSound")
  4. local PKWanFa = PKFramework.ImportWanFa("luaScript.SubGameDefine.PuKe.PKWanFa")
  5. local PKRoomXiaoJuView = class("PKRoomXiaoJuView", cc.UIView)
  6. function PKRoomXiaoJuView:ctor(nextCallBackFun,chaPaiCallBackFun,dajuCallBack)
  7. PKRoomXiaoJuView.super.ctor(self);
  8. self.nextCallBack = nextCallBackFun
  9. self.chaPaiCallBackFun = chaPaiCallBackFun
  10. self.dajuCallBack = dajuCallBack
  11. self.xiaojuData = app.room.roomInfo.playList
  12. end
  13. function PKRoomXiaoJuView:loadUI()
  14. local ui = loadUI("pk_base/res/ui/ui_fangjian/pk_ui_xiaoju.ui");
  15. self.ui = ui;
  16. self:addChild(ui);
  17. end
  18. function PKRoomXiaoJuView:onEnter()
  19. PKRoomXiaoJuView.super.onEnter(self)
  20. self:loadUI()
  21. -- 下一局
  22. self.ui.Items.Button_Next:registerClick(handler(self , self.onClickNext))
  23. --显示总结算
  24. self.ui.Items.Button_All:registerClick(handler(self , self.onClickZongJieSuan))
  25. --查牌
  26. self.ui.Items.Button_ChaPai:registerClick(handler(self , self.onClickChaPai))
  27. --复制用
  28. self.ui.Items.Layout_Player_Item:setVisible(false)
  29. self.ui.Items.Layout_Player_VS:setVisible(false)
  30. self.ui.Items.Layout_PlayerNoPlay_Item:setVisible(false)
  31. self.ui.Items.Layout_Player_gz:setVisible(false)
  32. --显示结束
  33. if app.room.roomInfo.isGameOver == 1 then
  34. self.ui.Items.Button_Next:setVisible(false)
  35. self.ui.Items.Button_All:setVisible(true)
  36. else
  37. self.ui.Items.Button_All:setVisible(false)
  38. end
  39. --初始化人物信息
  40. self:initOtherData()
  41. self:updatePlayerInfo()
  42. end
  43. function PKRoomXiaoJuView:initOtherData()
  44. local roomInfo = app.room.roomInfo
  45. --规则
  46. self.ui.Items.Text_Rule:setText(PKWanFa.getRuleInfo())
  47. --时间
  48. self.ui.Items.Text_Time:setText(os.date("%Y-%m-%d %X",roomInfo.mTime))
  49. --房号
  50. self.ui.Items.Text_RoomNum:setText("房间号:"..tostring(app.room.roomInfo.nShowTableId))
  51. --局数
  52. self.ui.Items.TextJuShu:setText("局数:"..tostring(app.room.roomInfo.nGameStartCount).."/"..tostring(app.room.roomInfo.nTotalGameNum))
  53. end
  54. function PKRoomXiaoJuView:updatePlayerInfo()
  55. local maxPlayer = app.room:getCurMaxPlayer()
  56. --是否第一次
  57. local isFirst = true
  58. --是否观战
  59. local isHaveGuanZhan = false
  60. --是否包牌
  61. local isHavePeopleBaoPai = false
  62. --非观战数据
  63. local friendList = {}
  64. local enemyList = {}
  65. for k,v in pairs(app.room.roomInfo.playerList) do
  66. if v.mPlaying == 0 then
  67. isHaveGuanZhan = true
  68. self.ui.Items.Layout_Player:setPositionX(self.ui.Items.Layout_Player:getPositionX() + 50)
  69. end
  70. local memberInfo = app.room.roomInfo.memberList[v.nUserId]
  71. if memberInfo then
  72. if tonumber(memberInfo.baoPai) == PKDef.BaoPai.BAOPAI then
  73. isHavePeopleBaoPai = true
  74. end
  75. end
  76. end
  77. if isHaveGuanZhan then
  78. self.ui.Items.Layout_Player:setAnchorPoint(cc.p(1,self.ui.Items.Layout_Player:getAnchorPoint().y))
  79. end
  80. --某个情况调整布局 --A VS B |观战
  81. if isHaveGuanZhan and maxPlayer == 3 then
  82. self.ui.Items.Layout_Player:setPositionX(self.ui.Items.Layout_Player:getPositionX() + 140)
  83. self.ui.Items.Layout_noPlayer:setPositionX(self.ui.Items.Layout_noPlayer:getPositionX() + 140)
  84. end
  85. --观战数据
  86. for k,v in pairsByKeys(app.room.roomInfo.playerList) do
  87. if v.mPlaying == 0 then
  88. if isFirst then
  89. isFirst = false
  90. local gz = self.ui.Items.Layout_Player_gz:getCopied()
  91. self.ui.Items.Layout_noPlayer:addChild(gz)
  92. end
  93. local player = self.ui.Items.Layout_PlayerNoPlay_Item:getCopied()
  94. player.Items = getUIItems(player)
  95. local userInfo = json.decode(v.userInfo);
  96. local name = getShortName(userInfo.nickname)
  97. setPlayerHeadImage(v.nUserId,userInfo.headimgurl,player.Items.ImageView_head_1,false)
  98. player.Items.Text_name_1:setText(tostring(name))
  99. player.Items.Text_id_1:setText(tostring(v.nUserId))
  100. --显示隐藏游戏内选手id(主办人和管理员不限制,只针对海选赛) -- todo lwq
  101. -- begin
  102. local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
  103. if app.club_php.clubID and app.club_php.clubID ~= 0 then
  104. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  105. --隐私数据
  106. local clubInfo = app.club_php.clubList[app.club_php.clubID]
  107. self.cliext = clubInfo.groupext and clubInfo.groupext.cliext
  108. if not self.cliext or not self.cliext.is_hideUid or (self.cliext and self.cliext.is_hideUid == 1) then
  109. if clubInfo.role == ClubDefine.Job.Creator or clubInfo.role == ClubDefine.Job.Manager then
  110. player.Items.Text_id_1:setVisible(true)
  111. else
  112. player.Items.Text_id_1:setVisible(false)
  113. end
  114. end
  115. end
  116. end
  117. if v.nUserId == tonumber(app.user.loginInfo.uid) then
  118. player.Items.Text_id_1:setVisible(true)
  119. end
  120. -- end
  121. if tonumber(v.nScore) > 0 then
  122. player.Items.Text_TurnScore_1:setText("+"..tostring(v.nScore))
  123. else
  124. player.Items.Text_TurnScore_1:setText(tostring(v.nScore))
  125. end
  126. self.ui.Items.Layout_noPlayer:addChild(player)
  127. if v.nUserId == app.room:getMyUserId() then
  128. self.ui.Items.ImageView_title:setVisible(false)
  129. end
  130. end
  131. if v.mPlaying == 1 and maxPlayer ~= 3 then
  132. if v.nUserId ~= app.room.roomInfo.nBankerUserId and v.nUserId ~= app.room.roomInfo.nBankerHelper then
  133. enemyList[v.nUserId] = v
  134. else
  135. friendList[v.nUserId] = v
  136. end
  137. end
  138. --3人玩法
  139. if v.mPlaying == 1 and maxPlayer == 3 then
  140. if tonumber(v.nScore) < 0 then
  141. enemyList[v.nUserId] = v
  142. else
  143. friendList[v.nUserId] = v
  144. end
  145. end
  146. end
  147. for k,v in pairsByKeys(friendList) do
  148. local player = self.ui.Items.Layout_Player_Item:getCopied()
  149. player.Items = getUIItems(player)
  150. local userInfo = json.decode(v.userInfo);
  151. local name = getShortName(userInfo.nickname)
  152. setPlayerHeadImage(v.nUserId,userInfo.headimgurl,player.Items.ImageView_head,false)
  153. player.Items.Text_name:setText(tostring(name))
  154. player.Items.Text_id:setText(tostring(v.nUserId))
  155. --显示隐藏游戏内选手id(主办人和管理员不限制,只针对海选赛) -- todo lwq
  156. -- begin
  157. local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
  158. if app.club_php.clubID and app.club_php.clubID ~= 0 then
  159. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  160. --隐私数据
  161. local clubInfo = app.club_php.clubList[app.club_php.clubID]
  162. self.cliext = clubInfo.groupext and clubInfo.groupext.cliext
  163. if not self.cliext or not self.cliext.is_hideUid or (self.cliext and self.cliext.is_hideUid == 1) then
  164. if clubInfo.role == ClubDefine.Job.Creator or clubInfo.role == ClubDefine.Job.Manager then
  165. player.Items.Text_id:setVisible(true)
  166. else
  167. player.Items.Text_id:setVisible(false)
  168. end
  169. end
  170. end
  171. end
  172. if v.nUserId == tonumber(app.user.loginInfo.uid) then
  173. player.Items.Text_id:setVisible(true)
  174. end
  175. -- end
  176. player.Items.Text_boomScore:setText(tostring(v.mBombTimes))
  177. if tonumber(v.nScore) > 0 then
  178. player.Items.Text_TurnScore:setText("+"..tostring(v.nScore))
  179. else
  180. player.Items.Text_TurnScore:setText(tostring(v.nScore))
  181. player.Items.ImageView_bg:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_lose.png")
  182. player.Items.ImageView_5:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_bombBg0.png")
  183. end
  184. if v.nUserId == app.room:getMyUserId() then
  185. if v.mWinLose == 2 then
  186. self.ui.Items.ImageView_title:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_xiaoju_pingju.png")
  187. elseif v.mWinLose == 0 then
  188. self.ui.Items.ImageView_title:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_xiaoju_lose.png")
  189. elseif v.mWinLose == 1 then
  190. self.ui.Items.ImageView_title:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_xiaoju_win.png")
  191. elseif v.mWinLose == -1 then
  192. self.ui.Items.ImageView_title:setVisible(false)
  193. end
  194. end
  195. if v.ranking > 0 then
  196. local file = string.format("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_ranking%d.png",v.ranking)
  197. player.Items.ImageView_flag:loadTexture(file)
  198. else
  199. player.Items.ImageView_4:setVisible(false)
  200. end
  201. self.ui.Items.Layout_Player:addChild(player)
  202. end
  203. local function doVs()
  204. local vs = self.ui.Items.Layout_Player_VS:getCopied()
  205. self.ui.Items.Layout_Player:addChild(vs)
  206. end
  207. --根据规则动态显示VS
  208. if PKFuc.getIsSingleBattle() and not isHavePeopleBaoPai then
  209. if maxPlayer == 2 then
  210. doVs()
  211. end
  212. else
  213. doVs()
  214. end
  215. for k,v in pairsByKeys(enemyList) do
  216. local player = self.ui.Items.Layout_Player_Item:getCopied()
  217. player.Items = getUIItems(player)
  218. local userInfo = json.decode(v.userInfo);
  219. local name = getShortName(userInfo.nickname)
  220. setPlayerHeadImage(v.nUserId,userInfo.headimgurl,player.Items.ImageView_head,false)
  221. player.Items.Text_name:setText(tostring(name))
  222. player.Items.Text_id:setText(tostring(v.nUserId))
  223. --显示隐藏游戏内选手id(主办人和管理员不限制,只针对海选赛) -- todo lwq
  224. -- begin
  225. local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
  226. if app.club_php.clubID and app.club_php.clubID ~= 0 then
  227. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  228. --隐私数据
  229. local clubInfo = app.club_php.clubList[app.club_php.clubID]
  230. self.cliext = clubInfo.groupext and clubInfo.groupext.cliext
  231. if not self.cliext or not self.cliext.is_hideUid or (self.cliext and self.cliext.is_hideUid == 1) then
  232. if clubInfo.role == ClubDefine.Job.Creator or clubInfo.role == ClubDefine.Job.Manager then
  233. player.Items.Text_id:setVisible(true)
  234. else
  235. player.Items.Text_id:setVisible(false)
  236. end
  237. end
  238. end
  239. end
  240. if v.nUserId == tonumber(app.user.loginInfo.uid) then
  241. player.Items.Text_id:setVisible(true)
  242. end
  243. -- end
  244. player.Items.Text_boomScore:setText(tostring(v.mBombTimes))
  245. if tonumber(v.nScore) > 0 then
  246. player.Items.Text_TurnScore:setText("+"..tostring(v.nScore))
  247. else
  248. player.Items.Text_TurnScore:setText(tostring(v.nScore))
  249. player.Items.ImageView_bg:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_lose.png")
  250. player.Items.ImageView_5:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_bombBg0.png")
  251. end
  252. if v.nUserId == app.room:getMyUserId() then
  253. if v.mWinLose == 2 then
  254. self.ui.Items.ImageView_title:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_xiaoju_pingju.png")
  255. elseif v.mWinLose == 0 then
  256. self.ui.Items.ImageView_title:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_xiaoju_lose.png")
  257. elseif v.mWinLose == 1 then
  258. self.ui.Items.ImageView_title:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_xiaoju_win.png")
  259. elseif v.mWinLose == -1 then
  260. self.ui.Items.ImageView_title:setVisible(false)
  261. end
  262. end
  263. if v.ranking > 0 then
  264. local file = string.format("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_ranking%d.png",v.ranking)
  265. player.Items.ImageView_flag:loadTexture(file)
  266. else
  267. player.Items.ImageView_4:setVisible(false)
  268. end
  269. self.ui.Items.Layout_Player:addChild(player)
  270. end
  271. self.ui.Items.Layout_Player:requestDoLayout()
  272. self.ui.Items.Layout_Player:doLayout()
  273. self.ui.Items.Layout_noPlayer:requestDoLayout()
  274. self.ui.Items.Layout_noPlayer:doLayout()
  275. end
  276. -- 查牌
  277. function PKRoomXiaoJuView:onClickChaPai()
  278. playBtnEffect()
  279. self:setVisible(false)
  280. if self.chaPaiCallBackFun then
  281. self.chaPaiCallBackFun()
  282. end
  283. end
  284. -- 下一局
  285. function PKRoomXiaoJuView:onClickNext()
  286. playBtnEffect()
  287. if self.nextCallBack then
  288. self.nextCallBack()
  289. end
  290. end
  291. function PKRoomXiaoJuView:onClickZongJieSuan()
  292. playBtnEffect()
  293. if self.dajuCallBack then
  294. self.dajuCallBack()
  295. end
  296. end
  297. return PKRoomXiaoJuView;