2025-06-10 16:11:48 +08:00
|
|
|
local EXRoomConfig = import(".EXRoomConfig")
|
|
|
|
|
local EXClearingView = import(".EXClearingView")
|
|
|
|
|
local TX_GameEvent = import(".GameEvent")
|
|
|
|
|
|
|
|
|
|
local Record_Event = import(".RecordEvent")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
|
|
--- Create a new
|
|
|
|
|
function M.new()
|
|
|
|
|
setmetatable(M, { __index = BaseView })
|
|
|
|
|
local self = setmetatable({}, { __index = M })
|
|
|
|
|
self.class = "EXMJWitness"
|
|
|
|
|
self:init()
|
|
|
|
|
|
|
|
|
|
return self
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:init()
|
|
|
|
|
self._gamectr = ControllerManager.GetController(GameController)
|
|
|
|
|
self._room = DataManager.CurrenRoom
|
|
|
|
|
self._room.Witness = true
|
|
|
|
|
UIPackage.AddPackage('base/chat/ui/Chat')
|
|
|
|
|
UIPackage.AddPackage("base/main_majiang/ui/Main_Majiang")
|
|
|
|
|
self._eventmap = {}
|
|
|
|
|
-- self._full = true
|
|
|
|
|
self._put_map = false
|
|
|
|
|
self._new_hide = false
|
|
|
|
|
self._queue = false
|
|
|
|
|
self._style = 1
|
|
|
|
|
self:InitView()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:InitView(url)
|
|
|
|
|
local room = self._room
|
|
|
|
|
UIPackage.AddPackage("extend/majiang/lichuan/ui/Extend_MJ_LiChuan")
|
|
|
|
|
BaseView.InitView(self, string.format("ui://Main_Majiang/Main_new_%d_jiangxi", room.room_config.people_num))
|
|
|
|
|
self:EventInit()
|
|
|
|
|
|
|
|
|
|
local _cardbox = self._view:GetChild("cardbox")
|
|
|
|
|
--self._view:GetChild("panel_record"):GetChild("btn_LastStep").enabled = false
|
|
|
|
|
self._ctr_cardbox = _cardbox:GetController("c1")
|
|
|
|
|
self._tex_round = self._view:GetChild("tex_round")
|
|
|
|
|
self._tex_LeftCard = self._view:GetChild("remaining_card")
|
|
|
|
|
self._anchor = self._view:GetChild("mask_tips")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:FillRoomData(data)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:EventInit()
|
|
|
|
|
-- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong")
|
2025-06-10 16:20:42 +08:00
|
|
|
print("lingmeng EventInit")
|
2025-06-10 16:11:48 +08:00
|
|
|
MainView.EventInit(self)
|
|
|
|
|
local _room = self._room
|
|
|
|
|
local _view = self._view
|
|
|
|
|
local _gcm_outcard_url = UIPackage.GetItemURL("Main_Majiang", "Gcm_OutCard")
|
|
|
|
|
local _player_info = self._player_info
|
|
|
|
|
local _gamectr = self._gamectr
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...)
|
|
|
|
|
local arg = { ... }
|
|
|
|
|
print("lingmeng witness SendLaiZi")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.SendGangZi, function(...)
|
|
|
|
|
local arg = { ... }
|
|
|
|
|
print("lingmeng witness SendGangZi")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.EventBuGang, function(...)
|
|
|
|
|
local arg = { ... }
|
|
|
|
|
print("lingmeng witness EventBuGang")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.SendCards, function(...)
|
|
|
|
|
print("lingmeng witness SendCards")
|
|
|
|
|
end)
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...)
|
|
|
|
|
print("lingmeng witness EventTurn")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.OutHint, function(...)
|
|
|
|
|
print("lingmeng witness OutHint")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
local _gcm_outcard_url = "ui://Main_Majiang/Gcm_OutCard"
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.OutCard, function(...)
|
|
|
|
|
print("lingmeng witness OutCard")
|
|
|
|
|
end)
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.GetCard, function(...)
|
|
|
|
|
print("lingmeng witness GetCard")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.FZTips, function(...)
|
|
|
|
|
print("lingmeng witness FZTips")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.FangziAction, function()
|
|
|
|
|
print("lingmeng witness FangziAction")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...)
|
|
|
|
|
print("lingmeng witness ZPHuCard")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.EventNiao, function(...)
|
|
|
|
|
print("lingmeng witness EventNiao")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.ZPResult1, function(...)
|
|
|
|
|
print("lingmeng witness ZPResult1")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...)
|
|
|
|
|
print("lingmeng witness ZPResult2")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.EvnetPiaoTip, function()
|
|
|
|
|
print("lingmeng witness EvnetPiaoTip")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.EvnetPiao, function(...)
|
|
|
|
|
print("lingmeng witness EvnetPiao")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.EventResidueCard, function(...)
|
|
|
|
|
print("lingmeng witness EventResidueCard")
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:ShowStep(index)
|
|
|
|
|
local step = self._step[index + 1]
|
|
|
|
|
self:UpdateLeftCard(step.left_card)
|
|
|
|
|
-- self._ctr_cardbox.selectedIndex = step.current_out_seat
|
|
|
|
|
self:UpdateCardBox(self:GetPos(step.current_out_seat))
|
|
|
|
|
self:UpdateStep(index + 1)
|
|
|
|
|
if step.cmd ~= Record_Event.Evt_OutCard then
|
|
|
|
|
self:RemoveCursor()
|
|
|
|
|
end
|
|
|
|
|
for i = 1, #step.player_card_data do
|
|
|
|
|
local p = self._room:GetPlayerBySeat(i)
|
|
|
|
|
local info = self._player_card_info[self:GetPos(i)]
|
|
|
|
|
p.card_list = step.player_card_data[i].card_list
|
|
|
|
|
p.outcard_list = step.player_card_data[i].outcard_list
|
|
|
|
|
p.fz_list = step.player_card_data[i].fz_list
|
|
|
|
|
p.hand_left_count = #p.card_list
|
|
|
|
|
info:Clear()
|
|
|
|
|
info:ResetFzList()
|
|
|
|
|
p.piao_niao = step.player_card_data[i].piao_niao
|
|
|
|
|
local head_info = self._player_info[self:GetPos(i)]
|
|
|
|
|
if p.piao_niao and p.piao_niao > 0 then
|
|
|
|
|
head_info._view:GetChild("mask_piao").title = "飘分 " .. p.piao_niao
|
|
|
|
|
head_info._view:GetController("piao_niao").selectedIndex = 1
|
|
|
|
|
else
|
|
|
|
|
head_info._view:GetController("piao_niao").selectedIndex = 0
|
|
|
|
|
end
|
|
|
|
|
if step.cmd == Record_Event.Evt_OutCard and i == step.last_out_seat then
|
|
|
|
|
local card = p.outcard_list[#p.outcard_list]
|
|
|
|
|
info:UpdateOutCardList(nil, nil, self._cursor)
|
|
|
|
|
else
|
|
|
|
|
info:UpdateOutCardList()
|
|
|
|
|
end
|
|
|
|
|
if step.cmd == Record_Event.Evt_GetCard and p.seat == step.current_out_seat then
|
|
|
|
|
info:UpdateHandCard(true, true)
|
|
|
|
|
else
|
|
|
|
|
info:UpdateHandCard(false, true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if step.cmd == Record_Event.Evt_Win then
|
|
|
|
|
self._win_pic = UIPackage.CreateObjectFromURL("ui://Main_Majiang/胡")
|
|
|
|
|
local info = self._player_card_info[self:GetPos(step.win)]
|
|
|
|
|
info._mask_liangpai:AddChild(self._win_pic)
|
|
|
|
|
self._win_pic:Center()
|
|
|
|
|
else
|
|
|
|
|
if self._win_pic then
|
|
|
|
|
self._win_pic:Dispose()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if step.cmd == Record_Event.Evt_Niao then
|
|
|
|
|
local niao_list = step.niao
|
|
|
|
|
self._niao = UIPackage.CreateObjectFromURL("ui://Extend_MJ_LiChuan/Panel_Birds")
|
|
|
|
|
local list = self._niao:GetChild("Lst_birds")
|
|
|
|
|
list:RemoveChildrenToPool()
|
|
|
|
|
for i = 1, #niao_list do
|
|
|
|
|
local item = list:AddItemFromPool()
|
|
|
|
|
item.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. niao_list[i].card)
|
|
|
|
|
if niao_list[i].score > 0 then
|
|
|
|
|
item:GetController("bg").selectedIndex = 2
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
self._view:AddChild(self._niao)
|
|
|
|
|
self._view:AddChild(self._view:GetChild("panel_record"))
|
|
|
|
|
self._niao:Center()
|
|
|
|
|
else
|
|
|
|
|
if self._niao then
|
|
|
|
|
self._niao:Dispose()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if step.cmd == Record_Event.Evt_Result then
|
|
|
|
|
if not self.result then
|
|
|
|
|
self.result = EXClearingView.new(self._root_view, true)
|
|
|
|
|
self.result:InitData(0, self._room, step.result_data)
|
|
|
|
|
self.result._view.x = (GRoot.inst.width - self.result._view.width) * -0.5
|
|
|
|
|
self.result._view.width = GRoot.inst.width
|
|
|
|
|
self.result._view.height = GRoot.inst.height
|
|
|
|
|
self.result._view:GetChild("btn_confirm").visible = false
|
|
|
|
|
self._anchor:AddChild(self.result._view)
|
|
|
|
|
self.result._view.x = self._anchor.x * -1
|
|
|
|
|
self.result._view.y = self._anchor.y * -1
|
|
|
|
|
else
|
|
|
|
|
self.result._view.visible = true
|
|
|
|
|
end
|
|
|
|
|
-- self.result._view:Center()
|
|
|
|
|
else
|
|
|
|
|
if self.result then
|
|
|
|
|
self.result._view.visible = false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:GenerateAllStepData(data)
|
|
|
|
|
local cmdList = self.cmdList
|
|
|
|
|
self._step = {}
|
|
|
|
|
local step = {}
|
|
|
|
|
local info = data.info
|
|
|
|
|
step.cmd = ""
|
|
|
|
|
step.left_card = info.left_card
|
|
|
|
|
step.last_out_seat = 0
|
|
|
|
|
step.current_out_seat = 1
|
|
|
|
|
step.win = 0
|
|
|
|
|
step.niao = 0
|
|
|
|
|
|
|
|
|
|
step.player_card_data = {}
|
|
|
|
|
for i = 1, #self._room.player_list do
|
|
|
|
|
local p = info.playerData[i]
|
|
|
|
|
local u = {}
|
|
|
|
|
u.seat = p.seat
|
|
|
|
|
u.card_list = p.hand_card
|
|
|
|
|
u.hand_left_count = #u.card_list
|
|
|
|
|
u.fz_list = {}
|
|
|
|
|
u.outcard_list = {}
|
|
|
|
|
u.piao_niao = p.piao_niao
|
|
|
|
|
step.player_card_data[u.seat] = u
|
|
|
|
|
end
|
|
|
|
|
self._step[#self._step + 1] = step
|
|
|
|
|
|
|
|
|
|
for i = 1, #cmdList do
|
|
|
|
|
local tem = cmdList[i]
|
|
|
|
|
self._cmdmap[tem.cmd](self, tem, i)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:CmdGetCard(cmd, index)
|
|
|
|
|
local data = self:CopyLastStep(index)
|
|
|
|
|
data.cmd = cmd.cmd
|
|
|
|
|
data.current_out_seat = cmd.seat
|
|
|
|
|
data.left_card = cmd.data.left_count
|
|
|
|
|
local u = data.player_card_data[cmd.seat]
|
|
|
|
|
u.card_list[#u.card_list + 1] = cmd.data.card
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:CmdOutCard(cmd, index)
|
|
|
|
|
local data = self:CopyLastStep(index)
|
|
|
|
|
data.cmd = cmd.cmd
|
|
|
|
|
data.last_out_seat = cmd.seat
|
|
|
|
|
local u = data.player_card_data[cmd.seat]
|
|
|
|
|
list_remove(u.card_list, cmd.data.card)
|
|
|
|
|
table.sort(u.card_list, self.HandCardSortAndJing)
|
|
|
|
|
u.outcard_list[#u.outcard_list + 1] = cmd.data.card
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:CmdAction(cmd, index)
|
|
|
|
|
local data = self:CopyLastStep(index)
|
|
|
|
|
data.cmd = cmd.cmd
|
|
|
|
|
data.last_out_seat = 0
|
|
|
|
|
data.current_out_seat = cmd.seat
|
|
|
|
|
local u = data.player_card_data[cmd.seat]
|
|
|
|
|
for i = 1, #cmd.data.opcard do
|
|
|
|
|
list_remove(u.card_list, cmd.data.opcard[i])
|
|
|
|
|
end
|
|
|
|
|
local fz = {}
|
|
|
|
|
fz.type = cmd.data.type
|
|
|
|
|
fz.card = cmd.data.card
|
|
|
|
|
fz.opcard = cmd.data.opcard
|
|
|
|
|
local uf = data.player_card_data[cmd.data.from_seat]
|
|
|
|
|
if fz.type ~= FZType.Gang_An and fz.type ~= FZType.Gang_Peng then
|
|
|
|
|
table.remove(uf.outcard_list, #uf.outcard_list)
|
|
|
|
|
end
|
|
|
|
|
if fz.type ~= FZType.Gang_Peng then
|
|
|
|
|
u.fz_list[#u.fz_list + 1] = fz
|
|
|
|
|
else
|
|
|
|
|
for i = 1, #u.fz_list do
|
|
|
|
|
if u.fz_list[i].type == FZType.Peng and u.fz_list[i].card == fz.card then
|
|
|
|
|
u.fz_list[i].type = FZType.Gang_Peng
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:CmdWin(cmd, index)
|
|
|
|
|
local data = self:CopyLastStep(index)
|
|
|
|
|
data.cmd = cmd.cmd
|
|
|
|
|
data.win = cmd.seat
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:CmdNiao(cmd, index)
|
|
|
|
|
local data = self:CopyLastStep(index)
|
|
|
|
|
data.cmd = cmd.cmd
|
|
|
|
|
data.niao = cmd.data.niao
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:CmdPiao(cmd, index)
|
|
|
|
|
local data = self:CopyLastStep(index)
|
|
|
|
|
data.cmd = cmd.cmd
|
|
|
|
|
data.player_card_data[cmd.seat].piao_niao = cmd.data.num
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:CmdResult(cmd, index)
|
|
|
|
|
local data = self:CopyLastStep(index)
|
|
|
|
|
data.cmd = cmd.cmd
|
|
|
|
|
data.result_data = cmd.data
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:CopyLastStep(index)
|
|
|
|
|
local step = {}
|
|
|
|
|
local last_step = self._step[index]
|
|
|
|
|
step = membe_deep_clone(last_step)
|
|
|
|
|
self._step[#self._step + 1] = step
|
|
|
|
|
step.result_data = nil
|
|
|
|
|
return step
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:UpdateLeftCard(num)
|
|
|
|
|
self._tex_LeftCard.text = "剩余 " .. num .. " 张牌"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:UpdateCardBox(seat)
|
|
|
|
|
local index = seat
|
|
|
|
|
local people_num = self._room.room_config.people_num
|
|
|
|
|
if people_num == 2 and seat == 2 then
|
|
|
|
|
index = 3
|
|
|
|
|
elseif people_num == 3 and seat == 3 then
|
|
|
|
|
index = 4
|
|
|
|
|
end
|
|
|
|
|
self._ctr_cardbox.selectedIndex = index
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:UpdateRound(round)
|
|
|
|
|
self._tex_round.text = "第 " .. round .. "/" .. self._room.room_config.round .. " 局"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:UpdateStep(step)
|
|
|
|
|
self._record:GetChild("tex_step").text = "第 " .. step .. " / " .. #self._step .. "步"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M.HandCardSortAndJing(a, b)
|
|
|
|
|
local jing = DataManager.CurrenRoom.jing
|
|
|
|
|
if a == jing or b == jing then
|
|
|
|
|
if a == b then
|
|
|
|
|
return a < b
|
|
|
|
|
end
|
|
|
|
|
return a == jing
|
|
|
|
|
else
|
|
|
|
|
if a < 200 then
|
|
|
|
|
a = a + 1000
|
|
|
|
|
elseif a < 300 then
|
|
|
|
|
a = a + 3000
|
|
|
|
|
elseif a < 400 then
|
|
|
|
|
a = a + 2000
|
|
|
|
|
else
|
|
|
|
|
a = a + 4000
|
|
|
|
|
end
|
|
|
|
|
if b < 200 then
|
|
|
|
|
b = b + 1000
|
|
|
|
|
elseif b < 300 then
|
|
|
|
|
b = b + 3000
|
|
|
|
|
elseif b < 400 then
|
|
|
|
|
b = b + 2000
|
|
|
|
|
else
|
|
|
|
|
b = b + 4000
|
|
|
|
|
end
|
|
|
|
|
return a < b
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return M
|