changhong/lua_probject/extend_project/extend/zipai/fanpaofa/EXGameController.lua

622 lines
21 KiB
Lua
Raw Normal View History

2025-05-25 11:35:02 +08:00
local RB_Protocol = import(".Protocol")
local FZTipList = import(".main.FZData")
local FanPaoFa_GameEvent = import(".FanPaoFa_GameEvent")
local M = {}
--- Create a new HZ_GameController
function M.new()
2025-06-23 04:57:54 +08:00
setmetatable(M, { __index = GameController })
local self = setmetatable({}, { __index = M })
self:init("放炮罚")
self.class = "RB_GameController"
return self
2025-05-25 11:35:02 +08:00
end
function M:init(name)
2025-06-23 04:57:54 +08:00
GameController.init(self, name)
2025-05-25 11:35:02 +08:00
self._eventmap[RB_Protocol.GAME_EVT_PLAYER_DEAL] = self.OnEventSendCards
self._eventmap[RB_Protocol.GAME_EVT_CHANGE_ACTIVE_PLAYER] = self.OnEventTurn
self._eventmap[RB_Protocol.GAME_EVT_DRAW] = self.OnEventTakeCard
self._eventmap[RB_Protocol.GAME_EVT_DISCARD_TIP] = self.OnEventOutHint
self._eventmap[RB_Protocol.GAME_EVT_DISCARD] = self.OnEventOutCard
self._eventmap[RB_Protocol.GAME_EVT_FZTIPS] = self.OnEventFzTips
self._eventmap[RB_Protocol.GAME_EVT_ACTION] = self.OnEventFzAction
self._eventmap[RB_Protocol.GAME_EVT_HU] = self.OnEventHu
self._eventmap[RB_Protocol.GAME_EVT_FANGPAO_TIP] = self.OnEventFangWei
2025-05-26 23:26:09 +08:00
self._eventmap[RB_Protocol.GAME_EVT_FANGPAO_RSP] = self.OnEventFangPaoOk
2025-05-25 11:35:02 +08:00
self._eventmap[RB_Protocol.GAME_EVT_DANIAO_TIP] = self.OnEventDaNiaoTip
2025-05-25 20:45:04 +08:00
self._eventmap[RB_Protocol.GAME_EVT_DANIAO] = self.OnEventDaNiao
2025-05-25 11:35:02 +08:00
self._eventmap[RB_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai
2025-06-23 04:57:54 +08:00
self._eventmap[RB_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim
2025-05-25 11:35:02 +08:00
self._eventmap[RB_Protocol.GAME_EVT_RESULT1] = self.OneventResult1
self._eventmap[RB_Protocol.GAME_EVT_QIPAI] = self.OnEventQIPAI
self._eventmap[RB_Protocol.GAME_EVT_ADD_CARD] = self.OnAddCard
end
function M:SendXiPaiAction(callBack)
local _data = {}
2025-06-23 04:57:54 +08:00
local _client = ControllerManager.GameNetClinet
2025-05-25 11:35:02 +08:00
_client:send(RB_Protocol.GAME_XIPAI, _data)
2025-06-23 04:57:54 +08:00
self.XiPaiCallBack = callBack
2025-05-25 11:35:02 +08:00
end
function M:OnEventDaNiaoTip(evt_data)
2025-06-23 04:57:54 +08:00
if ViewManager.GetCurrenView().dview_class == LobbyView then
2025-05-25 11:35:02 +08:00
self:ReturnToRoom()
return
end
2025-05-25 20:45:04 +08:00
self._cacheEvent:Enqueue(
function()
2025-07-06 00:53:24 +08:00
if self._callback_popEvent then
self._callback_popEvent(true)
end
local niao = evt_data["niao"]
local reload = evt_data["reload"]
2025-06-23 04:57:54 +08:00
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.OnDaNiaoTips, niao, reload)
ControllerManager.IsSendCard = true
2025-05-25 20:45:04 +08:00
end
)
end
2025-06-23 04:57:54 +08:00
function M:SendNiao(niao, callBack)
2025-05-25 20:45:04 +08:00
local _data = {}
_data["niaoflag"] = niao
local _client = ControllerManager.GameNetClinet
_client:send(RB_Protocol.GAME_EVT_SEND_NIAO, _data)
2025-06-23 04:57:54 +08:00
self.NiaoTipsCallBack = callBack
2025-05-25 20:45:04 +08:00
end
function M:OnEventDaNiao(evt_data)
2025-05-25 11:35:02 +08:00
self._cacheEvent:Enqueue(
function()
2025-07-06 00:53:24 +08:00
if self._callback_popEvent then
self._callback_popEvent(true)
end
local seat = evt_data["seat"]
local niao = evt_data["niao"]
if seat == DataManager.CurrenRoom.self_player.seat then
if self.NiaoTipsCallBack then
self.NiaoTipsCallBack()
self.NiaoTipsCallBack = nil
end
end
2025-06-23 04:57:54 +08:00
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.OnEventDaNiao, seat, niao)
2025-05-25 11:35:02 +08:00
end
)
end
function M:OnEventXiPai(evt_data)
2025-06-23 04:57:54 +08:00
if evt_data["result"] == 0 then
if self.XiPaiCallBack then
self.XiPaiCallBack()
end
else
ViewUtil.ErrorTip(1000000, "申请洗牌失败")
end
2025-05-25 11:35:02 +08:00
end
function M:OnEventXiPaiAnim(evt_data)
2025-07-06 00:53:24 +08:00
self._cacheEvent:Enqueue(function()
local playeridList = evt_data["list"]
local isXiPai = false
local otherisXiPai = false
if playeridList and #playeridList > 0 then
for i = 1, #playeridList do
local p = self._room:GetPlayerById(playeridList[i])
if p == self._room.self_player then
isXiPai = true
else
otherisXiPai = true
end
2025-06-23 04:57:54 +08:00
end
end
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.EventXiPai, isXiPai, otherisXiPai)
end)
2025-05-25 11:35:02 +08:00
end
-- 发送出牌指令到服务器
function M:SendOutCard(card)
local _data = {}
_data["card"] = card
local _room = self._room
2025-06-23 04:57:54 +08:00
local _client = ControllerManager.GameNetClinet
2025-05-25 11:35:02 +08:00
if _client ~= nil then
_client:send(RB_Protocol.GAME_DIS_CARD, _data)
end
end
2025-06-23 04:57:54 +08:00
2025-05-25 11:35:02 +08:00
--GAME_CHANGE_CARD GAME_DIS_CARD
2025-06-23 04:57:54 +08:00
function M:SendChangeCards(card_list)
2025-05-25 11:35:02 +08:00
local _data = {}
2025-06-23 04:57:54 +08:00
if card_list then
_data["card_list"] = card_list
else
_data["card_list"] = {}
end
local _client = ControllerManager.GameNetClinet
2025-05-25 11:35:02 +08:00
if _client ~= nil then
2025-06-23 04:57:54 +08:00
_client:send(RB_Protocol.GAME_CHANGE_CARD, _data)
2025-05-25 11:35:02 +08:00
end
end
function M:SendFangPao(card)
local _data = {}
2025-06-23 04:57:54 +08:00
if card then
_data["card"] = card
else
_data["card"] = {}
end
2025-05-26 23:26:09 +08:00
2025-06-23 04:57:54 +08:00
local _client = ControllerManager.GameNetClinet
2025-05-25 11:35:02 +08:00
if _client ~= nil then
2025-05-26 23:26:09 +08:00
_client:send(RB_Protocol.GAME_EVT_FANGPAO, _data)
2025-05-25 11:35:02 +08:00
end
end
function M:SendChangeTypeFace(TypeFace)
-- body
local _data = {}
_data["typeface"] = TypeFace
2025-06-23 04:57:54 +08:00
local _client = ControllerManager.GameNetClinet
2025-05-25 11:35:02 +08:00
if _client ~= nil then
2025-06-23 04:57:54 +08:00
_client:send(RB_Protocol.GAME_CHANGE_TYPEfACE, _data)
2025-05-25 11:35:02 +08:00
end
end
2025-06-23 04:57:54 +08:00
function M:ConformToNextGame()
local _client = ControllerManager.GameNetClinet
2025-05-25 11:35:02 +08:00
if _client ~= nil then
2025-06-23 04:57:54 +08:00
_client:send(RB_Protocol.GAME_EVT_CHUI)
2025-05-25 11:35:02 +08:00
end
end
-- 发送放子选择到服务器
2025-06-23 04:57:54 +08:00
function M:SendAction(id, num)
2025-05-25 11:35:02 +08:00
local _data = {}
_data["id"] = id
2025-06-23 04:57:54 +08:00
if num ~= nil then
2025-05-25 11:35:02 +08:00
_data["biid"] = num
end
local _client = ControllerManager.GameNetClinet
2025-06-23 04:57:54 +08:00
if _client ~= nil then
_client:send(RB_Protocol.GAME_ACTION, _data)
2025-05-25 11:35:02 +08:00
end
end
function M:OnEventSendCards(evt_data)
if ViewManager.GetCurrenView().dview_class == LobbyView then
self:ReturnToRoom()
return
end
self._cacheEvent:Enqueue(function()
2025-07-06 00:53:24 +08:00
if self._callback_popEvent then
self._callback_popEvent(true)
end
local _room = self._room
_room.curren_round = _room.curren_round + 1
if _room.curren_round > 0 then _room.playing = true end
local handcards = {}
if evt_data.card_list and #evt_data.card_list > 0 then
handcards = evt_data["card_list"]
else
ViewUtil.ErrorTip(100000, "发牌数据异常")
end
local p = _room.self_player
local seat = nil
if evt_data.bank_seat then
seat = evt_data["bank_seat"]
else
ViewUtil.ErrorTip(100001, "发牌座位异常")
end
_room.banker_seat = seat
for i = 1, #_room.player_list do
_room.self_player.handcard_list = {}
_room.self_player.card_list = {}
_room.player_list[i].hand_left_count = 20
_room.player_list[i].fz_list = {}
_room.player_list[i].card_list = {}
_room.player_list[i].outcard_list = {}
_room.player_list[i].hu_xi = 0
end
2025-06-23 04:57:54 +08:00
_room.self_player.handcard_list = handcards
2025-05-25 11:35:02 +08:00
self._room.self_player.hand_left_count = #handcards
2025-06-23 04:57:54 +08:00
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.SendCards, p)
ControllerManager.IsSendCard = true
end)
2025-05-25 11:35:02 +08:00
end
function M:OnEventOutCard(evt_data)
local seat = evt_data["seat"]
local card = evt_data["card"]
2025-06-20 11:52:54 +08:00
--printlog("jefe OnEventOutCard>>>>",card)
2025-05-25 11:35:02 +08:00
-- 判断是否对方有偎
2025-06-23 04:57:54 +08:00
2025-05-25 11:35:02 +08:00
local p = self._room:GetPlayerBySeat(seat)
self._cacheEvent:Enqueue(function()
2025-06-23 04:57:54 +08:00
local _room = self._room
if (seat == _room.self_player.seat) then
list_remove(_room.self_player.handcard_list, card)
2025-05-25 11:35:02 +08:00
end
p.DiceCard = card
2025-06-23 04:57:54 +08:00
p.hand_left_count = p.hand_left_count - 1
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.OutCard, p, card)
2025-05-25 11:35:02 +08:00
end)
end
function M:OnEventQIPAI(evt_data)
local seat = evt_data["seat"]
local card = evt_data["card"]
local p = self._room:GetPlayerBySeat(seat)
self._cacheEvent:Enqueue(function()
2025-07-06 00:53:24 +08:00
if self._callback_popEvent then
self._callback_popEvent(true)
end
2025-06-23 04:57:54 +08:00
local _room = self._room
if (not p.outcard_list) then p.outcard_list = {} end
p.outcard_list[#p.outcard_list + 1] = card
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.QiCard, seat, card)
2025-05-25 11:35:02 +08:00
end)
end
function M:OnEventTakeCard(evt_data)
local _room = self._room
local seat = evt_data["seat"]
local card = evt_data["card"]
local left_count = evt_data["left_count"]
local p = _room:GetPlayerBySeat(seat)
self._cacheEvent:Enqueue(function()
2025-07-06 00:53:24 +08:00
if self._callback_popEvent then
self._callback_popEvent(true)
end
2025-06-23 04:57:54 +08:00
if card ~= 0 then
2025-05-25 11:35:02 +08:00
p.DiceCard = card
end
2025-06-23 04:57:54 +08:00
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.GetCard, seat, card, left_count)
2025-05-25 11:35:02 +08:00
end)
end
function M:OnAddCard(evt_data)
local _room = self._room
local seat = evt_data["seat"]
local card = evt_data["card"]
local p = _room:GetPlayerBySeat(seat)
2025-06-23 04:57:54 +08:00
2025-05-25 11:35:02 +08:00
self._cacheEvent:Enqueue(function()
if self._callback_popEvent then
self._callback_popEvent(true)
end
2025-05-25 11:35:02 +08:00
p.DiceCard = card
2025-06-23 04:57:54 +08:00
p.hand_left_count = p.hand_left_count + 1
2025-05-25 11:35:02 +08:00
if (seat == _room.self_player.seat) then
2025-06-23 04:57:54 +08:00
_room.self_player.handcard_list[#_room.self_player.handcard_list + 1] = card
2025-05-25 11:35:02 +08:00
end
2025-06-23 04:57:54 +08:00
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.AddCard, seat, card)
2025-05-25 11:35:02 +08:00
end)
end
function M:OnEventOutHint(evt_data)
self._cacheEvent:Enqueue(function()
2025-07-06 00:53:24 +08:00
if self._callback_popEvent then
self._callback_popEvent(true)
end
2025-06-23 04:57:54 +08:00
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.OutHint)
2025-05-25 11:35:02 +08:00
end)
end
function M:OnEventTurn(evt_data)
local seat = evt_data["seat"]
self._cacheEvent:Enqueue(function()
2025-07-06 00:53:24 +08:00
if self._callback_popEvent then
self._callback_popEvent(true)
end
2025-06-23 04:57:54 +08:00
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.EventTurn, seat)
2025-05-25 11:35:02 +08:00
end)
end
function M:OnEventFzTips(evt_data)
self._cacheEvent:Enqueue(function()
2025-07-06 00:53:24 +08:00
if self._callback_popEvent then
self._callback_popEvent(true)
end
2025-05-25 11:35:02 +08:00
local tiplist = FZTipList.new()
2025-06-23 04:57:54 +08:00
local list = evt_data["tip_list"]
local uid = evt_data["uid"]
2025-05-25 11:35:02 +08:00
local fptype = evt_data['fptype']
2025-06-23 04:57:54 +08:00
for i = 1, #list do
local dtip = list[i]
local tip = {}
tip.id = dtip["id"]
-- if false then
tip.weight = dtip["weight"]
tip.card = dtip["card"]
tip.type = dtip["type"]
tip.bi_list = dtip["bi_list"]
if (dtip["opcard"]) then
local opcard = dtip["opcard"]
tip.OpCard = opcard
table.sort(tip.OpCard)
tip.OpCard[3] = tip.Card
2025-05-25 11:35:02 +08:00
end
2025-06-23 04:57:54 +08:00
tiplist:AddTip(tip)
-- end
end
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.FZTips, tiplist, uid, fptype)
2025-05-25 11:35:02 +08:00
end)
end
-- 放喂提示
function M:OnEventFangWei(evt_data)
2025-06-23 04:57:54 +08:00
local seat = evt_data["seat"]
local card = evt_data["card"]
2025-05-25 11:35:02 +08:00
self._cacheEvent:Enqueue(function()
2025-07-06 00:53:24 +08:00
if self._callback_popEvent then
self._callback_popEvent(true)
end
2025-06-23 04:57:54 +08:00
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.FangWei, seat, card)
2025-05-25 11:35:02 +08:00
end)
end
2025-05-26 23:26:09 +08:00
--放跑成功
function M:OnEventFangPaoOk(evt_data)
2025-06-23 04:57:54 +08:00
local seat = evt_data["seat"]
local card = evt_data["card"]
2025-05-26 23:26:09 +08:00
self._cacheEvent:Enqueue(function()
2025-07-06 00:53:24 +08:00
if self._callback_popEvent then
self._callback_popEvent(true)
end
2025-06-23 04:57:54 +08:00
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.FangPaoOk, seat, card)
2025-05-26 23:26:09 +08:00
end)
end
2025-05-25 11:35:02 +08:00
function M:OnEventFzAction(evt_data)
local _room = self._room
local playerid = evt_data["playerid"]
local card = evt_data["card"]
local actice_card = evt_data["active_card"]
local ftype = evt_data["type"]
local from_seat = evt_data["from_seat"]
local opcard = evt_data["opcard"]
local huxi = evt_data["hu_xi"]
local p = _room:GetPlayerById(playerid)
self._cacheEvent:Enqueue(function()
2025-06-23 04:57:54 +08:00
local isNeedDelHandCard = 0
2025-06-29 22:21:50 +08:00
local flag_pengPao = false
2025-06-23 04:57:54 +08:00
p.hu_xi = huxi
local fz = {}
fz.card = card
fz.type = ftype
fz.active_card = actice_card
fz.from_seat = from_seat
fz.opcard = opcard
local remove_num = #opcard
if ftype == RB_FZType.Chi then
p.fz_list[#p.fz_list + 1] = fz
2025-05-25 11:35:02 +08:00
if (p == _room.self_player) then
2025-06-23 04:57:54 +08:00
for i = 1, remove_num do
list_remove(_room.self_player.handcard_list, opcard[i])
2025-05-25 11:35:02 +08:00
end
end
elseif ftype == RB_FZType.Bi then
2025-06-23 04:57:54 +08:00
p.fz_list[#p.fz_list + 1] = fz
2025-05-25 11:35:02 +08:00
if (p == _room.self_player) then
2025-06-23 04:57:54 +08:00
for i = 1, remove_num do
list_remove(_room.self_player.handcard_list, opcard[i])
2025-05-25 11:35:02 +08:00
end
2025-06-23 04:57:54 +08:00
list_remove(_room.self_player.handcard_list, fz.card)
2025-05-25 11:35:02 +08:00
end
elseif ftype == RB_FZType.Peng then
2025-06-23 04:57:54 +08:00
p.fz_list[#p.fz_list + 1] = fz
2025-05-25 11:35:02 +08:00
if (p == _room.self_player) then
2025-06-23 04:57:54 +08:00
for i = 1, remove_num do
list_remove(_room.self_player.handcard_list, opcard[i])
2025-05-25 11:35:02 +08:00
end
end
elseif ftype == RB_FZType.Kan then
if (p == _room.self_player) then
2025-06-23 04:57:54 +08:00
if #opcard == 2 then
_room.self_player.handcard_list[#_room.self_player.handcard_list + 1] = card
2025-05-25 11:35:02 +08:00
end
2025-06-23 04:57:54 +08:00
p.fz_list[#p.fz_list + 1] = fz
2025-05-25 11:35:02 +08:00
end
elseif ftype == RB_FZType.ChouWei then
2025-06-23 04:57:54 +08:00
p.fz_list[#p.fz_list + 1] = fz
2025-05-25 11:35:02 +08:00
if (p == _room.self_player) then
2025-06-23 04:57:54 +08:00
for i = 1, 2 do
list_remove(_room.self_player.handcard_list, opcard[i])
2025-05-25 11:35:02 +08:00
end
2025-06-23 04:57:54 +08:00
end
2025-05-25 11:35:02 +08:00
elseif ftype == RB_FZType.Wei then
2025-06-23 04:57:54 +08:00
p.fz_list[#p.fz_list + 1] = fz
2025-05-25 11:35:02 +08:00
if (p == _room.self_player) then
2025-06-23 04:57:54 +08:00
for i = 1, remove_num do
list_remove(_room.self_player.handcard_list, opcard[i])
2025-05-25 11:35:02 +08:00
end
2025-06-23 04:57:54 +08:00
end
2025-05-25 11:35:02 +08:00
elseif ftype == RB_FZType.Pao then
2025-06-23 04:57:54 +08:00
if (p == _room.self_player) then
for i = 1, #p.fz_list do
2025-05-25 11:35:02 +08:00
if p.fz_list[i].card == card then
2025-07-06 06:32:30 +08:00
flag_pengPao = true
2025-05-25 11:35:02 +08:00
if p.fz_list[i].type == RB_FZType.Kan then
2025-06-23 04:57:54 +08:00
isNeedDelHandCard = 3
for i = 1, remove_num do
list_remove(_room.self_player.handcard_list, opcard[i])
2025-05-25 11:35:02 +08:00
end
2025-07-06 06:32:30 +08:00
flag_pengPao = false
2025-05-25 11:35:02 +08:00
end
2025-06-23 04:57:54 +08:00
remove_num = 0
p.fz_list[i].type = RB_FZType.Pao
2025-05-25 11:35:02 +08:00
end
end
2025-06-23 04:57:54 +08:00
local num = 0
for i = 1, #_room.self_player.handcard_list do
2025-05-25 11:35:02 +08:00
if card == _room.self_player.handcard_list[i] then
2025-06-23 04:57:54 +08:00
num = num + 1
2025-05-25 11:35:02 +08:00
end
end
2025-06-23 04:57:54 +08:00
if num > 0 then
isNeedDelHandCard = num
2025-05-25 11:35:02 +08:00
2025-06-23 04:57:54 +08:00
for i = 1, num do
list_remove(_room.self_player.handcard_list, card)
2025-05-25 11:35:02 +08:00
end
2025-06-23 04:57:54 +08:00
local isAddTi = false
for i = 1, #p.fz_list do
2025-05-25 11:35:02 +08:00
if p.fz_list[i].card == card then
2025-06-23 04:57:54 +08:00
p.fz_list[i].type = RB_FZType.Pao
isAddTi = true
remove_num = 0
2025-07-06 06:32:30 +08:00
flag_pengPao = true
2025-05-25 11:35:02 +08:00
end
end
2025-06-23 04:57:54 +08:00
if isAddTi == false then
p.fz_list[#p.fz_list + 1] = fz
2025-05-25 11:35:02 +08:00
end
end
else
2025-06-23 04:57:54 +08:00
local num = 0
for i = 1, #p.fz_list do
2025-05-25 11:35:02 +08:00
if p.fz_list[i].card == card then
2025-06-23 04:57:54 +08:00
p.fz_list[i].type = RB_FZType.Pao
num = 1
remove_num = 0
2025-06-29 22:21:50 +08:00
flag_pengPao = true
2025-05-25 11:35:02 +08:00
end
end
2025-06-23 04:57:54 +08:00
if num == 0 then
p.fz_list[#p.fz_list + 1] = fz
2025-05-25 11:35:02 +08:00
end
2025-06-23 04:57:54 +08:00
end
2025-05-25 11:35:02 +08:00
elseif ftype == RB_FZType.Ti then
if (p == _room.self_player) then
2025-06-23 04:57:54 +08:00
for i = 1, #p.fz_list do
2025-05-25 11:35:02 +08:00
if p.fz_list[i].card == card then
if p.fz_list[i].type == RB_FZType.Kan then
2025-06-23 04:57:54 +08:00
isNeedDelHandCard = 3
for i = 1, remove_num do
list_remove(_room.self_player.handcard_list, opcard[i])
2025-05-25 11:35:02 +08:00
end
end
2025-06-23 04:57:54 +08:00
remove_num = 0
p.fz_list[i].type = RB_FZType.Ti
2025-05-25 11:35:02 +08:00
end
end
2025-06-23 04:57:54 +08:00
local num = 0
for i = 1, #_room.self_player.handcard_list do
2025-05-25 11:35:02 +08:00
if card == _room.self_player.handcard_list[i] then
2025-06-23 04:57:54 +08:00
num = num + 1
2025-05-25 11:35:02 +08:00
end
end
2025-06-23 04:57:54 +08:00
if num > 0 then
isNeedDelHandCard = num
2025-05-25 11:35:02 +08:00
2025-06-23 04:57:54 +08:00
for i = 1, num do
list_remove(_room.self_player.handcard_list, card)
2025-05-25 11:35:02 +08:00
end
2025-06-23 04:57:54 +08:00
local isAddTi = false
for i = 1, #p.fz_list do
2025-05-25 11:35:02 +08:00
if p.fz_list[i].card == card then
2025-06-23 04:57:54 +08:00
p.fz_list[i].type = RB_FZType.Ti
remove_num = 0
isAddTi = true
2025-05-25 11:35:02 +08:00
end
end
2025-06-23 04:57:54 +08:00
if isAddTi == false then
p.fz_list[#p.fz_list + 1] = fz
2025-05-25 11:35:02 +08:00
end
end
else
2025-06-23 04:57:54 +08:00
local num = 0
for i = 1, #p.fz_list do
2025-05-25 11:35:02 +08:00
if p.fz_list[i].card == card then
2025-06-23 04:57:54 +08:00
p.fz_list[i].type = RB_FZType.Ti
remove_num = 0
num = 1
2025-05-25 11:35:02 +08:00
end
end
2025-06-23 04:57:54 +08:00
if num == 0 then
p.fz_list[#p.fz_list + 1] = fz
2025-05-25 11:35:02 +08:00
end
2025-06-23 04:57:54 +08:00
end
2025-05-25 11:35:02 +08:00
end
2025-06-23 04:57:54 +08:00
2025-05-25 11:35:02 +08:00
p.hand_left_count = p.hand_left_count - remove_num
2025-07-06 00:53:24 +08:00
-- if fz.type == RB_FZType.Pao or fz.type == RB_FZType.Ti or fz.type == RB_FZType.Wei or fz.type == RB_FZType.ChouWei then
-- coroutine.start(function()
-- -- coroutine.wait(0.88)
-- DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.FangziAction, fz, p, isNeedDelHandCard, flag_pengPao)
-- end)
-- else
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.FangziAction, fz, p, isNeedDelHandCard, flag_pengPao)
-- end
2025-05-25 11:35:02 +08:00
end)
end
function M:OnEventHu(evt_data)
local cards = evt_data["card"]
local win_p = self._room:GetPlayerBySeat(evt_data["seat"])
local lose_p = self._room:GetPlayerBySeat(evt_data["from_seat"])
-- print(win_p.hand_left_count)
2025-06-23 04:57:54 +08:00
2025-05-25 11:35:02 +08:00
self._cacheEvent:Enqueue(function()
2025-07-06 00:53:24 +08:00
if self._callback_popEvent then
self._callback_popEvent(true)
end
2025-05-25 11:35:02 +08:00
win_p.card_list = cards
2025-06-23 04:57:54 +08:00
table.sort(win_p.card_list, ViewUtil.HandCardSort)
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.ZPHuCard, evt_data["seat"], evt_data["from_seat"], cards)
2025-05-25 11:35:02 +08:00
end)
end
function M:OneventResult1(evt_data)
local over = evt_data.type
--0小结算 1小大结算 2大结算
self._room.playing = false
2025-06-20 11:52:54 +08:00
2025-06-23 04:57:54 +08:00
if 0 == over then
2025-05-25 11:35:02 +08:00
local result = evt_data.result
for i = 1, #self._room.player_list do
local p = self._room.player_list[i]
p.hand_left_count = 0
p.outcard_list = {}
end
2025-06-23 04:57:54 +08:00
2025-05-25 11:35:02 +08:00
self._cacheEvent:Enqueue(function()
2025-07-06 00:53:24 +08:00
if self._callback_popEvent then
self._callback_popEvent(true)
end
2025-06-23 04:57:54 +08:00
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.ZPResult1, result);
2025-05-25 11:35:02 +08:00
end)
elseif 1 == over or 2 == over then
DataManager.CurrenRoom.Over = true
2025-06-23 04:57:54 +08:00
ControllerManager.SetGameNetClient(nil, true)
2025-05-25 11:35:02 +08:00
local total_result = evt_data.total_result
2025-06-23 04:57:54 +08:00
2025-05-25 11:35:02 +08:00
local result = evt_data.result
self._cacheEvent:Enqueue(function()
2025-07-06 00:53:24 +08:00
if self._callback_popEvent then
self._callback_popEvent(true)
end
2025-06-23 04:57:54 +08:00
DispatchEvent(self._dispatcher, FanPaoFa_GameEvent.ZPResult2, result, total_result, over);
2025-05-25 11:35:02 +08:00
end)
end
end
2025-06-23 04:57:54 +08:00
return M