全麻将同步

master
罗家炜 2025-09-10 21:55:18 +08:00
parent d4591f9d94
commit 3f6e4ee15d
3 changed files with 300 additions and 148 deletions

View File

@ -66,13 +66,33 @@ function M:InitView()
self:InitPlayerInfoView()
self._player_card_info = {}
local _player_card_info = self._player_card_info
for i = 1, #room.player_list do
if room.curren_round > 0 then
for i = 1, #room.room_config.people_num do
local p = room.player_list[i]
local index = self:GetPos(p.seat)
print("lingmeng index", index)
local info = self._player_info[index]
local tem = self._view:GetChild("player_card_info" .. index)
_player_card_info[index] = self:NewMJPlayerCardInfoView(tem, index)
local info = self._player_info[i]
local tem = self._view:GetChild("player_card_info" .. i)
_player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i)
local cardInfo = _player_card_info[i]
cardInfo:SetPlayer(p)
cardInfo:UpdateHandCardWitness(false)
cardInfo:UpdateOutCardList(nil, nil, self._cursor)
for i = 1, #p.fz_list do
cardInfo:UpdateFzList(p.fz_list[i], -1)
end
info:FillData(p)
info._view.visible = false
end
else
for i = 1, room.room_config.people_num do
local tem = self._view:GetChild("player_card_info" .. i)
_player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i)
end
for i = 1, #room.player_list do
local p = room.player_list[i]
local index = self:GetPos(p.seat)
local info = self._player_info[i]
local cardInfo = _player_card_info[index]
cardInfo:SetPlayer(p)
cardInfo:UpdateHandCardWitness(false)
@ -83,6 +103,8 @@ function M:InitView()
info:FillData(p)
info._view.visible = true
end
end
local btn_rule = self._view:GetChild('btn_rule')
if btn_rule ~= nil then
@ -145,11 +167,21 @@ function M:EventInit()
self:PlayMJSound("user_enter.mp3")
local arg = { ... }
local p = arg[1]
local info = self._player_info[self:GetPos(p.seat)]
info:FillData(p)
info._view.visible = true
info:SetPlayer(p)
info:FillData()
local info1 = self._player_info[self:GetPos(p.seat)]
info1:FillData(p)
info1._view.visible = true
local info2 = self._player_card_info[self:GetPos(p.seat)]
info2:SetPlayer(p)
info2:FillData()
end)
_gamectr:AddEventListener(GameEvent.PlayerLeave, function(...)
local arg = { ... }
local p = arg[1]
local info1 = self._player_info[self:GetPos(p.seat)]
info1._view.visible = false
self:PlayMJSound("user_leave.mp3")
end)
_gamectr:AddEventListener(GameEvent.WitnessPlayerEnter, function(...)
@ -277,6 +309,7 @@ function M:EventInit()
_gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self, self.OnFangziAction))
_gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...)
self._popEvent = false
self._left_time = 0
self:UpdateCardBox(0)
local arg = { ... }
@ -433,10 +466,12 @@ function M:EventInit()
local result = arg[1]
local over = arg[3]
self._clearingView = EXClearingView.new()
if over ~= 2 or _room.curren_round > 0 then
coroutine.start(function()
coroutine.wait(0.5)
self._clearingView:Show()
end)
end
self._clearingView:InitData(over, _room, result, total_result)
ControllerManager.ChangeController(LoddyController)
end)
@ -496,17 +531,54 @@ function M:OnFangziAction(...)
local info = _player_card_info[self:GetPos(player.seat)]
-- local pNode = info._mask_liangpai
local arg = { ... }
local _player_card_info = self._player_card_info
local fz = arg[1]
local player = arg[2]
local index = arg[3]
local info = _player_card_info[self:GetPos(player.seat)]
-- local pNode = info._mask_liangpai
local effect = UIPackage.CreateObject("Extend_MJ_JinXi", "FzEffect")
if fz.type == FZType.Peng then
self:PlaySound("JinXi_MJ", player.self_user.sex, "peng")
effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "")
effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "")
-- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "碰框")
elseif fz.type == FZType.Chi then
self:PlaySound("JinXi_MJ", player.self_user.sex, "chi")
effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "")
effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "")
else
self:PlaySound("JinXi_MJ", player.self_user.sex, "gang")
effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "")
effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "")
-- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框")
end
effect.touchable = false
effect:GetTransition("t2"):Play()
-- pNode:AddChild(effect)
coroutine.start(function()
coroutine.wait(0.3)
self._popEvent = true
end)
coroutine.start(function()
coroutine.wait(2)
effect:Dispose()
end)
self:RemoveCursor()
if (player.seat ~= fz.from_seat) then
local fs_info = _player_card_info[self:GetPos(fz.from_seat)]
fs_info:UpdateOutCardList()
end
local seat = (self._room.room_config.people_num == 2 and fz.from_seat == 2) and 2 or fz.from_seat - 1
info:UpdateFzList(fz, index, true, seat)
info:UpdateFzList(fz, index, true)
local getcard = fz.type == FZType.Peng or fz.type == FZType.Chi
--printlog(getcard)
--因为观战没有手牌,等预处理完扣牌数之后矫正一次(最粗暴的修正方式手牌数等于13-3*吃碰数)
info._player.hand_left_count = info._player.hand_left_count - 1
info._player.hand_left_count = 14 - 3 * #info._player.fz_list
info:UpdateHandCardWitness(true)
-- self:__CloseTip()
end
@ -551,27 +623,6 @@ end
-- end
-- end
function M:OnUpdate()
if (self._popEvent) then
local func = self._gamectr:PopEvent()
if (func ~= nil) then
local success, result = pcall(func)
if success then
else
print("witness error")
print(result)
error(result)
-- self._gamectr = ControllerManager.GetController(GameController)
-- if self._gamectr then
-- self._gamectr:ResetConnect()
-- end
end
--func()
end
end
end
function M:ResetConnect()
end

