|
- local PdkGameResult = class("PdkGameResult", cc.UIView)
- local PdkSoundHelper = require("pk_hejiangpdk.luaScript.Views.Room.hejiangPdkSoundHelper"):new()
- function PdkGameResult:ctor( o )
- self._data = o
- local ui = loadUI("pk_hejiangpdk/res/ui/ui_room/ui_hjpdk_xiaoju.ui")
- self.ui = ui
- self:addChild(ui)
-
- self:initUi()
- self:showPlayers()
- --是否是game over 前的最后一局
- self.btnSure:setVisible(self._data.isLast==true)
- self.ui.Items.btnContinue:setVisible(self._data.isLast==false)
- end
-
- function PdkGameResult:initUi()
- self.ui.Items.btnContinue:registerClick(handler(self , self.onClickContinue))
- self.txtRoomID = self.ui.Items.txtRoomID
- self.txtRoundNum = self.ui.Items.txtRoundNum
- self.btnSure = self.ui.Items.btnSure
- local roomInfo = app.room:getRoomInfo()
- self.dipaiCard = self._data.dipaiCard or roomInfo.dipaiCard
- self.txtRoomID:setString(string.format("房号:%d ", roomInfo.nTableId))
- self.txtRoundNum:setString(string.format("%s 局数:%d/%d", os.date("%m-%d %H:%M", os.time()), self._data.gameStartCount, self._data.totalGamenum))
- self.ui.Items.txtRoomRule:setString(self._data.ruleString or "")
- self.btnSure:registerClick(handler(self , self.onClickSure))
- self.btnSure:setVisible(false)
- end
-
- function PdkGameResult:showPlayers()
- for i,v in ipairs(self._data.players) do
- v.turnScore = tonumber(v.turnScore)
- self.ui.Items.Layout_player:addChild(self:createItem(v))
- if app.room:isMyself(v.userId) then
- if v.turnScore > 0 then --win
- PdkSoundHelper:win()
- --self.ui.Items.ImageView_title:loadTexture("pdk_gameresult_img_title_win.png", 1)
- else
- PdkSoundHelper:lose()
- --self.ui.Items.ImageView_title:loadTexture("pdk_gameresult_img_title_lose.png", 1)
- end
- end
- end
-
- self.otherCardShow = {}
- if self.dipaiCard then
- local dipaiCard = string.split(self.dipaiCard," ")
- local otherPlayNum = 1
- for i ,v in pairs (dipaiCard) do
- if not self.otherCardShow[otherPlayNum] then
- self.otherCardShow[otherPlayNum] = {}
- end
- if v and tonumber(v) then
- table.insert(self.otherCardShow[otherPlayNum],tonumber(v))
- if #self.otherCardShow[otherPlayNum] == 13 then
- otherPlayNum = otherPlayNum + 1
- end
- end
- end
- end
- for i,v in pairs(self.otherCardShow) do
- if #v > 3 then
- local cards = pokerSortPdkCards(v)
- local tmp = {}
- for i,v in pairs(cards) do
- table.insert(tmp,v.cid)
- end
- self.ui.Items.Layout_player:addChild(self:createItemWithNoPlayer(tmp))
- end
- end
- if #self.otherCardShow > 0 and #self.otherCardShow[#self.otherCardShow] > 0 and #self.otherCardShow[#self.otherCardShow] <= 3 then
- self.ui.Items.Layout_Bottom_1:setVisible(true)
- for i=1,3 do
- local cardItem = string.format("ImageView_card_%d",i)
- self.ui.Items[cardItem]:setVisible(false)
- end
- for i=1,#self.otherCardShow[#self.otherCardShow] do
- local cardItem = string.format("ImageView_card_%d",i)
- local fileName = pokerPng(self.otherCardShow[#self.otherCardShow][i])
- self.ui.Items[cardItem]:loadTextureFromPlist(fileName);
- self.ui.Items[cardItem]:setVisible(true)
- end
- else
- self.ui.Items.Layout_Bottom_1:setVisible(false)
- self.ui.Items.btnSure:setPositionX(640)
- self.ui.Items.btnContinue:setPositionX(640)
- end
- end
-
- function PdkGameResult:onClickContinue( sender )
- playBtnEffect()
- self.ui:sendMsg(app.room, "callReadyRequestPdk", function() print("根本没调用") end)
- performWithDelay(self, function()
- app.room:dispatchEvent({name = "pdkNormalEvent_show_game_over"})
- self:removeFromParent()
- end, 0.1)
- end
-
- function PdkGameResult:onClickSure( sender )
- playBtnEffect()
- app.room:dispatchEvent({name = "pdkNormalEvent_show_game_over"})
- self:removeFromParent()
- end
-
- function PdkGameResult:createItem( info )
- local node = loadUI("pk_luzhoupdk/res/ui/ui_room/ui_lzpdk_xiaojuitem.ui")
- autoAdapt(node)
- self.startX = 1
- self.curCardNum = 0
- node.Items.Layout_card:removeAllChildren()
- node.Items.ImageView_line:setVisible(false)
- node.Items.ImageView_flag:setVisible(false)--黑关(13张) 小关(10-12张)
- node.Items.txtNick:setString(getSubStringNickname(info.nickname or ""))
- node.Items.txtID:setString("ID:"..info.userId)
-
- --显示隐藏游戏内选手id(主办人和管理员不限制,只针对海选赛) -- todo lwq
- -- begin
- local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
- if app.club_php.clubID and app.club_php.clubID ~= 0 then
- if app.club_php:getCestIsOpen(app.club_php.clubID) then
- --隐私数据
- local clubInfo = app.club_php.clubList[app.club_php.clubID]
- self.cliext = clubInfo.groupext and clubInfo.groupext.cliext
- if not self.cliext or not self.cliext.is_hideUid or (self.cliext and self.cliext.is_hideUid == 1) then
- if clubInfo.role == ClubDefine.Job.Creator or clubInfo.role == ClubDefine.Job.Manager then
- node.Items.txtID:setVisible(true)
- else
- node.Items.txtID:setVisible(false)
- end
- end
- end
- end
- if info.userId == tonumber(app.user.loginInfo.uid) then
- node.Items.txtID:setVisible(true)
- end
- -- end
-
- node.Items.txtLeft:setString("剩牌:"..info.leftNum)
- local bombinfo = string.format("炸弹:%d/%d",info.bombTimes,info.allBombTimes)
- node.Items.txtBomb:setString(bombinfo)
- setPlayerHeadImage(info.userId, info.headimgurl, node.Items.imgHead)
- if info.turnScore > 0 then--win
- --node.Items.ImageView:loadTexture("pdk_gameresult_img_yellow_bg.png", 1)
- node.Items.ImageView:setVisible(true)
- local txtColor = cc.c3b(255, 228, 128)
- --node.Items.txtLeft:setColor(txtColor)
- --node.Items.txtBomb:setColor(txtColor)
- --node.Items.txtScore:setColor(txtColor)
- local fntConfg = node.Items.txtLeft:getFontConfig()
- fntConfg.effectColor = {a=255, r=132, g=59, b=11}
- node.Items.txtLeft:setFontConfig(fntConfg)
- node.Items.txtBomb:setFontConfig(fntConfg)
- node.Items.txtScore:setText("+"..info.turnScore)
- else
- --node.Items.ImageView:loadTexture("pdk_gameresult_img_blue_bg.png", 1)
- node.Items.ImageView:setVisible(false)
- local fntConfg = node.Items.txtLeft:getFontConfig()
- node.Items.txtScore:setFntFile("res/fonts/dt_jian_num.fnt")
- node.Items.txtScore:setText(""..info.turnScore)
- end
- local groupCard = string.split(info.groupCardInfo,",")
- for i,v in pairs(groupCard) do
- local tgcard = string.split(v," ")
- self:showCards(node,tgcard,true)
- end
- --local leftCard = string.split(info.handCards," ")
- local leftCardNum = 0
- if info.leftCards and #info.leftCards > 0 then
- self:showCards(node,info.leftCards,false,true)
- leftCardNum = #info.leftCards
- elseif info.handCards and #info.handCards > 0 then
- self:showCards(node,info.handCards,false,true)
- leftCardNum = #info.handCards
- end
- local isDismiss = true--是否是解散的
- if app.room.dismissInfo and next(app.room.dismissInfo) ~= nil then
- for i,v in pairs(app.room.dismissInfo) do
- if v>2 then
- isDismiss = false
- break
- end
- end
- else
- isDismiss = false
- end
- if not isDismiss then
- if leftCardNum == 13 then
- node.Items.ImageView_flag:setVisible(true)
- node.Items.ImageView_flag:loadTexture("lzpdk_xiaoju_heiguan.png", 1)
- elseif leftCardNum <= 12 and leftCardNum >= 10 then
- node.Items.ImageView_flag:setVisible(true)
- end
- end
-
-
- return node
- end
-
- function PdkGameResult:createItemWithNoPlayer( info )
- local node = loadUI("pk_luzhoupdk/res/ui/ui_room/ui_lzpdk_xiaojuitem.ui")
- self.startX = 1
- self.curCardNum = 0
- node.Items.Layout_card:removeAllChildren()
- node.Items.ImageView_line:setVisible(false)
- node.Items.ImageView_flag:setVisible(false)--黑关(13张) 小关(10-12张)
- node.Items.txtNick:setVisible(false)
- node.Items.txtID:setVisible(false)
- node.Items.txtLeft:setVisible(false)
- node.Items.txtBomb:setVisible(false)
- node.Items.ImageView:setVisible(false)
- node.Items.txtScore:setVisible(false)
- node.Items.imgHead:setVisible(false)
-
- if #info > 0 then
- self:showCards(node,info,false,true)
- end
-
-
- return node
- end
-
- function PdkGameResult:showCards(node,data,isShowLine,isGray)
- if not data then return end
- local num = table.nums(data)
- for dipaiK,dipaiV in pairs(data) do
- local cardImg = cc.ImageView:createNode();
- cardImg:setAnchorPoint(cc.p(0,0));
- if dipaiV and dipaiV ~= "" then
- local fileName = pokerPng(dipaiV)
- cardImg:loadTextureFromPlist(fileName);
- cardImg:setScale(0.35)
- local x = self.startX + self.curCardNum*50
- local tarPos = cc.p(x ,7)
- cardImg:setPosition(tarPos);
- node.Items.Layout_card:addChild(cardImg);
- if num > 1 and isShowLine and true == isShowLine then
- isShowLine = false
- local imgaeLine = node.Items.ImageView_line:getCopied()
- imgaeLine:setSize(cc.size((num-1)*50,10))
- imgaeLine:setPosition(x+25,90)
- node.Items.Layout_card:addChild(imgaeLine)
- end
- if isGray and true == isGray then
- cardImg:setColor(cc.c3b(0xb3, 0xaa, 0xaa))--DOWN_COLOR
- end
-
- self.curCardNum = self.curCardNum + 1
- end
- end
- end
-
- return PdkGameResult
-
- --[[
-
-
- --[[
- "self._data" = {
- "bankSeatId" = 0
- "gameStartCount" = 1
- "leftCards" = {
- 1 = 12
- 2 = 24
- 3 = 9
- 4 = 53
- 5 = 44
- 6 = 4
- 7 = 58
- 8 = 10
- 9 = 61
- 10 = 5
- 11 = 56
- 12 = 23
- 13 = 37
- 14 = 8
- 15 = 25
- 16 = 54
- }
- "players" = {
- 1 = {
- "bSpring" = 0
- "bombTimes" = 0
- "haveRedTen" = 0
- "totalScore" = 9
- "turnScore" = 9
- "userId" = 1023496
- "leftNum"
- }
- 2 = {
- "bSpring" = 0
- "bombTimes" = 0
- "haveRedTen" = 0
- "totalScore" = -9
- "turnScore" = -9
- "userId" = 1023544
- "leftNum"
- }
- }
- "totalGamenum" = 10
- }
- ]]
|