553 lines
17 KiB
Lua
553 lines
17 KiB
Lua
|
|
require("Game.View.ResultView")
|
|||
|
|
local CS_Win_Type = import(".CS_Win_Type")
|
|||
|
|
|
|||
|
|
local CS_ClearingView = {}
|
|||
|
|
|
|||
|
|
local M = CS_ClearingView
|
|||
|
|
|
|||
|
|
function CS_ClearingView.new(blur_view)
|
|||
|
|
setmetatable(M, { __index = ResultView })
|
|||
|
|
local self = setmetatable({}, { __index = M })
|
|||
|
|
self._full = true
|
|||
|
|
ResultView.init(self, "ui://Main_Majiang/clearing")
|
|||
|
|
|
|||
|
|
self._currenIndex = 0
|
|||
|
|
self._blur_view = blur_view
|
|||
|
|
self._close_zone = false
|
|||
|
|
self._close_destroy = true
|
|||
|
|
|
|||
|
|
self.xiPaiCtr = self._view:GetController("xipai")
|
|||
|
|
|
|||
|
|
self:InitMaPai()
|
|||
|
|
return self
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function M:InitMaPai()
|
|||
|
|
self.maPaiCtr = self._view:GetController("mapai")
|
|||
|
|
self.maPaiCtr.selectedIndex = 0
|
|||
|
|
|
|||
|
|
self.maPaiList = {}
|
|||
|
|
|
|||
|
|
for i = 1, 10 do
|
|||
|
|
local tempMP = self._view:GetChild("niao" .. i)
|
|||
|
|
table.insert(self.maPaiList, tempMP)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function M:IsMapaiShow(niao, isShow)
|
|||
|
|
if niao then
|
|||
|
|
niao.visible = isShow
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function M:SetMaPaiValue(niao, value)
|
|||
|
|
if niao then
|
|||
|
|
niao.icon = 'ui://Main_Majiang/' .. get_majiang_prefix(DataManager.CurrenRoom.game_id) .. "201_" .. value
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function M:SetMaPaiColor(niao, num)
|
|||
|
|
niao:GetController("color").selectedIndex = num
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function M:HideAllMapai()
|
|||
|
|
for i = 1, #self.maPaiList do
|
|||
|
|
self:IsMapaiShow(self.maPaiList[i], false)
|
|||
|
|
self:SetMaPaiColor(self.maPaiList[i], 0)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function M:ShowSelectMaPai(niaoList)
|
|||
|
|
if niaoList and #niaoList > 0 then
|
|||
|
|
self.maPaiCtr.selectedIndex = 1
|
|||
|
|
self:HideAllMapai()
|
|||
|
|
for i = 1, #niaoList do
|
|||
|
|
self:IsMapaiShow(self.maPaiList[i], true)
|
|||
|
|
self:SetMaPaiValue(self.maPaiList[i], niaoList[i].card)
|
|||
|
|
if niaoList[i].score > 0 then
|
|||
|
|
self:SetMaPaiColor(self.maPaiList[i], 2)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
self.maPaiCtr.selectedIndex = 0
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function M:InitData(over, room, result, total_result, callback)
|
|||
|
|
self._callback = callback
|
|||
|
|
local _overCtr = self._view:GetController("over")
|
|||
|
|
local btn_confirm = self._view:GetChild("btn_confirm")
|
|||
|
|
local btn_result = self._view:GetChild("btn_showResult")
|
|||
|
|
local btn_close = self._view:GetChild("big_result"):GetChild("btn_close")
|
|||
|
|
local _btnCtr = self._view:GetController("button")
|
|||
|
|
local _sdkCtr = self._view:GetController("sdk")
|
|||
|
|
local ctr_type = self._view:GetController("type")
|
|||
|
|
self._view:GetChild("tex_roominfo").text = string.format("房号%s 局%s/%s %s", room.room_id, room.curren_round,
|
|||
|
|
room.room_config.round, os.date("%Y-%m-%d %H:%M:%S", os.time()))
|
|||
|
|
self._view:GetChild("tex_gameinfo").text = string.gsub(room.room_config:GetDes(), "\r", "")
|
|||
|
|
-- self._view:GetChild("tex_roomnum").text = room.room_id
|
|||
|
|
-- self._view:GetChild("tex_data").text = os.date("%Y-%m-%d %H:%M", os.time())
|
|||
|
|
-- self._view:GetChild("tex_time").text = os.date("%H:%M", os.time())
|
|||
|
|
|
|||
|
|
local paixingxiangqing = self._view:GetChild("btn_detal")
|
|||
|
|
paixingxiangqing.visible = false
|
|||
|
|
local fanhuipaixing = self._view:GetChild("btn_fanhuipaixing")
|
|||
|
|
fanhuipaixing.visible = false
|
|||
|
|
|
|||
|
|
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
|
|||
|
|
|
|||
|
|
|
|||
|
|
if result then
|
|||
|
|
self:ShowSelectMaPai(result.niao)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
|
|||
|
|
if over ~= 2 then
|
|||
|
|
local xipai = self._view:GetChild("btn_xipai")
|
|||
|
|
xipai.touchable = true
|
|||
|
|
xipai.onClick:Add(function()
|
|||
|
|
local xiPaiCallBack = function()
|
|||
|
|
xipai.touchable = false
|
|||
|
|
self.xiPaiCtr.selectedIndex = 0
|
|||
|
|
ViewUtil.ErrorTip(1000000, "申请洗牌成功")
|
|||
|
|
end
|
|||
|
|
local _gamectr = ControllerManager.GetController(GameController)
|
|||
|
|
_gamectr:SendXiPaiAction(xiPaiCallBack)
|
|||
|
|
end)
|
|||
|
|
if result and result.xipai_score then
|
|||
|
|
--xipai.text="洗牌 积分x"..result.xipai_score
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
if result.liuju then
|
|||
|
|
ctr_type.selectedIndex = 3
|
|||
|
|
else
|
|||
|
|
local info_list = result.info_list
|
|||
|
|
for i = 1, #info_list do
|
|||
|
|
local is_win = info_list[i].is_win
|
|||
|
|
if is_win then
|
|||
|
|
if info_list[i].seat == room.self_player.seat then
|
|||
|
|
ctr_type.selectedIndex = 1
|
|||
|
|
else
|
|||
|
|
ctr_type.selectedIndex = 2
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
if over == 0 then
|
|||
|
|
_btnCtr.selectedIndex = 0
|
|||
|
|
_sdkCtr.selectedIndex = 1
|
|||
|
|
btn_confirm.onClick:Add(function()
|
|||
|
|
local _gamectr = ControllerManager.GetController(GameController)
|
|||
|
|
_gamectr:PlayerReady()
|
|||
|
|
self:DestroyWithCallback()
|
|||
|
|
end)
|
|||
|
|
self:AddClearItem(room, result.info_list, nil, over, result.niao, result.active_player)
|
|||
|
|
elseif over == 1 then
|
|||
|
|
self.xiPaiCtr.selectedIndex = 0
|
|||
|
|
_btnCtr.selectedIndex = 1
|
|||
|
|
_sdkCtr.selectedIndex = 1
|
|||
|
|
btn_result.onClick:Add(function()
|
|||
|
|
_overCtr.selectedIndex = 1
|
|||
|
|
_btnCtr.selectedIndex = 0
|
|||
|
|
_sdkCtr.selectedIndex = 0
|
|||
|
|
self.maPaiCtr.selectedIndex = 0
|
|||
|
|
if self._qsinfo_view then
|
|||
|
|
self._qsinfo_view:Dispose()
|
|||
|
|
end
|
|||
|
|
end)
|
|||
|
|
btn_close.onClick:Add(function()
|
|||
|
|
ViewManager.ChangeView(ViewManager.View_Lobby)
|
|||
|
|
end)
|
|||
|
|
self:AddClearItem(room, result.info_list, total_result.info_list, over, result.niao, result.active_player)
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
self.xiPaiCtr.selectedIndex = 0
|
|||
|
|
_overCtr.selectedIndex = 1
|
|||
|
|
self.maPaiCtr.selectedIndex = 0
|
|||
|
|
btn_close.onClick:Add(function()
|
|||
|
|
ViewManager.ChangeView(ViewManager.View_Lobby)
|
|||
|
|
end)
|
|||
|
|
self:AddClearItem(room, nil, total_result.info_list, over)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function M:AddClearItem(room, data, total_data, over, niao, active_player)
|
|||
|
|
local n = over + 1
|
|||
|
|
local list_view1 = self._view:GetChild("player_list_1")
|
|||
|
|
local list_view2 = self._view:GetChild("player_list_2")
|
|||
|
|
if 0 == over or 1 == over then
|
|||
|
|
-- 把鸟放到中的人列表中
|
|||
|
|
for i = 1, #niao do
|
|||
|
|
if niao[i].score > 0 then
|
|||
|
|
local p = room:GetPlayerById(niao[i].playerId)
|
|||
|
|
for j = 1, #data do
|
|||
|
|
if data[j].seat == p.seat then
|
|||
|
|
if not data[j].niao then
|
|||
|
|
data[j].niao = {}
|
|||
|
|
end
|
|||
|
|
table.insert(data[j].niao, niao[i].card)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
table.sort(data, function(a, b) return a.seat > b.seat end)
|
|||
|
|
list_view1:RemoveChildrenToPool()
|
|||
|
|
for i = 1, #data do
|
|||
|
|
local item = list_view1:AddItemFromPool()
|
|||
|
|
self:FillItemData(room, data[i], item, active_player, niao)
|
|||
|
|
end
|
|||
|
|
if #data == 3 then
|
|||
|
|
list_view1.lineGap = 54
|
|||
|
|
elseif #data == 2 then
|
|||
|
|
list_view1.lineGap = 108
|
|||
|
|
end
|
|||
|
|
if 1 == over then
|
|||
|
|
self:FillItemData2(room, total_data, list_view2)
|
|||
|
|
end
|
|||
|
|
elseif 2 == over then
|
|||
|
|
self:FillItemData2(room, total_data, list_view2)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function M:FillItemData(room, data, item, active_player)
|
|||
|
|
local _gamectr = ControllerManager.GetController(GameController)
|
|||
|
|
local p = room:GetPlayerBySeat(data["seat"])
|
|||
|
|
item:GetChild("playerName").text = p.self_user.nick_name
|
|||
|
|
if data.win_count > 3 then
|
|||
|
|
item:GetController("mult_win").selectedIndex = 1
|
|||
|
|
-- item:GetChild("tex_win_count").text = string.char(97 + data.win_count - 4) .. "连"
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
local huadd = data["hu_score"]
|
|||
|
|
local qsadd = data["qs_score"]
|
|||
|
|
local birdadd = data["niao_score"]
|
|||
|
|
local qs_niao_list = data["qs_niao_list"]
|
|||
|
|
local total = data["round_score"]
|
|||
|
|
|
|||
|
|
-- if room.room_config.fengding and huadd + birdadd >= 28 then
|
|||
|
|
if data.fengding then
|
|||
|
|
item:GetController("fengding").selectedIndex = 1
|
|||
|
|
else
|
|||
|
|
item:GetController("fengding").selectedIndex = 0
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
local sp = " "
|
|||
|
|
local str = "胡:" .. huadd .. "分"
|
|||
|
|
str = str .. sp .. "扎鸟:" .. birdadd .. "分"
|
|||
|
|
str = str .. sp .. "起手胡:" .. qsadd .. "分"
|
|||
|
|
-- if #qs_niao_list > 0 then
|
|||
|
|
-- str = str .. "(摇骰点数:" .. qs_niao_list[1].card .. " " .. qs_niao_list[2].card .. ")"
|
|||
|
|
-- end
|
|||
|
|
if data["piao_niao_score"] then
|
|||
|
|
str = str .. sp .. "飘鸟:" .. data["piao_niao_score"] .. "分"
|
|||
|
|
end
|
|||
|
|
item:GetChild("score1").text = str
|
|||
|
|
local win_list = data["win_list"]
|
|||
|
|
local remove_win_card = true
|
|||
|
|
if win_list then
|
|||
|
|
local str1 = ""
|
|||
|
|
item:GetController("hu_list").selectedIndex = 1
|
|||
|
|
for i = 1, #win_list do
|
|||
|
|
local str2 = ""
|
|||
|
|
if win_list[i].type == 1 then
|
|||
|
|
local value = win_list[i].value
|
|||
|
|
str2 = value == 1 and "" or (value == 2 and "豪华" or (value == 3 and "双豪华" or "三豪华"))
|
|||
|
|
str2 = str2 .. "小七对"
|
|||
|
|
else
|
|||
|
|
if win_list[i].type == 5 then
|
|||
|
|
remove_win_card = false
|
|||
|
|
end
|
|||
|
|
str2 = CS_Win_Type[win_list[i].type]
|
|||
|
|
end
|
|||
|
|
str1 = str1 .. str2 .. sp
|
|||
|
|
end
|
|||
|
|
item:GetChild("score3").text = str1
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 手牌
|
|||
|
|
local hand_cards = data["hand_card"]
|
|||
|
|
table.sort(hand_cards, ViewUtil.HandCardSort)
|
|||
|
|
local hand_list_view = item:GetChild("hand_card_list")
|
|||
|
|
hand_list_view:RemoveChildrenToPool()
|
|||
|
|
if data["is_win"] and active_player == p.self_user.account_id and remove_win_card then
|
|||
|
|
list_remove(hand_cards, data["win_card"])
|
|||
|
|
end
|
|||
|
|
for i = 1, #hand_cards do
|
|||
|
|
local card = hand_list_view:AddItemFromPool()
|
|||
|
|
card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. hand_cards[i]
|
|||
|
|
end
|
|||
|
|
hand_list_view.width = 52 * #hand_cards
|
|||
|
|
|
|||
|
|
local fz_card = p.fz_list
|
|||
|
|
local fz_card_list = item:GetChild("fz_card_list")
|
|||
|
|
fz_card_list.width = 157 * #fz_card * 0.8
|
|||
|
|
fz_card_list:RemoveChildrenToPool()
|
|||
|
|
for i = 1, #fz_card do
|
|||
|
|
if fz_card[i].type == FZType.Peng then
|
|||
|
|
local item = fz_card_list:AddItemFromPool("ui://Main_Majiang/clearing_fz_3")
|
|||
|
|
for j = 1, 3 do
|
|||
|
|
local card = item:GetChild("card_" .. j)
|
|||
|
|
card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. fz_card[i].card
|
|||
|
|
end
|
|||
|
|
elseif fz_card[i].type == FZType.Chi then
|
|||
|
|
local item = fz_card_list:AddItemFromPool("ui://Main_Majiang/clearing_fz_3")
|
|||
|
|
for j = 1, 3 do
|
|||
|
|
local card = item:GetChild("card_" .. j)
|
|||
|
|
card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. fz_card[i].opcard[j]
|
|||
|
|
end
|
|||
|
|
elseif fz_card[i].type == FZType.Gang or fz_card[i].type == FZType.Gang_An or fz_card[i].type == FZType.Gang_Peng then
|
|||
|
|
local item = fz_card_list:AddItemFromPool("ui://Main_Majiang/clearing_fz_4")
|
|||
|
|
for j = 1, 4 do
|
|||
|
|
local card = item:GetChild("card_" .. j)
|
|||
|
|
if fz_card[i].type == FZType.Gang_An and j == 4 then
|
|||
|
|
card.icon = "ui://Main_Majiang/b202_00"
|
|||
|
|
else
|
|||
|
|
card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. fz_card[i].card
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- local total_score = data["total_score"]
|
|||
|
|
if total >= 0 then
|
|||
|
|
item:GetChild("score2").text = "+" .. total
|
|||
|
|
item:GetChild("score2").grayed = false
|
|||
|
|
else
|
|||
|
|
item:GetChild("score2").text = total
|
|||
|
|
item:GetChild("score2").grayed = true
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
local hp_nonnegative = room:checkHpNonnegative()
|
|||
|
|
item:GetController("nonnegative").selectedIndex = hp_nonnegative and 1 or 0
|
|||
|
|
if hp_nonnegative then
|
|||
|
|
local hp_info = data.hp_info
|
|||
|
|
local ctr_hp_limit = item:GetController("hp_limit")
|
|||
|
|
local hp = d2ad(hp_info.round_actual_hp)
|
|||
|
|
if hp >= 0 then hp = "+" .. tostring(hp) end
|
|||
|
|
item:GetChild("tex_hp").text = hp
|
|||
|
|
ctr_hp_limit.selectedIndex = hp_info.upper_limit and 1 or 0
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
local is_win = data["is_win"] or false
|
|||
|
|
item:GetController("win").selectedIndex = is_win and 0 or 1
|
|||
|
|
---- print(p.self_user.account_id, active_player)
|
|||
|
|
if p.self_user.account_id == active_player and is_win == false and not data["liuju"] then
|
|||
|
|
item:GetController("win").selectedIndex = 2
|
|||
|
|
end
|
|||
|
|
local win_card = item:GetChild("win_card")
|
|||
|
|
if is_win then
|
|||
|
|
win_card.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. data["win_card"]
|
|||
|
|
end
|
|||
|
|
if data.niao then
|
|||
|
|
item:GetController("niao").selectedIndex = 1
|
|||
|
|
local lst_niao = item:GetChild("list_niao")
|
|||
|
|
lst_niao:RemoveChildrenToPool()
|
|||
|
|
local niao = data.niao
|
|||
|
|
for i = 1, #niao do
|
|||
|
|
local card_niao = lst_niao:AddItemFromPool()
|
|||
|
|
card_niao.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. niao[i]
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
if p.seat == room.banker_seat then
|
|||
|
|
item:GetController("bank").selectedIndex = 1
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- item.onClick:Set(function()
|
|||
|
|
-- self:__AddQSInfo(data.qs_info_list, p.self_user.nick_name, room)
|
|||
|
|
-- end)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function M:FillItemData2(room, data, list)
|
|||
|
|
-- 赋值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].hp_info = data[i].hp_info
|
|||
|
|
player_list[i].score = data[i].total_score
|
|||
|
|
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].head_url = user.head_url
|
|||
|
|
|
|||
|
|
local settle_log = data[i].settle_log
|
|||
|
|
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.da_zimo)
|
|||
|
|
player_list[i].param[2] = {}
|
|||
|
|
player_list[i].param[2].key = "小胡自摸:"
|
|||
|
|
player_list[i].param[2].value = tostring(data[i].settle_log.xiao_zimo)
|
|||
|
|
player_list[i].param[3] = {}
|
|||
|
|
player_list[i].param[3].key = "大胡接炮:"
|
|||
|
|
player_list[i].param[3].value = tostring(data[i].settle_log.da_jie_pao)
|
|||
|
|
player_list[i].param[4] = {}
|
|||
|
|
player_list[i].param[4].key = "小胡接炮:"
|
|||
|
|
player_list[i].param[4].value = tostring(data[i].settle_log.xiao_jie_pao)
|
|||
|
|
player_list[i].param[5] = {}
|
|||
|
|
player_list[i].param[5].key = "大胡点炮:"
|
|||
|
|
player_list[i].param[5].value = tostring(data[i].settle_log.da_dian_pao)
|
|||
|
|
player_list[i].param[6] = {}
|
|||
|
|
player_list[i].param[6].key = "小胡点炮:"
|
|||
|
|
player_list[i].param[6].value = tostring(data[i].settle_log.xiao_dian_pao)
|
|||
|
|
end
|
|||
|
|
local round = room.room_config.round
|
|||
|
|
self:GenerateRoomResultInfo(round, room.room_config:GetGameName(), room.room_id, room.create_time, player_list)
|
|||
|
|
-- self:SetGSListlineGap(-10)
|
|||
|
|
|
|||
|
|
local big_result = self._view:GetChild("big_result")
|
|||
|
|
big_result:GetChild("txt_room_info").text = string.format("%s 房号%s 局%s/%s", os.date("%Y/%m/%d", os.time()),
|
|||
|
|
room.room_id, room.curren_round, room.room_config.round)
|
|||
|
|
local lst_p = big_result:GetChild("player_list")
|
|||
|
|
if #player_list == 3 then
|
|||
|
|
lst_p.columnGap = 108
|
|||
|
|
elseif #player_list == 2 then
|
|||
|
|
lst_p.columnGap = 208
|
|||
|
|
end
|
|||
|
|
self:InitBigResult(room, 30)
|
|||
|
|
local show_detail = room.hpOnOff == 1
|
|||
|
|
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
|
|||
|
|
if show_detail then
|
|||
|
|
local score = 0
|
|||
|
|
if com_p:GetController("pn").selectedIndex == 0 then
|
|||
|
|
score = com_p:GetChild("txt_navigate").text
|
|||
|
|
else
|
|||
|
|
score = com_p:GetChild("txt_positive").text
|
|||
|
|
end
|
|||
|
|
score = score / room.score_times
|
|||
|
|
com_p:GetChild("tex_detail_score").text = string.format("%s × %s倍", score, room.score_times)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
if room.group_id ~= 0 then
|
|||
|
|
big_result:GetController("group").selectedIndex = 1
|
|||
|
|
end
|
|||
|
|
DataManager.CurrenRoom = nil
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 起手胡详情
|
|||
|
|
function M:__AddQSInfo(data, nick, room)
|
|||
|
|
if self._qsinfo_view then
|
|||
|
|
self._qsinfo_view:Dispose()
|
|||
|
|
end
|
|||
|
|
local qsinfo = UIPackage.CreateObjectFromURL("ui://Extend_MJ_ChangSha/qs_info")
|
|||
|
|
self._qsinfo_view = qsinfo
|
|||
|
|
qsinfo:GetChild("btn_close").onClick:Add(function()
|
|||
|
|
qsinfo:Dispose()
|
|||
|
|
end)
|
|||
|
|
qsinfo:GetChild("tex_nick").text = nick
|
|||
|
|
local lst_qs = qsinfo:GetChild("lst_qs")
|
|||
|
|
lst_qs:RemoveChildrenToPool()
|
|||
|
|
if #data > 0 then
|
|||
|
|
for i = 1, #data do
|
|||
|
|
local tem = data[i]
|
|||
|
|
local item = lst_qs:AddItemFromPool()
|
|||
|
|
local lst_card = item:GetChild("lst_card")
|
|||
|
|
-- 整理起手胡板牌
|
|||
|
|
local card_map = {}
|
|||
|
|
for j = 1, #tem.win_list do
|
|||
|
|
local opcard = tem.win_list[j].opcard
|
|||
|
|
local cards = {}
|
|||
|
|
for k = 1, #opcard do
|
|||
|
|
local card = opcard[k]
|
|||
|
|
if cards[card] then
|
|||
|
|
cards[card] = cards[card] + 1
|
|||
|
|
else
|
|||
|
|
cards[card] = 1
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
for k, v in pairs(cards) do
|
|||
|
|
local card = k
|
|||
|
|
if card_map[card] then
|
|||
|
|
if card_map[card] < cards[card] then
|
|||
|
|
card_map[card] = cards[card]
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
card_map[card] = cards[card]
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
local all_cards = {}
|
|||
|
|
for j, v in pairs(card_map) do
|
|||
|
|
for k = 1, v do
|
|||
|
|
table.insert(all_cards, j)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
table.sort(all_cards)
|
|||
|
|
for j = 1, #all_cards do
|
|||
|
|
local citem = lst_card:AddItemFromPool()
|
|||
|
|
citem.touchable = false
|
|||
|
|
citem.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. all_cards[j]
|
|||
|
|
end
|
|||
|
|
local cs_zhua_niao = room.room_config.niao_type == 2
|
|||
|
|
qsinfo:GetController("niao").selectedIndex = cs_zhua_niao and 1 or 0
|
|||
|
|
item:GetChild("tex_touzi").text = cs_zhua_niao and (tem.niao[1].card .. " " .. tem.niao[2].card) or ""
|
|||
|
|
item:GetChild("tex_score").text = tem.score
|
|||
|
|
item:GetChild("tex_niao_score").text = cs_zhua_niao and tem.niao_score or ""
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
qsinfo:GetController("c1").selectedIndex = 1
|
|||
|
|
end
|
|||
|
|
if #data > 1 then
|
|||
|
|
qsinfo.height = qsinfo.height + 56 * (#data - 1)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
local _view_start_pos = nil
|
|||
|
|
local _touch_start_pos = nil
|
|||
|
|
self._view:AddChild(qsinfo)
|
|||
|
|
local btn_di = qsinfo:GetChild("btn_di")
|
|||
|
|
btn_di.onTouchBegin:Add(function(context)
|
|||
|
|
_view_start_pos = Vector2(qsinfo.x, qsinfo.y)
|
|||
|
|
_touch_start_pos = self._view:GlobalToLocal(Vector2(context.inputEvent.x, context.inputEvent.y))
|
|||
|
|
end)
|
|||
|
|
btn_di.onTouchMove:Add(function(context)
|
|||
|
|
local xy = self._view:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y))
|
|||
|
|
local dist = Vector2(xy.x - _touch_start_pos.x, xy.y - _touch_start_pos.y)
|
|||
|
|
local posx = _view_start_pos.x + dist.x
|
|||
|
|
local posy = _view_start_pos.y + dist.y
|
|||
|
|
local max_x = self._view.width - qsinfo.width
|
|||
|
|
local max_y = self._view.height - qsinfo.height
|
|||
|
|
qsinfo.x = posx < 0 and 0 or posx > max_x and max_x or posx
|
|||
|
|
qsinfo.y = posy < 0 and 0 or posy > max_y and max_y or posy
|
|||
|
|
end)
|
|||
|
|
qsinfo:Center()
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function M:LoadHead(p, room)
|
|||
|
|
local btn_head = self._view:GetChild("btn_head")
|
|||
|
|
for i = 1, #room.player_list do
|
|||
|
|
local player = room.player_list[i]
|
|||
|
|
if p.seat == player.seat and player.self_user.head_url ~= "" then
|
|||
|
|
ImageLoad.Load(player.self_user.head_url, btn_head.icon)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
local prefix
|
|||
|
|
function M:GetPrefix()
|
|||
|
|
-- if not prefix then
|
|||
|
|
prefix = get_majiang_prefix(10)
|
|||
|
|
-- end
|
|||
|
|
return prefix
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function M:DestroyWithCallback()
|
|||
|
|
if self._callback then
|
|||
|
|
self._callback()
|
|||
|
|
end
|
|||
|
|
self:Destroy()
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
return M
|