View File

@ -66,13 +66,33 @@ function M:InitView(url)
self:InitPlayerInfoView()
self._player_card_info = {}
local _player_card_info = self._player_card_info
for i = 1, #room.player_list do
if room.curren_round > 0 then
for i = 1, #room.room_config.people_num do
local p = room.player_list[i]
local index = self:GetPos(p.seat)
print("lingmeng index", index)
local info = self._player_info[index]
local tem = self._view:GetChild("player_card_info" .. index)
_player_card_info[index] = self:NewMJPlayerCardInfoView(tem, index)
local info = self._player_info[i]
local tem = self._view:GetChild("player_card_info" .. i)
_player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i)
local cardInfo = _player_card_info[i]
cardInfo:SetPlayer(p)
cardInfo:UpdateHandCardWitness(false)
cardInfo:UpdateOutCardList(nil, nil, self._cursor)
for i = 1, #p.fz_list do
cardInfo:UpdateFzList(p.fz_list[i], -1)
end
info:FillData(p)
info._view.visible = false
end
else
for i = 1, room.room_config.people_num do
local tem = self._view:GetChild("player_card_info" .. i)
_player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i)
end
for i = 1, #room.player_list do
local p = room.player_list[i]
local index = self:GetPos(p.seat)
local info = self._player_info[i]
local cardInfo = _player_card_info[index]
cardInfo:SetPlayer(p)
cardInfo:UpdateHandCardWitness(false)
@ -83,6 +103,8 @@ function M:InitView(url)
info:FillData(p)
info._view.visible = true
end
end
local btn_rule = self._view:GetChild('btn_rule')
if btn_rule ~= nil then
@ -145,11 +167,21 @@ function M:EventInit()
self:PlayMJSound("user_enter.mp3")
local arg = { ... }
local p = arg[1]
local info = self._player_info[self:GetPos(p.seat)]
info:FillData(p)
info._view.visible = true
info:SetPlayer(p)
info:FillData()
local info1 = self._player_info[self:GetPos(p.seat)]
info1:FillData(p)
info1._view.visible = true
local info2 = self._player_card_info[self:GetPos(p.seat)]
info2:SetPlayer(p)
info2:FillData()
end)
_gamectr:AddEventListener(GameEvent.PlayerLeave, function(...)
local arg = { ... }
local p = arg[1]
local info1 = self._player_info[self:GetPos(p.seat)]
info1._view.visible = false
self:PlayMJSound("user_leave.mp3")
end)
_gamectr:AddEventListener(GameEvent.WitnessPlayerEnter, function(...)
@ -160,7 +192,6 @@ function M:EventInit()
local _room = DataManager.CurrenRoom
local viewList_witness = self._view:GetChild('comp_witness'):GetChild('list_players')
print("linemng tcp", _room._flag_updateWitness, #_room.witness_player_list, viewList_witness.numItems)
if viewList_witness.numItems == #_room.witness_player_list then
viewList_witness:RefreshVirtualList()
else
@ -277,6 +308,7 @@ function M:EventInit()
_gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self, self.OnFangziAction))
_gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...)
self._popEvent = false
self._left_time = 0
self:UpdateCardBox(0)
local arg = { ... }
@ -433,10 +465,12 @@ function M:EventInit()
local result = arg[1]
local over = arg[3]
self._clearingView = EXClearingView.new()
if over ~= 2 or _room.curren_round > 0 then
coroutine.start(function()
coroutine.wait(0.5)
self._clearingView:Show()
end)
end
self._clearingView:InitData(over, _room, result, total_result)
ControllerManager.ChangeController(LoddyController)
end)
@ -496,17 +530,54 @@ function M:OnFangziAction(...)
local info = _player_card_info[self:GetPos(player.seat)]
-- local pNode = info._mask_liangpai
local arg = { ... }
local _player_card_info = self._player_card_info
local fz = arg[1]
local player = arg[2]
local index = arg[3]
local info = _player_card_info[self:GetPos(player.seat)]
-- local pNode = info._mask_liangpai
local effect = UIPackage.CreateObject("Extend_MJ_JinXi", "FzEffect")
if fz.type == FZType.Peng then
self:PlaySound("JinXi_MJ", player.self_user.sex, "peng")
effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "")
effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "")
-- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "碰框")
elseif fz.type == FZType.Chi then
self:PlaySound("JinXi_MJ", player.self_user.sex, "chi")
effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "")
effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "")
else
self:PlaySound("JinXi_MJ", player.self_user.sex, "gang")
effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "")
effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "")
-- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框")
end
effect.touchable = false
effect:GetTransition("t2"):Play()
-- pNode:AddChild(effect)
coroutine.start(function()
coroutine.wait(0.3)
self._popEvent = true
end)
coroutine.start(function()
coroutine.wait(2)
effect:Dispose()
end)
self:RemoveCursor()
if (player.seat ~= fz.from_seat) then
local fs_info = _player_card_info[self:GetPos(fz.from_seat)]
fs_info:UpdateOutCardList()
end
local seat = (self._room.room_config.people_num == 2 and fz.from_seat == 2) and 2 or fz.from_seat - 1
info:UpdateFzList(fz, index, true, seat)
info:UpdateFzList(fz, index, true)
local getcard = fz.type == FZType.Peng or fz.type == FZType.Chi
--printlog(getcard)
--因为观战没有手牌,等预处理完扣牌数之后矫正一次(最粗暴的修正方式手牌数等于13-3*吃碰数)
info._player.hand_left_count = info._player.hand_left_count - 1
info._player.hand_left_count = 14 - 3 * #info._player.fz_list
info:UpdateHandCardWitness(true)
-- self:__CloseTip()
end
@ -551,27 +622,6 @@ end
-- end
-- end
function M:OnUpdate()
if (self._popEvent) then
local func = self._gamectr:PopEvent()
if (func ~= nil) then
local success, result = pcall(func)
if success then
else
print("witness error")
print(result)
error(result)
-- self._gamectr = ControllerManager.GetController(GameController)
-- if self._gamectr then
-- self._gamectr:ResetConnect()
-- end
end
--func()
end
end
end
function M:ResetConnect()
end

