|
- -- 总结算界面
- local ZPFunc = ZPFramework.ZPImport("zp_base.luaScript.ZPFunctions")
- local ZPWanFa=ZPFramework.ImportWanFa("luaScript.SubGameDefine.ZiPai.ZPWanFa")
- local ZPDef = ZPFramework.ZPImport("zp_base.luaScript.ZPDef")
-
- local ZPRoomCountAllView = class("ZPRoomCountAllView", cc.UIView)
-
- function ZPRoomCountAllView:ctor(response,endTime)
- ZPRoomCountAllView.super.ctor(self);
-
- self.response = response
- self.endTime = endTime
- end
-
-
- function ZPRoomCountAllView:loadUI()
- local ui = loadUI("zp_base/res/ui/ui_fangjian/zipai_ui_daju.ui");
- self.ui = ui;
- self:addChild(ui);
- end
-
- function ZPRoomCountAllView:onEnter()
- ZPRoomCountAllView.super.onEnter(self)
- local config = getSubGameConfig(ZPDef.GameID or app.gameId)
- setShowCountAll(true);
- self:loadUI()
-
- self.ui.Items.Layout_1:setTouchEnabled(true)
- -- 关闭
- self.ui.Items.Button_Sure:registerClick(handler(self , self.onClickClose))
- -- 防封群分享
- self.ui.Items.Button_ffqShare:registerClick(handler(self , self.onClickFFQShare))
-
- -- 分享,如果没安装微信则不展示分享按钮
- local showShare = app.plugin:isShowThirdLogin() or false
- self.ui.Items.Button_Share:registerClick(handler(self , self.onClickShare))
- if not showShare then
- self.ui.Items.Layout_5:setVisible(false);
- end
- if not app.config.ModuleConfig.IsSupportZhanJiUrl then
- self.ui.Items.Layout_8:setVisible(false)
- end
- if isReviewVersion() then
- self.ui.Items.Layout_8:setVisible(false)
- self.ui.Items.Layout_5:setVisible(false);
- end
- --两个连打才有的按钮功能先屏蔽
- self.ui.Items.Layout_7:setVisible(false);--结束离开
- self.ui.Items.Layout_3:requestDoLayout()
- self.ui.Items.Layout_3:doLayout();
- self.ui.Items.Layout_3:setVisible(false);
- self.ui.Items.ImageView_tip:setVisible(false)--再玩一轮提示隐藏
-
- local roomInfo = app.room.roomInfo
-
- --房间玩法
- --local ruleAll = ZPWanFa.getRuleInfo(roomInfo.strGameInfo)
- local newRule = "" ..ZPDef.GameName
- newRule = newRule.." 房间号:"..tostring(roomInfo.nShowTableId)
- local curCount = roomInfo.nGameStartCount or 0
- local str = string.format("%02d/%02d局", curCount, roomInfo.nTotalGameNum)
- newRule = newRule.." "..str
- self.ui.Items.Text_Rule:setText(newRule)
-
- -- 设置房间号和开始时间
- --[[ local tableId = roomInfo.nShowTableId
- self.ui.Items.Text_RoomNum:setText("房号:"..tableId)--]]
- if app.club_php.clubID and app.club_php.clubID ~= 0 then
- self.ui.Items.Text_RoomNum:setText((app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_NAME).."ID:"..app.club_php.clubID)
- else
- self.ui.Items.Text_RoomNum:setText("")
- end
- --self.ui.Items.Text_Time:setText(os.date("%Y-%m-%d %X"))--用服务器发的时间
- self.ui.Items.Text_Time:setText(os.date("%Y-%m-%d %X",app.room.roomInfo.endtime))
-
- --分数uid,标志
- -- 玩家头像
- self.headSize = {}
- self.headSize.width = self.ui.Items.ImageView_head_1:getContentSize().width;
- self.headSize.height = self.ui.Items.ImageView_head_1:getContentSize().height;
-
- self:setAllDaYingJiaVisible(false)
- --找到大赢家的分数
- local dayingjiaScore = 0
- for nUserId,totalData in pairsByKeys(self.response) do
- totalData.nTotalScore = tonumber(totalData.nTotalScore)
- if totalData.nTotalScore > dayingjiaScore then
- dayingjiaScore = totalData.nTotalScore
- end
- end
- local index = 1
- for nUserId,totalData in pairsByKeys(self.response) do
- -- 玩家头像 名字
- local userInfo = app.room:getUserInfo(nUserId)
- local name = string.format("Text_Name_%d",index)
- local uid = string.format("Text_ID_%d",index)
- local head = string.format("ImageView_head_%d",index)
- local headBg = string.format("ImageView_head_bg_%d",index)
- local infoBg = string.format("ImageView_bg_%d",index)
- local beizi = string.format("ImageView_Bei_%d",index)
- local roomer = string.format("ImageView_roomer_%d",index)
- local leftDia = string.format("Text_Diamond_%d",index)
- local yingLight = string.format("ImageView_light_%d",index)
-
- --胡牌次数
- local hupaiTimes = string.format("Text_count_hp_%d",index)
- --点炮
- local dpTimes = string.format("Text_count_dp_%d",index)
- --连庄
- local lzTimes = string.format("Text_count_zz_%d",index)
- --分数
- local score = string.format("TextBMFont_Score_%d",index)
-
-
- --头像
- local nickname = ""
- if userInfo and userInfo.nickname then
- nickname = getSubStringNickname(userInfo.nickname)
- self:updateUserHead(self.ui.Items[head],nUserId, userInfo.sex, userInfo.headimgurl);
- end
-
- self.ui.Items[name]:setText(nickname)
-
- local totalScore = tonumber(totalData.nTotalScore)
-
- --分数
- if totalScore >= 0 then
- --self.ui.Items[infoBg]:loadTextureFromPlist("zipai_daju_win_bg.png")
- --self.ui.Items[headBg]:loadTextureFromPlist("zipai_daju_win_img.png")
- self.ui.Items[score]:setText(tostring("+"..totalScore))
- self.ui.Items[score]:setFntFile("res/fonts/dt_jia_num.fnt")--("zp_base/res/ui/zy_fangjian/jia_num.fnt")
- else
- --self.ui.Items[infoBg]:loadTextureFromPlist("zipai_daju_lose_bg.png")
- --self.ui.Items[headBg]:loadTextureFromPlist("zipai_daju_lose_img.png")
- self.ui.Items[score]:setText(tostring(totalScore))
- self.ui.Items[score]:setFntFile("res/fonts/dt_jian_num.fnt")--("zp_base/res/ui/zy_fangjian/jian_num.fnt")
- end
- if totalScore == dayingjiaScore then
- self.ui.Items[beizi]:setVisible(true)
- self.ui.Items[yingLight]:setVisible(true)
- end
-
- --uid
- self.ui.Items[uid]:setText("ID:"..tostring(nUserId))
-
- --显示隐藏游戏内选手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
- self.ui.Items[uid]:setVisible(true)
- else
- self.ui.Items[uid]:setVisible(false)
- end
- end
- end
- end
- if nUserId == tonumber(app.user.loginInfo.uid) then
- self.ui.Items[uid]:setVisible(true)
- end
- -- end
-
- --显示房主
- if app.room.roomInfo.nRoomOwnedUid ~= nUserId then
- self.ui.Items[roomer]:setVisible(false)
- end
- self.ui.Items[roomer]:setVisible(false)--隐藏房主
- --用户金币信息 如"120,80,10"表示历史房卡数量为120,当前房卡数量80,金币10
- if totalData.propertyInfo then
- local ppInfo = string.split(totalData.propertyInfo, ",")
- --self.ui.Items[leftDia]:setText(ppInfo[2])
- end
-
- if totalData.nTextJson then
- local dataJson = json.decode(totalData.nTextJson)
- --消耗房卡数
- if dataJson and dataJson.DeInfo then
- self.ui.Items[leftDia]:setText("-"..dataJson.DeInfo)
- end
- --[[--胡牌次数
- self.ui.Items[hupaiTimes]:setText(tostring(dataJson.hupaiCnt))
- --中庄
- self.ui.Items[lzTimes]:setText(tostring(dataJson.zhongBankCnt))
- --点炮次数
- self.ui.Items[dpTimes]:setText(tostring(dataJson.dianPaoCnt))--]]
- end
-
- index = index + 1
- end
-
- if app.room:getActualPlayerNum() == 3 then
- self.ui.Items.Layout_player_4:setVisible(false)
- self.ui.Items.Layout_Player:doLayout()
- self.ui.Items.Layout_Player:requestDoLayout()
- elseif app.room:getActualPlayerNum() == 2 then
- self.ui.Items.Layout_player_3:setVisible(false)
- self.ui.Items.Layout_player_4:setVisible(false)
- self.ui.Items.Layout_Player:doLayout()
- self.ui.Items.Layout_Player:requestDoLayout()
- end
-
- self:initPlayGameAgain()
- end
- ---
- -- 初始化大结算再来一局
- -- @return
- --
- function ZPRoomCountAllView:initPlayGameAgain ()
- local roomInfo = app.room.roomInfo or {};
- local gameId = roomInfo.gameId or app.gameId
- if dd.IClub.isInClub() and roomInfo.nShowTableId then
- local inviteList = {}
- for k,v in pairsByKeys(roomInfo.memberList) do
- if tonumber(v.nUserId) ~= app.user.loginInfo.uid then
- table.insert(inviteList, v.nUserId)
- end
- end
-
- local strInvite = ZPFunc.getClubInviteWanFa(gameId, roomInfo)
- local btnPlayAgain = self.ui.Items.Button_Play
- dd.IPlayGameAgain.bindPlayAgainButton(btnPlayAgain, gameId, strInvite, inviteList, function ()
- -- 初始化成功后干嘛干嘛
- local visible = btnPlayAgain:isVisible()
- self.ui.Items.Layout_6:setVisible(visible)
- if self.ui.Items.Layout_3 then
- self.ui.Items.Layout_3:requestDoLayout()
- self.ui.Items.Layout_3:doLayout()
- end
- end)
- --绑定消息通知回调
- self:bindEvent(app.club_php , GAME_EVENT.CLUB_INVITE , handler(self , self.onClubInviteEvent))
- else
- logD("ZPRoomCountAllView:initPlayGameAgain", "不在亲友圈或桌子id为空,不能进行再来一局操作")
- if self.ui.Items.Layout_6 then
- self.ui.Items.Layout_6:setVisible(false)
- end
- if self.ui.Items.Layout_3 then
- self.ui.Items.Layout_3:requestDoLayout()
- self.ui.Items.Layout_3:doLayout()
- end
- end
- end
- ---
- -- 监听亲友圈邀请信息
- -- @param event
- -- @return
- --
- function ZPRoomCountAllView:onClubInviteEvent(event)
- dd.IPlayGameAgain.showClubInviteDialog(event, nil, nil)
- end
-
- --设置所有大赢家visible
- function ZPRoomCountAllView:setAllDaYingJiaVisible(vis)
- for i = 1,4 do
- local beizi = string.format("ImageView_Bei_%d",i)
- local yingLight = string.format("ImageView_light_%d",i)
- if self.ui.Items[beizi] then
- self.ui.Items[beizi]:setVisible(vis)
- end
- if self.ui.Items[yingLight] then
- self.ui.Items[yingLight]:setVisible(vis)
- end
- end
- end
-
- function ZPRoomCountAllView:playAni()
- --判断大赢家和土豪
- local tuhaoScore = -999999
- local winerScore = -999999
- local tt = {}
- --排除都为0的情况
- local zeorNum = 0
- for k,v in pairs(self.response) do
- if v.nTotalScore == 0 then
- zeorNum = zeorNum + 1
- end
- end
-
- local maxPeople = table.nums(self.response)
-
- if zeorNum ~= maxPeople then
- for k,v in pairs(self.response) do
- table.insert(tt,v.nTotalScore)
- end
- local function sortFunc(a,b)
- return a < b
- end
- table.sort(tt,sortFunc)
- tuhaoScore = tt[1]
- winerScore = tt[maxPeople]
- end
-
- self:setAllDaYingJiaVisible(false)
- local index = 1
- for nUserId,totalData in pairsByKeys(self.response) do
- if (not (tolua.type(app.room.isLianDa) == "function")) or (tolua.type(app.room.isLianDa) == "function" and app.room:checkUserIDIsInTable(nUserId)) then
- -- 玩家头像 名字
- local beizi = string.format("ImageView_Bei_%d",index)
- local yingLight = string.format("ImageView_light_%d",index)
- local nodePlayer = string.format("Layout_player_%d",index)
- local totalScore = totalData.nTotalScore
- --分数
- if totalScore == winerScore then
- local tarPos = cc.pAdd(self.ui.Items[beizi]:getPosition(),cc.p(0,30))
- self.ui.Items[beizi]:setScale(3)
- self.ui.Items[beizi]:setOpacity(0)
- local mSpawn = cc.Spawn:create(cc.ScaleTo:create(0.2,1.0),cc.FadeIn:create(0.2))
- local seq = cc.Sequence:create(cc.DelayTime:create(0.15 * 5),mSpawn)
- self.ui.Items[beizi]:runAction(seq)
- self.ui.Items[beizi]:setVisible(true)
- if self.ui.Items[yingLight] then
- self.ui.Items[yingLight]:setVisible(true)
- end
- else
- self.ui.Items[beizi]:setVisible(false)
- if self.ui.Items[yingLight] then
- self.ui.Items[yingLight]:setVisible(false)
- end
- end
-
- self.ui.Items[nodePlayer]:setOpacity(0)
-
-
- local mSpawn = cc.Spawn:create(cc.MoveBy:create(0.2,cc.p(0,120)),cc.FadeIn:create(0.2))
- local seq = cc.Sequence:create(cc.DelayTime:create(0.15 * index),cc.CallFunc:create(function ()
- self.ui.Items[nodePlayer]:setPositionY(self.ui.Items[nodePlayer]:getPositionY() - 120)
- end),mSpawn)
- self.ui.Items[nodePlayer]:runAction(seq)
-
- index = index + 1
- end
- end
-
- local seq = cc.Sequence:create(cc.DelayTime:create(0.35*index),cc.CallFunc:create(function ()
- self.ui.Items.Layout_3:setVisible(true);
- end))
- self.ui:runAction(seq)
- end
-
- function ZPRoomCountAllView:onExit()
- ZPRoomCountAllView.super.onExit(self);
- setShowCountAll(false);
- end
-
- -- 关闭
- function ZPRoomCountAllView:onClickClose()
- app.room:dispatchEvent({name = "onGameOverResponse"});
- self:removeFromParent()
- runInNextFrame(function()
- local roomInfo = app.room.roomInfo
-
- -- 房间号
- local roomId = roomInfo.nShowTableId
- gotoMainView(app.gameId,roomId)
- end)
- end
-
- -- 防封群分享
- function ZPRoomCountAllView:onClickFFQShare()
- app.waitDialogManager:showWaitNetworkDialog("获取分享链接")
- local onGetUrlCallback = function(url)
- app.waitDialogManager:closeWaitNetworkDialog()
- if url then
- local imagePath = cc.FileUtils:getInstance():getWritablePath().."icon.png"
- local gameName = getSubGameName(app.gameId) or "川南棋牌"
-
- local info = {}
- -- info.contentType = "image"
- info.image = fileName
- info.title = gameName.."战绩"
- -- info.imageWidth = 800
- info.menuIdxs = {1, 4, 5, 6}
- -- info.isShareZhanjiUrl = false
- info.copyData={
- type=1,
- tableId=app.room.roomInfo.nShowTableId,
- userInfos={},
- }
- local content = nil;
- local memberList = app.room.roomInfo.memberList--self._overData.nTotalPlayerInfos
-
- for k,v in pairs(self.response) do
- local userInfo = app.room:getUserInfo(k)
- --昵称
- local nickname = userInfo.nickname or ""
- local totalScore = v.nTotalScore or v.nTotalMoney
- table.insert(info.copyData.userInfos,{nickname=nickname,totalScore=totalScore})
-
- local strUserInfo = ""
- if totalScore > 0 then
- strUserInfo = string.format("%s(+%s)", getShortName(nickname), totalScore)
- else
- strUserInfo = string.format("%s(%s)", getShortName(nickname), totalScore)
- end
- if content then
- content = content .. "," .. strUserInfo
- else
- content = strUserInfo
- end
- end
-
- local sharUrl = string.format("%s?uid=%s&gameid=%s&app=%s&roomid=%s&endtime=%s",
- url,
- app.user.loginInfo.uid,
- app.gameId,
- getAppId(),
- app.room.roomInfo.nShowTableId,
- os.time())
- info.url = sharUrl
- info.description = content
- dump(info)
- local view = import("luaScript.Views.Main.ShareView"):new(info)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- else
- showTooltip("获取分享用的链接失败")
- end
- end
- app.php:initShareZhanJiToUrl(onGetUrlCallback)
- end
-
- -- 分享
- function ZPRoomCountAllView:onClickShare()
- local fileName = cc.FileUtils:getInstance():getWritablePath()..tostring(app.room.roomInfo.nShowTableId).."_screen.jpg"
-
- cc.FileUtils:getInstance():screenToFile(fileName, function(ret)
- if 1 == tonumber(ret) then
- local info = {}
- info.contentType = "image"
- info.image = fileName
- info.imageWidth = 800
- info.isShareZhanjiUrl = true
-
- info.copyData={
- type=1,
- tableId=app.room.roomInfo.nShowTableId,
- userInfos={},
- gameId = ZPDef.GameID or app.gameId,
- }
-
- for nUserId,totalData in pairsByKeys(self.response) do
- local userInfo = app.room:getUserInfo(nUserId)
- --昵称
- local nickname = userInfo.nickname or ""
- local totalScore = totalData.nTotalScore
- table.insert(info.copyData.userInfos,{nickname=nickname,totalScore=totalScore})
- end
-
- local view = import("luaScript.Views.Main.ShareView"):new(info)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- else
- showTooltip("截图保存失败");
- end
- end);
- end
-
-
- function ZPRoomCountAllView:updateUserHead(nodeHead,nUserId, sex, headimgurl)
- setPlayerHeadImage(nUserId,headimgurl,nodeHead)
- end
-
- return ZPRoomCountAllView;
|