553 lines
20 KiB
Lua
553 lines
20 KiB
Lua
---
|
||
--- Created by 谌建军.
|
||
--- DateTime: 2017/12/19 11:05
|
||
---
|
||
require("Game.View.ResultView")
|
||
|
||
local RunFast_ResultView = {}
|
||
|
||
local M = RunFast_ResultView
|
||
|
||
function RunFast_ResultView.new(blur_view, data, roomid, over, win_seat, dissolve, remaincards)
|
||
setmetatable(M, { __index = ResultView })
|
||
local self = setmetatable({}, { __index = M })
|
||
|
||
self.class = "RunFast_ResultView"
|
||
self._currenIndex = 0
|
||
self._close_zone = false
|
||
--self._blur_view = blur_view
|
||
self._gamectr = ControllerManager.GetController(GameController)
|
||
self:init("ui://Extend_Poker_RunFastNew/clearing", data, roomid, over, win_seat, dissolve, remaincards)
|
||
|
||
return self
|
||
end
|
||
|
||
function M:init(url, data, roomid, over, win_seat, dissolve, remaincards)
|
||
ResultView.init(self, url, true)
|
||
self.xiPaiCtr = self._view:GetController("xipai")
|
||
|
||
|
||
local round = DataManager.CurrenRoom.room_config.config.times or 1
|
||
local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai
|
||
if xpconfig and round > 1 then
|
||
self.xiPaiCtr.selectedIndex = 1
|
||
else
|
||
self.xiPaiCtr.selectedIndex = 0
|
||
end
|
||
|
||
|
||
--self:InitData(data,roomid)
|
||
--self:InitData(data,roomid)
|
||
printlog("aaaaaaaaaaaaaaaa1111111111111111111111111222222222222222 ", dissolve)
|
||
pt(data)
|
||
if dissolve == 1 then
|
||
-- body
|
||
self.xiPaiCtr.selectedIndex = 0
|
||
self:InitData(data, win_seat, roomid)
|
||
else
|
||
local xipai = self._view:GetChild("btn_xipai")
|
||
xipai.touchable = true
|
||
xipai.onClick:Add(function()
|
||
local xiPaiCallBack = function()
|
||
xipai.touchable = false
|
||
self.xiPaiCtr.selectedIndex = 0
|
||
local _gamectr = ControllerManager.GetController(GameController)
|
||
_gamectr:PlayerReady()
|
||
self:DestroyWithCallback()
|
||
--ViewUtil.ErrorTip(1000000, "申请洗牌成功")
|
||
end
|
||
local _gamectr = ControllerManager.GetController(GameController)
|
||
_gamectr:SendXiPaiAction(xiPaiCallBack)
|
||
end)
|
||
if DataManager.CurrenRoom.xipaiScore then
|
||
--xipai.text="洗牌 积分x"..DataManager.CurrenRoom.xipaiScore
|
||
else
|
||
--xipai.text="洗牌 积分x0"
|
||
end
|
||
|
||
self:InitData_One(data, win_seat, over, roomid, remaincards)
|
||
end
|
||
end
|
||
|
||
function M:ChangeCodeByTo(card)
|
||
local flower = card % 10
|
||
local number = math.floor(card / 10)
|
||
if number == 15 then
|
||
number = 2
|
||
end
|
||
return flower * 100 + number
|
||
end
|
||
|
||
-- 小结算
|
||
function M:InitData_One(data, winseat, over, roomid, remaincards)
|
||
local room = DataManager.CurrenRoom
|
||
self._view:GetController("sdk").selectedIndex = 1
|
||
local _gamectr = ControllerManager.GetController(GameController)
|
||
local list_view = self._view:GetChild("player_list_1")
|
||
list_view:RemoveChildrenToPool()
|
||
|
||
local leftCardAll = self._view:GetChild("leftCardHand")
|
||
leftCardAll:RemoveChildrenToPool()
|
||
|
||
if remaincards and #remaincards > 0 then
|
||
table.sort(remaincards, function(a, b)
|
||
return a % 100 < b % 100
|
||
end)
|
||
for i = 1, #remaincards do
|
||
local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. remaincards[i])
|
||
leftCardAll:AddChild(card_code_obj)
|
||
end
|
||
end
|
||
|
||
|
||
for i = 1, #data do
|
||
local player = data[i]
|
||
local item = list_view:AddItemFromPool("ui://Extend_Poker_RunFastNew/clearing_item_1")
|
||
|
||
local leftCard = item:GetChild("leftCard")
|
||
leftCard:RemoveChildrenToPool()
|
||
-- table.sort(data[i].handCards,function (a,b)
|
||
|
||
-- return a % 100 < b % 100
|
||
-- end)
|
||
|
||
for j = 1, #data[i].handCards do
|
||
local code = data[i].handCards[j]
|
||
local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. code)
|
||
leftCard:AddChild(card_code_obj)
|
||
end
|
||
|
||
-- table.sort(data[i].outCards,function (a,b)
|
||
-- return a % 100 < b % 100
|
||
-- end)
|
||
|
||
|
||
|
||
for k = 1, #data[i].outCards do
|
||
local code = data[i].outCards[k]
|
||
local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. code)
|
||
leftCard:AddChild(card_code_obj)
|
||
card_code_obj:GetChildAt(0):GetChildAt(0).color = Color(0.7, 0.7, 0.7)
|
||
end
|
||
|
||
|
||
|
||
local boom = item:GetChild("boom")
|
||
boom.text = player.thisboomnum
|
||
|
||
local piao = item:GetChild("piao")
|
||
if player.piao <= 0 then
|
||
piao.text = "0"
|
||
else
|
||
piao.text = "" .. player.piao
|
||
end
|
||
|
||
local nichen = item:GetChild("nichen")
|
||
|
||
if player.nick ~= nil then
|
||
-- body
|
||
nichen.text = tostring(player.nick)
|
||
else
|
||
nichen.text = tostring(player.self_user.nick_name)
|
||
end
|
||
|
||
|
||
local shengpai = item:GetChild("shengpai")
|
||
if player.cards ~= nil then
|
||
-- body
|
||
shengpai.text = tostring(#player.cards)
|
||
else
|
||
shengpai.text = tostring(#player.hand_list)
|
||
end
|
||
|
||
local rt = 1
|
||
if room.hpOnOff == 1 then
|
||
rt = room.score_times
|
||
end
|
||
|
||
local hp_nonnegative = room:checkHpNonnegative()
|
||
local roundScore = player.winCardScore
|
||
roundScore = roundScore or 0
|
||
if hp_nonnegative then
|
||
local jifen = ""
|
||
if roundScore > 0 then
|
||
jifen = "+" .. roundScore
|
||
else
|
||
jifen = "" .. roundScore
|
||
end
|
||
|
||
local tili = ""
|
||
local limit = ""
|
||
if player.hp_info.round_actual_hp > 0 then
|
||
-- tili = "(+" .. d2ad(player.hp_info.round_actual_hp) .. ")"
|
||
tili = "(+" .. roundScore .. ")"
|
||
if player.hp_info.upper_limit then
|
||
limit = "达到上限"
|
||
end
|
||
else
|
||
-- tili = "(" .. d2ad(player.hp_info.round_actual_hp) .. ")"
|
||
tili = "(" .. roundScore .. ")"
|
||
|
||
if player.hp_info.upper_limit then
|
||
limit = "达到下限"
|
||
end
|
||
end
|
||
|
||
item:GetChild("score").text = jifen .. tili .. limit
|
||
else
|
||
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
|
||
|
||
|
||
item:GetChild("score").text = jifen .. tili
|
||
end
|
||
|
||
if roundScore >= 0 then
|
||
if room.self_player.seat == player.seat then
|
||
-- body
|
||
self._view:GetController("result").selectedIndex = 1
|
||
item:GetController('win').selectedIndex = 1
|
||
else
|
||
item:GetController('win').selectedIndex = 0
|
||
end
|
||
else
|
||
if room.self_player.seat == player.seat then
|
||
self._view:GetController("result").selectedIndex = 0
|
||
item:GetController('win').selectedIndex = 0
|
||
else
|
||
item:GetController('win').selectedIndex = 1
|
||
end
|
||
end
|
||
end
|
||
|
||
|
||
if over == 0 then
|
||
-- body
|
||
local btn_confirm = self._view:GetChild("btn_confirm")
|
||
btn_confirm.onClick:Set(function()
|
||
self:Destroy()
|
||
local _gamectr = ControllerManager.GetController(GameController)
|
||
_gamectr:ConformToNextGame()
|
||
end)
|
||
else
|
||
self.xiPaiCtr.selectedIndex = 0
|
||
local btn_confirm = self._view:GetChild("btn_confirm")
|
||
btn_confirm.onClick:Set(function()
|
||
--self:Destroy()
|
||
self:InitData(data, winseat, roomid)
|
||
-- ViewManager.ChangeView(ViewManager.View_Lobby)
|
||
end)
|
||
end
|
||
end
|
||
|
||
-- 大结算
|
||
function M:InitData(data, winseat, roomid)
|
||
self.xiPaiCtr.selectedIndex = 0
|
||
self._view:GetController("sdk").selectedIndex = 0
|
||
|
||
local room = DataManager.CurrenRoom
|
||
|
||
local rt = 1
|
||
if room.hpOnOff == 1 and room.score_times ~= 1 then
|
||
rt = room.score_times
|
||
end
|
||
|
||
-- 赋值result_info,聊天室分享需要
|
||
local player_list = {}
|
||
for i = 1, #data do
|
||
player_list[i] = {}
|
||
|
||
local user = room:GetPlayerBySeat(data[i].seat).self_user
|
||
|
||
player_list[i].id = user.account_id
|
||
|
||
player_list[i].score = data[i].score
|
||
player_list[i].hp_info = data[i].hp_info
|
||
player_list[i].house = room.owner_id == player_list[i].id and 1 or 0
|
||
player_list[i].nick = user.nick_name
|
||
player_list[i].seat = data[i].seat
|
||
player_list[i].head_url = data[i].self_user.head_url
|
||
player_list[i].daniao = data[i].daniao
|
||
|
||
if data[i].entrust ~= nil then
|
||
player_list[i].entrust = data[i].entrust > 0
|
||
else
|
||
player_list[i].entrust = false
|
||
end
|
||
|
||
player_list[i].param = {}
|
||
|
||
player_list[i].param[1] = {}
|
||
player_list[i].param[1].key = "赢局数:"
|
||
player_list[i].param[1].value = tostring(data[i].settle_log.winnum)
|
||
|
||
player_list[i].param[2] = {}
|
||
player_list[i].param[2].key = "打出炸弹数:"
|
||
player_list[i].param[2].value = tostring(data[i].settle_log.boomnum)
|
||
|
||
player_list[i].param[3] = {}
|
||
player_list[i].param[3].key = "春天次数:"
|
||
player_list[i].param[3].value = tostring(data[i].settle_log.springnum)
|
||
|
||
player_list[i].param[4] = {}
|
||
player_list[i].param[4].key = "当局最高分:"
|
||
player_list[i].param[4].value = tostring(data[i].settle_log.maxscore * rt)
|
||
|
||
if data[i].daniao > 0 then
|
||
player_list[i].flag = { "打鸟" }
|
||
end
|
||
end
|
||
|
||
self:GenerateRoomResultInfo(room.room_config.Times, room.room_config:GetGameName(), room.room_id, room.create_time,
|
||
player_list)
|
||
self:InitBigResult(room)
|
||
local big_result = self._view:GetChild("big_result")
|
||
local lst_p = big_result:GetChild("player_list")
|
||
-- local list_param = com_p:GetChild("list_param")
|
||
for i = 1, lst_p.numChildren do
|
||
local com_p = lst_p:GetChildAt(i - 1)
|
||
local list_param = com_p:GetChild("list_param")
|
||
for j = 1, list_param.numChildren do
|
||
local tem = list_param:GetChildAt(j - 1)
|
||
tem:GetChild("txt_value").textFormat.size = 30
|
||
end
|
||
end
|
||
end
|
||
|
||
function M:InitBigResult(room, fontsize)
|
||
local big_result = self._view:GetChild('big_result')
|
||
if big_result ~= nil then
|
||
local player_list = big_result:GetChild('player_list')
|
||
player_list:RemoveChildrenToPool()
|
||
|
||
big_result:GetChild('txt_room_id').text = '房号:' .. self._resultInfo.room_id
|
||
big_result:GetChild('txt_game_name').text = self._resultInfo.game_name
|
||
big_result:GetChild('txt_game_data').text = os.date('%Y-%m-%d %H:%M', os.time())
|
||
|
||
local str_roominfo = string.gsub(room.room_config:GetDes(), '\r', '')
|
||
big_result:GetChild('txt_play').text = str_roominfo
|
||
|
||
if room.hpOnOff == 1 and room.score_times ~= 1 then
|
||
big_result:GetChild('txt_time').text = '倍数:' .. tostring(room.score_times)
|
||
big_result:GetController('time').selectedIndex = 1
|
||
end
|
||
|
||
local maxScore = 0
|
||
local isWin = false
|
||
local flag_new = big_result:GetChild('flag_tempNew')
|
||
for i = 1, #self._resultInfo.player_list do
|
||
local player_info = self._resultInfo.player_list[i]
|
||
|
||
local total_score = room:GetTotalScore(player_info.score)
|
||
local hp_nonnegative = room:checkHpNonnegative()
|
||
player_info.total_score = 0
|
||
if hp_nonnegative then
|
||
local hp_info = player_info.hp_info
|
||
player_info.total_score = d2ad(hp_info.total_hp)
|
||
else
|
||
player_info.total_score = total_score
|
||
end
|
||
|
||
if player_info.score > maxScore then
|
||
maxScore = player_info.score
|
||
end
|
||
|
||
if player_info.id == room.self_player.self_user.account_id then
|
||
if player_info.total_score >= 0 then
|
||
isWin = true
|
||
end
|
||
end
|
||
end
|
||
|
||
if isWin then
|
||
big_result:GetController('result').selectedIndex = 1
|
||
else
|
||
big_result:GetController('result').selectedIndex = 0
|
||
end
|
||
|
||
for i = 1, #self._resultInfo.player_list do
|
||
local player_info = self._resultInfo.player_list[i]
|
||
|
||
local item2
|
||
if player_info.id == room.self_player.self_user.account_id then
|
||
if isWin then
|
||
item2 = big_result:GetChild('play_win')
|
||
else
|
||
item2 = big_result:GetChild('play_lose')
|
||
end
|
||
else
|
||
if not isWin then
|
||
item2 = big_result:GetChild('play_win')
|
||
else
|
||
item2 = big_result:GetChild('play_lose')
|
||
end
|
||
end
|
||
local item = player_list:AddItemFromPool()
|
||
item:GetChild('txt_name').text = player_info.nick
|
||
item2:GetChild('txt_name').text = player_info.nick
|
||
item2:GetChild('txt_id').text = player_info.id
|
||
|
||
local head = item:GetChild('head'):GetChild('n4')
|
||
ImageLoad.Load(player_info.head_url, head)
|
||
local head = item2:GetChild('head'):GetChild('n4')
|
||
ImageLoad.Load(player_info.head_url, head)
|
||
|
||
if player_info.entrust ~= nil and player_info.entrust == true then
|
||
item:GetController('entrust').selectedIndex = 1
|
||
else
|
||
item:GetController('entrust').selectedIndex = 0
|
||
end
|
||
|
||
if player_info.hp_info ~= nil and player_info.hp_info.cur_hp ~= nil then
|
||
item:GetChild('txt_reserve_hp').text = '积分:' .. tostring(d2ad(player_info.hp_info.cur_hp))
|
||
end
|
||
|
||
if player_info.total_score ~= nil then
|
||
if tostring(player_info.score) == tostring(maxScore) and player_info.score > 0 then
|
||
item:GetController('big_win').selectedIndex = 1
|
||
else
|
||
item:GetController('big_win').selectedIndex = 0
|
||
end
|
||
|
||
if player_info.total_score >= 0 then
|
||
item:GetController('pn').selectedIndex = 1
|
||
item:GetChild('txt_positive').text = '+' .. tostring(player_info.total_score)
|
||
item2:GetChild('txt_navigate').text = string.format("总战绩:+%s", player_info.total_score)
|
||
item2:GetChild('txt_daniao').text = string.format("打鸟 %s", player_info.daniao)
|
||
item2:GetChild('text_zongjifen').text = player_info.total_score < player_info.daniao and 0 or
|
||
player_info.total_score - player_info.daniao
|
||
else
|
||
item:GetController('pn').selectedIndex = 0
|
||
item:GetChild('txt_navigate').text = tostring(player_info.total_score)
|
||
item2:GetChild('txt_navigate').text = string.format("总战绩:%s", player_info.total_score)
|
||
item2:GetChild('txt_daniao').text = string.format("打鸟 %s", player_info.daniao)
|
||
item2:GetChild('text_zongjifen').text = player_info.total_score > player_info.daniao and 0 or
|
||
player_info.total_score - player_info.daniao
|
||
end
|
||
end
|
||
|
||
player_info.score = room:GetTotalScore(player_info.score)
|
||
|
||
local list_param = item:GetChild('list_param')
|
||
list_param:RemoveChildrenToPool()
|
||
if self._gameStatisticsLineSpacing ~= nil then
|
||
list_param.lineGap = self._gameStatisticsLineSpacing
|
||
end
|
||
|
||
if player_info.param ~= nil then
|
||
local big = false
|
||
if #player_info.param <= 4 then
|
||
big = true
|
||
end
|
||
|
||
for i = 1, #player_info.param do
|
||
local pitem = list_param:AddItemFromPool()
|
||
|
||
pitem:GetChild('txt_key').text = player_info.param[i].key
|
||
pitem:GetChild('txt_value').text = player_info.param[i].value
|
||
|
||
if fontsize ~= nil and fontsize > 0 then
|
||
pitem:GetChild('txt_key').textFormat.size = fontsize
|
||
pitem:GetChild('txt_value').textFormat.size = fontsize
|
||
else
|
||
if big then
|
||
pitem:GetChild('txt_key').textFormat.size = 30
|
||
pitem:GetChild('txt_value').textFormat.size = 30
|
||
else
|
||
pitem:GetChild('txt_key').textFormat.size = 24
|
||
pitem:GetChild('txt_value').textFormat.size = 24
|
||
end
|
||
end
|
||
end
|
||
end
|
||
|
||
local list_param = item2:GetChild('list_param')
|
||
list_param:RemoveChildrenToPool()
|
||
if self._gameStatisticsLineSpacing ~= nil then
|
||
list_param.lineGap = self._gameStatisticsLineSpacing
|
||
end
|
||
|
||
if player_info.param ~= nil then
|
||
local big = false
|
||
if #player_info.param <= 4 then
|
||
big = true
|
||
end
|
||
|
||
for i = 1, #player_info.param do
|
||
local pitem = list_param:AddItemFromPool()
|
||
|
||
pitem:GetChild('txt_key').text = player_info.param[i].key
|
||
pitem:GetChild('txt_value').text = player_info.param[i].value
|
||
|
||
if fontsize ~= nil and fontsize > 0 then
|
||
pitem:GetChild('txt_key').textFormat.size = fontsize
|
||
pitem:GetChild('txt_value').textFormat.size = fontsize
|
||
else
|
||
if big then
|
||
pitem:GetChild('txt_key').textFormat.size = 30
|
||
pitem:GetChild('txt_value').textFormat.size = 30
|
||
else
|
||
pitem:GetChild('txt_key').textFormat.size = 24
|
||
pitem:GetChild('txt_value').textFormat.size = 24
|
||
end
|
||
end
|
||
end
|
||
end
|
||
|
||
local flag = item:GetChild('flag')
|
||
flag:RemoveChildrenToPool()
|
||
if player_info.flag ~= nil and #player_info.flag > 0 then
|
||
for i = 1, #player_info.flag do
|
||
local pitem = flag:AddItemFromPool()
|
||
|
||
pitem:GetChild('txt_name').text = player_info.flag[i]
|
||
end
|
||
item:GetController('have_flag').selectedIndex = 1
|
||
else
|
||
item:GetController('have_flag').selectedIndex = 0
|
||
end
|
||
|
||
if player_info.id == room.self_player.self_user.account_id then
|
||
item:GetController('self').selectedIndex = 1
|
||
else
|
||
item:GetController('self').selectedIndex = 0
|
||
end
|
||
end
|
||
|
||
local btn_continue_game = big_result: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
|
||
end
|
||
end
|
||
|
||
return M
|