View File

@ -66,13 +66,33 @@ function M:InitView()
self:InitPlayerInfoView()
self._player_card_info = {}
local _player_card_info = self._player_card_info
for i = 1, #room.player_list do
if room.curren_round > 0 then
for i = 1, #room.room_config.people_num do
local p = room.player_list[i]
local index = self:GetPos(p.seat)
print("lingmeng index", index)
local info = self._player_info[index]
local tem = self._view:GetChild("player_card_info" .. index)
_player_card_info[index] = self:NewMJPlayerCardInfoView(tem, index)
local info = self._player_info[i]
local tem = self._view:GetChild("player_card_info" .. i)
_player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i)
local cardInfo = _player_card_info[i]
cardInfo:SetPlayer(p)
cardInfo:UpdateHandCardWitness(false)
cardInfo:UpdateOutCardList(nil, nil, self._cursor)
for i = 1, #p.fz_list do
cardInfo:UpdateFzList(p.fz_list[i], -1)
end
info:FillData(p)
info._view.visible = false
end
else
for i = 1, room.room_config.people_num do
local tem = self._view:GetChild("player_card_info" .. i)
_player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i)
end
for i = 1, #room.player_list do
local p = room.player_list[i]
local index = self:GetPos(p.seat)
local info = self._player_info[i]
local cardInfo = _player_card_info[index]
cardInfo:SetPlayer(p)
cardInfo:UpdateHandCardWitness(false)
@ -83,6 +103,8 @@ function M:InitView()
info:FillData(p)
info._view.visible = true
end
end
local btn_rule = self._view:GetChild('btn_rule')
if btn_rule ~= nil then
@ -145,11 +167,21 @@ function M:EventInit()
self:PlayMJSound("user_enter.mp3")
local arg = { ... }
local p = arg[1]
local info = self._player_info[self:GetPos(p.seat)]
info:FillData(p)
info._view.visible = true
info:SetPlayer(p)
info:FillData()
local info1 = self._player_info[self:GetPos(p.seat)]
info1:FillData(p)
info1._view.visible = true
local info2 = self._player_card_info[self:GetPos(p.seat)]
info2:SetPlayer(p)
info2:FillData()
end)
_gamectr:AddEventListener(GameEvent.PlayerLeave, function(...)
local arg = { ... }
local p = arg[1]
local info1 = self._player_info[self:GetPos(p.seat)]
info1._view.visible = false
self:PlayMJSound("user_leave.mp3")
end)
_gamectr:AddEventListener(GameEvent.WitnessPlayerEnter, function(...)
@ -277,6 +309,7 @@ function M:EventInit()
_gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self, self.OnFangziAction))
_gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...)
self._popEvent = false
self._left_time = 0
self:UpdateCardBox(0)
local arg = { ... }
@ -433,10 +466,12 @@ function M:EventInit()
local result = arg[1]
local over = arg[3]
self._clearingView = EXClearingView.new()
if over ~= 2 or _room.curren_round > 0 then
coroutine.start(function()
coroutine.wait(0.5)
self._clearingView:Show()
end)
end
self._clearingView:InitData(over, _room, result, total_result)
ControllerManager.ChangeController(LoddyController)
end)
@ -496,17 +531,54 @@ function M:OnFangziAction(...)
local info = _player_card_info[self:GetPos(player.seat)]
-- local pNode = info._mask_liangpai
local arg = { ... }
local _player_card_info = self._player_card_info
local fz = arg[1]
local player = arg[2]
local index = arg[3]
local info = _player_card_info[self:GetPos(player.seat)]
-- local pNode = info._mask_liangpai
local effect = UIPackage.CreateObject("Extend_MJ_NanCheng", "FzEffect")
if fz.type == FZType.Peng then
self:PlaySound("NanCheng_MJ", player.self_user.sex, "peng")
effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "")
effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "")
-- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "碰框")
elseif fz.type == FZType.Chi then
self:PlaySound("NanCheng_MJ", player.self_user.sex, "chi")
effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "")
effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "")
else
self:PlaySound("NanCheng_MJ", player.self_user.sex, "gang")
effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "")
effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "")
-- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框")
end
effect.touchable = false
effect:GetTransition("t2"):Play()
-- pNode:AddChild(effect)
coroutine.start(function()
coroutine.wait(0.3)
self._popEvent = true
end)
coroutine.start(function()
coroutine.wait(2)
effect:Dispose()
end)
self:RemoveCursor()
if (player.seat ~= fz.from_seat) then
local fs_info = _player_card_info[self:GetPos(fz.from_seat)]
fs_info:UpdateOutCardList()
end
local seat = (self._room.room_config.people_num == 2 and fz.from_seat == 2) and 2 or fz.from_seat - 1
info:UpdateFzList(fz, index, true, seat)
info:UpdateFzList(fz, index, true)
local getcard = fz.type == FZType.Peng or fz.type == FZType.Chi
--printlog(getcard)
--因为观战没有手牌,等预处理完扣牌数之后矫正一次(最粗暴的修正方式手牌数等于13-3*吃碰数)
info._player.hand_left_count = info._player.hand_left_count - 1
info._player.hand_left_count = 14 - 3 * #info._player.fz_list
info:UpdateHandCardWitness(true)
-- self:__CloseTip()
end
@ -551,27 +623,6 @@ end
-- end
-- end
function M:OnUpdate()
if (self._popEvent) then
local func = self._gamectr:PopEvent()
if (func ~= nil) then
local success, result = pcall(func)
if success then
else
print("witness error")
print(result)
error(result)
-- self._gamectr = ControllerManager.GetController(GameController)
-- if self._gamectr then
-- self._gamectr:ResetConnect()
-- end
end
--func()
end
end
end
function M:ResetConnect()
end