-- 单局战绩单元Layout local ClubZhanJiDanjuItem = class("ClubZhanJiDanjuItem") function ClubZhanJiDanjuItem:ctor(gameRule, zhanjiInfo, detail, endTime, idx, tableIdx) self.gameRule = gameRule; self.zhanjiInfo = zhanjiInfo self.detail = detail --logD("idx:",idx) --logD("detail.endtime :",detail.endtime) --logD("endTime :",endTime) self.endTime = detail.endtime or endTime --logD("self.endTime :",self.endTime) self.idx = idx self.gameid = self.zhanjiInfo.gameid --从房间返回茶馆的桌子标识 self.tableIdx = tableIdx self.ui = loadUI("res/ui/ui_club/ui_club_zhanji_danju_item.ui") autoAdaptWidth(self.ui) self.ui.Items.Layout_player:setVisible(false) self:initView() end function ClubZhanJiDanjuItem:initView() -- 回放 self.ui.Items.Button_record:registerClick(handler(self, self.onClickRecord)); --隐藏下拉按钮 self.ui.Items.Button_down:setVisible(false) self.ui.Items.Button_up:setVisible(false) self.ui.Items.ImageView_Flag:setVisible(false) --积分 self:showScoreCount(); -- 时间 local time = os.date("%Y-%m-%d %H:%M",self.endTime) --logD("time:",time) local timeInfo = time; self.ui.Items.Text_time:setText(timeInfo) self.ui.Items.TextBMFont_num:setText(tonumber(self.idx)) end --输赢分数 function ClubZhanJiDanjuItem:showScoreCount() local isMe = false; -- 0=正常结束 1=吃臭牌 2=吃牌不比 3=无牌赔包子 4=胡臭牌 7=黄庄 8=长时间自动解散 9=解散游戏 , 如果为0、8、9则表示正常结束 local endFlag = self.detail.flag if endFlag == 8 or endFlag == 9 then self.ui.Items.ImageView_Flag:setVisible(true) elseif endFlag == 22 then--管理解散 self.ui.Items.Text_disbandUids:setText('解散人: ' .. self.detail.ext.disbandUids) end if endFlag == 8 then self.ui.Items.Text_disbandUids:setText('房间占用超时解散') end local jiesanInfo if self.detail.ext and self.detail.ext.disbandStatus then jiesanInfo = self.detail.ext.disbandStatus elseif self.detail.ext and self.detail.ext.jiesan then jiesanInfo = self.detail.ext.jiesan end local extUidInfo if self.detail.ext and self.detail.ext.disbandUids then extUidInfo = self.detail.ext.disbandUids end local uiTemplate = self.ui.Items.Layout_player; local contentSize = self.ui.Items.Layout_score:getContentSize(); local scoreList = self.detail.score local scoreSize = table.nums(scoreList) local gameConfig = getSubGameConfig(self.gameid) or {} for uid,score in pairsByKeys(scoreList) do local uiItem = uiTemplate:getCopied() uiItem:setSize(cc.size(contentSize.width / scoreSize, contentSize.height)) uiItem.Items = getUIItems(uiItem) if gameConfig.isUseDivision10 then score = score / 10 end if score > 0 then score = "+"..tostring(score) uiItem.Items.Text_score:setFntFile("res/fonts/zhanji_win.fnt") else uiItem.Items.Text_score:setFntFile("res/fonts/zhanji_lose.fnt") end uiItem.Items.Text_score:setText(score) --名字 local playerInfo = app.playerInfoManager:getPlayerInfo(uid); if playerInfo then local len = string.len(playerInfo.name) if len == 0 then playerInfo.name = "未知昵称" end playerInfo.name = getSubStringNickname(playerInfo.name) uiItem.Items.Text_player_name:setText(playerInfo.name) --战绩用户列表中是否有自己 if tonumber(uid) == app.user.loginInfo.uid then isMe = true; end end if endFlag == 9 and jiesanInfo then uiItem.Items.Text_jiesanInfo:setVisible(true) if jiesanInfo[uid] and jiesanInfo[uid] == 0 then uiItem.Items.Text_jiesanInfo:setText("超时解散") uiItem.Items.Text_jiesanInfo:setColor(cc.c3b(0,255,0)) elseif jiesanInfo[uid] and jiesanInfo[uid] == 1 then uiItem.Items.Text_jiesanInfo:setText("申请解散") uiItem.Items.Text_jiesanInfo:setColor(cc.c3b(255,0,0)) elseif jiesanInfo[uid] and jiesanInfo[uid] == 2 then uiItem.Items.Text_jiesanInfo:setText("同意解散") uiItem.Items.Text_jiesanInfo:setColor(cc.c3b(0,255,0)) elseif jiesanInfo[uid] and jiesanInfo[uid] == 3 then uiItem.Items.Text_jiesanInfo:setText("拒绝解散") end elseif endFlag == 8 then--系统解散 uiItem.Items.Text_jiesanInfo:setVisible(true) uiItem.Items.Text_jiesanInfo:setText("系统解散") uiItem.Items.Text_jiesanInfo:setColor(cc.c3b(255,0,0)) elseif endFlag == 10 then--托管解散 local autoDisArr = string.split(extUidInfo,";") or {} if table.indexOf(autoDisArr, uid) >= 0 then uiItem.Items.Text_jiesanInfo:setVisible(true) uiItem.Items.Text_jiesanInfo:setText("托管解散") uiItem.Items.Text_jiesanInfo:setColor(cc.c3b(255,0,0)) else uiItem.Items.Text_jiesanInfo:setVisible(false) end elseif endFlag == 23 then--房卡不足 uiItem.Items.Text_jiesanInfo:setVisible(true) uiItem.Items.Text_jiesanInfo:setText("房卡不足") uiItem.Items.Text_jiesanInfo:setColor(cc.c3b(255,0,0)) elseif endFlag == 25 then--其他解散 local eliminateArr = string.split(extUidInfo,";") or {} if table.indexOf(eliminateArr, uid) >= 0 then uiItem.Items.Text_jiesanInfo:setVisible(true) uiItem.Items.Text_jiesanInfo:setText("比赛淘汰") uiItem.Items.Text_jiesanInfo:setColor(cc.c3b(255,0,0)) else uiItem.Items.Text_jiesanInfo:setVisible(false) end else uiItem.Items.Text_jiesanInfo:setVisible(false) end self.ui.Items.Layout_score:addChild(uiItem); end --如果自己不参与牌局,则不显示回放按钮 --[[if isMe then self.ui.Items.Layout_record:setVisible(true) else self.ui.Items.Layout_record:setVisible(false) end--]] self.ui.Items.Layout_btn:requestDoLayout() self.ui.Items.Layout_btn:doLayout(); end function ClubZhanJiDanjuItem:onClickRecord() playBtnEffect() local room = app.club_php:getMyInRoom(app.club_php.clubID) local view = app:getCurrentView() if room or view.__cname ~= "MainView" then showTooltip("正在游戏中,禁止查看回放") return end if self.tableIdx then --从房间切换回茶馆时,不能使用回放按钮 showTooltip("当前正在游戏中,禁止使用回放") return end if not app.subGameManager:isInstaller(tonumber(self.zhanjiInfo.gameid)) or app.subGameManager:isNeedUpdate(tonumber(self.zhanjiInfo.gameid)) then requestDownloadSubGame(tonumber(self.zhanjiInfo.gameid), function () showTooltip("下载完成") end, true) return end local pid = self.zhanjiInfo.pid local subid = self.detail.subid -- 显示加载界面,直到加载完毕 local function showZhanjiRecord() local zhanjiInfo = app.club_zhanji.zhanjiInfoList[pid] if not zhanjiInfo then logD("zhanjiInfo:"..table.tostring(zhanjiInfo)) showTooltip("回放数据不存在") return end if not zhanjiInfo.detail then logD("zhanjiInfo.detail:"..table.tostring(zhanjiInfo.detail)) showTooltip("回放数据不存在") return end local lunDetail for jushu, jushuInfo in pairs(zhanjiInfo.detail) do for lunshu, lunshuInfo in pairs(jushuInfo) do if lunshuInfo.subid == subid then lunDetail = lunshuInfo end end end if not lunDetail then logD("lunDetail:"..table.tostring(lunDetail)) showTooltip("回放数据不存在") return end --拼接字段,此字段php未下发 lunDetail.curCount = self.idx lunDetail.totalCount = self.zhanjiInfo.nbound--总局数 lunDetail.nTotalGameNum = self.zhanjiInfo.nbound--总局数(每个游戏字段定义不同) lunDetail.nbound = self.zhanjiInfo.nbound--总局数(每个游戏字段定义不同) lunDetail.roomNum = self.zhanjiInfo.roomid lunDetail.roomid = self.zhanjiInfo.roomid logD("lunDetail:"..table.tostring(lunDetail)) if not lunDetail or not lunDetail.user then showTooltip("回放数据不存在") return end if table.nums(lunDetail.user) <= 0 then showTooltip("游戏解散了") return end --[[if lunDetail.flag == 8 or lunDetail.flag == 9 then showTooltip("游戏解散了") return end--]] for uid, userInfo in pairs(lunDetail.user) do --玩家信息 local playerInfo = app.playerInfoManager:getPlayerInfo(uid) if playerInfo then userInfo.nick = playerInfo.name or "" userInfo.head = playerInfo.head or "" userInfo.sex = playerInfo.sex or 0 else userInfo.nick = "未知昵称" userInfo.head = "" userInfo.sex = 0 end --总分 userInfo.tscore = zhanjiInfo.tscore[tostring(uid)] if not userInfo.hand then showTooltip("游戏解散了") return end end local recordClass = getSubGameZhanjiRecordView(self.zhanjiInfo.gameid); if recordClass then app:changeGameProtocol(tonumber(self.zhanjiInfo.gameid), 1) local view = import(recordClass):new(lunDetail); view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end end app.club_zhanji:getZhanJiDetail(self.zhanjiInfo.pid, self.detail.subid, showZhanjiRecord) end return ClubZhanJiDanjuItem