changhong/lua_probject/extend_project/extend/poker/runfast/RunFast_ResultView.lua

234 lines
8.5 KiB
Lua
Raw Normal View History

2025-05-24 14:29:14 +08:00
---
--- Created by 谌建军.
--- DateTime: 2017/12/19 11:05
---
require("Game.View.ResultView")
local RunFast_ResultView = {}
local M = RunFast_ResultView
2026-02-04 15:07:37 +08:00
function RunFast_ResultView.new(root, data, roomid, over, win_seat, dissolve, remaincards)
setmetatable(M, { __index = ResultView })
local self = setmetatable({}, { __index = M })
2025-05-24 14:29:14 +08:00
self.class = "RunFast_ResultView"
self._currenIndex = 0
self._close_zone = false
2026-02-04 15:07:37 +08:00
self._root_runFast = root
2025-05-24 14:29:14 +08:00
self._gamectr = ControllerManager.GetController(GameController)
2026-02-04 15:07:37 +08:00
self:init("ui://Extend_Poker_RunFastNew/clearing_new", data, roomid, over, win_seat, dissolve, remaincards)
print("=======================lingmengresult", data, roomid, over, win_seat, dissolve, remaincards)
2025-05-24 14:29:14 +08:00
return self
end
function M:init(url, data, roomid, over, win_seat, dissolve, remaincards)
ResultView.init(self, url, true)
2025-05-24 14:29:14 +08:00
local room = DataManager.CurrenRoom
2026-02-04 15:07:37 +08:00
self._view:GetController('over').selectedIndex = 0
2026-02-04 15:07:37 +08:00
if over == 2 and room.curren_round <= 0 then
ViewManager.ChangeView(ViewManager.View_Lobby)
end
2026-02-04 15:07:37 +08:00
------------------
2026-02-04 15:07:37 +08:00
--只有一人直接退,有两人才进正常结算
if not over and #data == 1 then
ViewManager.ChangeView(ViewManager.View_Lobby)
end
2025-05-24 14:29:14 +08:00
2026-02-05 19:59:27 +08:00
local btn_confirm = self._view:GetChild('btn_confirm')
btn_confirm.onClick:Add(
function()
2026-02-04 15:07:37 +08:00
local _gamectr = ControllerManager.GetController(GameController)
_gamectr:ConformToNextGame()
self:Destroy()
2025-05-24 14:29:14 +08:00
end
2026-02-05 19:59:27 +08:00
)
2026-02-05 19:59:27 +08:00
local btn_Show1 = self._view:GetChild('btn_Show1')
btn_Show1.onClick:Set(function()
self._view:GetController('over').selectedIndex = 1
end)
2026-02-04 15:07:37 +08:00
self._view:GetChild('btn_closeRound').onClick:Set(function()
ViewManager.ChangeView(ViewManager.View_Lobby)
end)
2026-02-05 19:59:27 +08:00
local bgWindow = self._view:GetChild('bgWindow')
if win_seat == room.self_player.seat then
bgWindow.text = "胜利"
bgWindow:GetController('bianhui').selectedIndex = 0
else
bgWindow.text = "失败"
bgWindow:GetController('bianhui').selectedIndex = 1
end
2026-02-04 15:07:37 +08:00
2026-02-05 19:59:27 +08:00
-- self._view:GetController('win').selectedIndex = win_seat == room.self_player.seat and 1 or 0
local rt = 1
if room.hpOnOff == 1 then
rt = room.score_times
end
2026-02-04 15:07:37 +08:00
local over0List = self._view:GetChild('list_over0')
over0List:SetVirtual()
over0List.itemRenderer = function(index, obj)
local info = data[index + 1]
local playerInfo = room:GetPlayerBySeat(info.seat)
obj:GetChild('name').text = playerInfo.self_user.nick_name
obj:GetChild('residue').text = #info.handCards
obj:GetChild('bomb').text = info.thisboomnum
2026-02-05 19:59:27 +08:00
obj:GetChild('piao').text = info.piao < 0 and 0 or info.piao
local roundScore = info.winCardScore
local jifen = ""
if roundScore >= 0 then
jifen = "+" .. roundScore
else
jifen = "" .. roundScore
end
jifen = jifen .. " "
local tili = ""
if room.hpOnOff > 0 then
local need = roundScore * rt
tili = "("
if roundScore > 0 then
tili = tili .. "+" .. tostring(need)
else
tili = tili .. tostring(need)
end
tili = tili .. ")"
end
obj:GetChild('score').text = jifen .. tili
local list_residue = obj:GetChild('list_residue')
list_residue:RemoveChildrenToPool()
for i, v in ipairs(info.handCards) do
local rc = list_residue:AddItemFromPool()
rc.icon = string.format("ui://Extend_Poker_RunFastNew/%s", v)
rc:GetController('choose').selectedIndex = 0
end
for i, v in ipairs(info.outCards) do
local rc = list_residue:AddItemFromPool()
rc.icon = string.format("ui://Extend_Poker_RunFastNew/%s", v)
rc:GetController('choose').selectedIndex = 1
end
2025-05-24 14:29:14 +08:00
end
2026-02-04 15:07:37 +08:00
over0List.numItems = #data
if over == 1 or (over == 2 and room.curren_round > 0) then
2026-02-05 19:59:27 +08:00
self._view:GetController('lastRound').selectedIndex = 1
self._view:GetChild('txt_room_id').text = '房号:' .. roomid
self._view:GetChild('txt_game_name').text = room.room_config:GetGameName()
self._view:GetChild('txt_game_data').text = os.date('%Y-%m-%d %H:%M', os.time())
local str_roominfo = string.gsub(room.room_config:GetDes(), '\r', '')
self._view:GetChild('txt_play').text = str_roominfo
2026-02-04 15:07:37 +08:00
for i = 1, #data do
local info = data[i]
local playerInfo = room:GetPlayerBySeat(info.seat)
2026-02-05 19:59:27 +08:00
self:FillPlayerInfoEnd(self._view:GetChild(string.format("comp_playerInfo%d_over1", i)), info, playerInfo, rt,
bgWindow)
end
2026-02-07 16:18:01 +08:00
end
local list_residue = self._view:GetChild('list_residue')
list_residue:RemoveChildrenToPool()
if remaincards then
2026-02-05 19:59:27 +08:00
for i, v in ipairs(remaincards) do
local rc = list_residue:AddItemFromPool()
rc.icon = string.format("ui://Extend_Poker_RunFastNew/%s", v)
2026-02-04 15:07:37 +08:00
end
2025-05-24 14:29:14 +08:00
end
2026-02-04 15:07:37 +08:00
local Btn_Share = self._view:GetChild('btn_shareRecord')
if Btn_Share then
Btn_Share.onClick:Set(function()
self:SaveRenderTextureToPNG()
end)
2025-05-24 14:29:14 +08:00
end
2026-02-04 15:07:37 +08:00
local Btn_Copy = self._view:GetChild('btn_copyRecord')
if Btn_Copy then
Btn_Copy.onClick:Set(function()
local resultStr = ""
if room.group_id ~= 0 then
local group = DataManager.groups:get(room.group_id)
resultStr = string.format("【%s】俱乐部", group.name)
end
resultStr = string.format("%s%s\n", resultStr, room.game_info.name)
for i = 1, #data do
local info = data[i]
local playerInfo = room:GetPlayerBySeat(info.seat)
resultStr = string.format("%s%s\nID:%s【%s】\n", resultStr, playerInfo.self_user.nick_name,
playerInfo.self_user.account_id,
info.total_score)
end
resultStr = string.format("%s房号:%s 局数:%s/%s局\n结束时间:%s", resultStr, room.room_id, room.curren_round,
room.room_config.Times, os.date("%Y-%m-%d %H:%M:%S", os.time()))
ViewUtil.__openWx()
GameApplication.Instance:CopyToClipboard(resultStr)
end)
2025-05-24 14:29:14 +08:00
end
2026-02-05 19:59:27 +08:00
local btn_continue_game = self._view:GetChild('btn_continue_game')
if btn_continue_game then
local gid = room.group_id
if gid ~= 0 then
btn_continue_game.visible = true
local pid = room.room_config.pid
local game_id = room.game_id
btn_continue_game.onClick:Set(
function()
self:ContinueGame(gid, pid, game_id)
end
)
end
end
2025-05-24 14:29:14 +08:00
end
2026-02-06 23:33:30 +08:00
function M:FillPlayerInfoEnd(view, info, playerInfo, rt, bgWindow)
2026-02-04 15:07:37 +08:00
local room = DataManager.CurrenRoom
2026-02-04 15:07:37 +08:00
ImageLoad.Load(playerInfo.self_user.head_url, view:GetChild('btn_head')._iconObject)
view:GetChild('text_name').text = ViewUtil.stringEllipsis(playerInfo.self_user.nick_name)
2026-02-05 19:59:27 +08:00
view:GetChild('text_ID').text = playerInfo.self_user.account_id
local detailList = view:GetChild('list_detail')
self:FillDetailChild(detailList:AddItemFromPool(), "赢局数:", info.settle_log.winnum)
self:FillDetailChild(detailList:AddItemFromPool(), "打出炸弹数:", info.settle_log.boomnum)
self:FillDetailChild(detailList:AddItemFromPool(), "春天次数:", info.settle_log.springnum)
self:FillDetailChild(detailList:AddItemFromPool(), "当局最高分:", info.settle_log.maxscore * rt)
view:GetChild('text_daniao').text = info.daniao
view:GetChild('text_toltalScore').text = info.total_score
view:GetChild('text_score').text = info.total_score - info.daniao
view:GetController('win').selectedIndex = info.total_score >= 0 and 1 or 0
if info.seat == room.self_player.seat and info.total_score >= 0 then
bgWindow.text = "胜利"
bgWindow:GetController('bianhui').selectedIndex = 0
else
bgWindow.text = "失败"
bgWindow:GetController('bianhui').selectedIndex = 1
end
2026-02-04 15:07:37 +08:00
end
2026-02-04 15:07:37 +08:00
function M:FillDetailChild(view, index, value)
2026-02-05 19:59:27 +08:00
view:GetChild('text_title').text = index
2026-02-04 15:07:37 +08:00
view:GetChild('text_value').text = value
end
2026-02-04 15:07:37 +08:00
function M:SetDestroryCallback(fct)
self._destoryCallback = fct
end
2026-02-04 15:07:37 +08:00
function M:Destroy()
if self._destoryCallback then
self._destoryCallback()
end
2026-02-04 15:07:37 +08:00
getmetatable(M).__index.Destroy(self)
end
2025-05-24 14:29:14 +08:00
return M