2025-04-01 10:48:36 +08:00
|
|
|
|
local TX_Protocol = import(".Protocol")
|
|
|
|
|
|
local FZTipList = require("main.majiang.FZData")
|
|
|
|
|
|
local TX_GameEvent = import(".GameEvent")
|
|
|
|
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
|
|
|
|
--- Create a new GameController
|
|
|
|
|
|
function M.new()
|
2025-04-10 11:19:20 +08:00
|
|
|
|
setmetatable(M, { __index = GameController })
|
|
|
|
|
|
local self = setmetatable({}, { __index = M })
|
2025-05-09 14:56:23 +08:00
|
|
|
|
self:init("金溪麻将")
|
2025-04-10 11:19:20 +08:00
|
|
|
|
self.class = "TX_GameController"
|
|
|
|
|
|
return self
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:init(name)
|
2025-04-10 11:19:20 +08:00
|
|
|
|
GameController.init(self, name)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
|
2025-04-10 11:19:20 +08:00
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_PLAYER_DEAL] = self.OnEventSendCards
|
2025-04-01 10:48:36 +08:00
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_CHANGE_ACTIVE_PLAYER] = self.OnEventTurn
|
|
|
|
|
|
|
|
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_DRAW] = self.OnEventTakeCard
|
|
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_DISCARD_TIP] = self.OnEventOutHint
|
|
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_DISCARD] = self.OnEventOutCard
|
|
|
|
|
|
|
|
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_FZTIPS] = self.OnEventFzTips
|
|
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_ACTION] = self.OnEventFzAction
|
|
|
|
|
|
|
|
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_HU] = self.OnEventHu
|
|
|
|
|
|
|
|
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_RESULT1] = self.OneventResult1
|
|
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_RESULT2] = self.OnEventResult2
|
|
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_NIAO] = self.OnEventNiao
|
|
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_PIAOTIP] = self.OnEventPiaoTip
|
|
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_PIAO] = self.OnEventPiao
|
|
|
|
|
|
|
|
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_GANGZI] = self.OnEventGangCards
|
|
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_BUGANG] = self.OnEventBuGang
|
2025-05-08 12:41:42 +08:00
|
|
|
|
|
|
|
|
|
|
self._eventmap[TX_Protocol.GAME_EVT_RESIDUE_CARD] = self.OnEventResidueCard
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local __pre_delete_card = false
|
|
|
|
|
|
-- 发送出牌指令到服务器
|
2025-04-21 18:55:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-05-08 12:41:42 +08:00
|
|
|
|
-------------------------展示牌---------------------------
|
2025-04-21 18:55:46 +08:00
|
|
|
|
function M:SendNextCard(card)
|
|
|
|
|
|
local _data = {}
|
|
|
|
|
|
_data["card"] = tonumber(card)
|
|
|
|
|
|
local _client = ControllerManager.GameNetClinet
|
|
|
|
|
|
_client:send(TX_Protocol.GAME_NEXT_CARD, _data)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-05-08 12:41:42 +08:00
|
|
|
|
function M:ReqResidueCard()
|
|
|
|
|
|
local _data = {}
|
2025-05-08 12:48:37 +08:00
|
|
|
|
_data["card"] = 0
|
2025-05-08 12:41:42 +08:00
|
|
|
|
local _client = ControllerManager.GameNetClinet
|
|
|
|
|
|
_client:send(TX_Protocol.GAME_RESIDUE_CARD, _data)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-04-21 18:55:46 +08:00
|
|
|
|
------------------------------------------------------------
|
|
|
|
|
|
|
2025-09-03 16:52:14 +08:00
|
|
|
|
function M:SendOutCard(data, callback)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local _data = {}
|
2025-09-03 16:52:14 +08:00
|
|
|
|
_data["card"] = data.card
|
|
|
|
|
|
_data["isTip"] = data.isTip
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local _room = self._room
|
2025-04-10 11:19:20 +08:00
|
|
|
|
local _client = ControllerManager.GameNetClinet
|
2025-09-03 16:52:14 +08:00
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
|
_client:send(TX_Protocol.GAME_DIS_CARD, _data)
|
|
|
|
|
|
|
|
|
|
|
|
-- 进行预删牌处理
|
|
|
|
|
|
local p = _room.self_player
|
|
|
|
|
|
_room.curren_outcard_seat = -1
|
2025-09-03 16:52:14 +08:00
|
|
|
|
list_remove(p.card_list, data.card)
|
2025-05-13 10:30:27 +08:00
|
|
|
|
|
|
|
|
|
|
table.sort(p.card_list, self.HandCardSortAndJing)
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
|
p.hand_left_count = p.hand_left_count - 1
|
|
|
|
|
|
if not p.outcard_list then p.outcard_list = {} end
|
2025-09-03 16:52:14 +08:00
|
|
|
|
p.outcard_list[#p.outcard_list + 1] = data.card
|
2025-04-01 10:48:36 +08:00
|
|
|
|
__pre_delete_card = true
|
|
|
|
|
|
callback()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:SendGangCard(card)
|
|
|
|
|
|
local _data = {}
|
|
|
|
|
|
_data["card"] = card
|
2025-04-10 11:19:20 +08:00
|
|
|
|
local _client = ControllerManager.GameNetClinet
|
2025-04-01 10:48:36 +08:00
|
|
|
|
_client:send(TX_Protocol.GAME_EVT_DOGANG, _data)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:OnEventGangCards(evt_data)
|
|
|
|
|
|
printlog("OnEventGangCards")
|
|
|
|
|
|
pt(evt_data)
|
2025-04-10 11:19:20 +08:00
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.SendGangZi, evt_data["gangzi1"], evt_data["gangzi2"],
|
|
|
|
|
|
evt_data["gangnum"], true)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:OnEventBuGang(evt_data)
|
|
|
|
|
|
printlog("OnEventBuGang")
|
|
|
|
|
|
pt(evt_data)
|
2025-04-09 10:50:46 +08:00
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.EventBuGang, evt_data["info"], true)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2025-05-08 12:41:42 +08:00
|
|
|
|
function M:OnEventResidueCard(evt_data)
|
|
|
|
|
|
printlog("OnEventResidueCard")
|
|
|
|
|
|
pt(evt_data)
|
2025-05-08 13:18:43 +08:00
|
|
|
|
if evt_data.seat ~= DataManager.CurrenRoom.self_player.seat then
|
|
|
|
|
|
return
|
|
|
|
|
|
end
|
|
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.EventResidueCard, evt_data["residueCard"])
|
2025-05-08 12:41:42 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
|
-- 发送放子选择到服务器
|
|
|
|
|
|
function M:SendAction(id)
|
|
|
|
|
|
local _data = {}
|
|
|
|
|
|
_data["id"] = id
|
2025-04-10 11:19:20 +08:00
|
|
|
|
local _client = ControllerManager.GameNetClinet
|
2025-04-01 10:48:36 +08:00
|
|
|
|
_client:send(TX_Protocol.GAME_ACTION, _data)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:OnEventSendCards(evt_data)
|
|
|
|
|
|
if ViewManager.GetCurrenView().dview_class == LobbyView then
|
|
|
|
|
|
self:ReturnToRoom()
|
|
|
|
|
|
return
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-04-10 11:19:20 +08:00
|
|
|
|
local _room = self._room
|
2025-04-01 10:48:36 +08:00
|
|
|
|
if not _room.room_config.piao_niao or _room.self_player.entrust then
|
|
|
|
|
|
_room.curren_round = _room.curren_round + 1
|
|
|
|
|
|
end
|
|
|
|
|
|
if _room.curren_round > 0 then _room.playing = true end
|
2025-04-10 11:19:20 +08:00
|
|
|
|
|
|
|
|
|
|
printlog("开始发牌===========>>>")
|
|
|
|
|
|
pt(evt_data)
|
|
|
|
|
|
|
|
|
|
|
|
local room = DataManager.CurrenRoom
|
|
|
|
|
|
--printlog(evt_data.laiziCard)
|
|
|
|
|
|
--printlog(evt_data.laiziCard2)
|
|
|
|
|
|
--printlog(evt_data.laiziCardBefore)
|
|
|
|
|
|
--printlog(evt_data.laiziCard2Before)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.SendGangZi, 102, 103, 0, true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
|
-- _room.SelfPlayer.AutoOutCard = false
|
|
|
|
|
|
local handcards = evt_data["card_list"]
|
|
|
|
|
|
local p = _room.self_player
|
|
|
|
|
|
local seat = evt_data["bank_seat"]
|
2025-04-10 11:19:20 +08:00
|
|
|
|
local jing = evt_data["jing"]
|
2025-04-10 15:52:04 +08:00
|
|
|
|
_room.jing = jing
|
2025-04-01 10:48:36 +08:00
|
|
|
|
self._cacheEvent:Enqueue(function()
|
|
|
|
|
|
_room.banker_seat = seat
|
2025-04-10 11:19:20 +08:00
|
|
|
|
for i = 1, #_room.player_list do
|
2025-04-01 10:48:36 +08:00
|
|
|
|
_room.player_list[i].hand_left_count = 13
|
|
|
|
|
|
_room.player_list[i].fz_list = {}
|
|
|
|
|
|
_room.player_list[i].card_list = {}
|
|
|
|
|
|
end
|
|
|
|
|
|
p.card_list = handcards
|
2025-04-10 11:19:20 +08:00
|
|
|
|
self._room.self_player.hand_left_count = #handcards
|
2025-05-13 10:30:27 +08:00
|
|
|
|
|
|
|
|
|
|
table.sort(handcards, self.HandCardSortAndJing)
|
2025-04-10 11:19:20 +08:00
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.SendCards, p)
|
|
|
|
|
|
end)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:OnEventOutCard(evt_data)
|
|
|
|
|
|
local seat = evt_data["seat"]
|
|
|
|
|
|
local card = evt_data["card"]
|
|
|
|
|
|
local ting_list = nil
|
|
|
|
|
|
local p = self._room:GetPlayerBySeat(seat)
|
|
|
|
|
|
self._cacheEvent:Enqueue(function()
|
2025-04-10 11:19:20 +08:00
|
|
|
|
local _room = self._room
|
2025-04-01 10:48:36 +08:00
|
|
|
|
_room.last_outcard_seat = seat
|
|
|
|
|
|
if seat == _room.self_player.seat and __pre_delete_card then
|
|
|
|
|
|
__pre_delete_card = false
|
|
|
|
|
|
else
|
|
|
|
|
|
if seat == _room.self_player.seat then
|
|
|
|
|
|
list_remove(p.card_list, card)
|
2025-05-13 10:30:27 +08:00
|
|
|
|
|
|
|
|
|
|
table.sort(p.card_list, self.HandCardSortAndJing)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
p.hand_left_count = p.hand_left_count - 1
|
|
|
|
|
|
if not p.outcard_list then p.outcard_list = {} end
|
2025-04-10 11:19:20 +08:00
|
|
|
|
p.outcard_list[#p.outcard_list + 1] = card
|
|
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.OutCard, p, card)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
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-04-10 11:19:20 +08:00
|
|
|
|
p.hand_left_count = p.hand_left_count + 1
|
2025-04-01 10:48:36 +08:00
|
|
|
|
if (seat == _room.self_player.seat) then
|
2025-04-10 11:19:20 +08:00
|
|
|
|
_room.self_player.card_list[#_room.self_player.card_list + 1] = card
|
2025-05-13 10:30:27 +08:00
|
|
|
|
|
|
|
|
|
|
-- table.sort( _room.self_player.card_list, self.HandCardSortAndJing )
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
2025-04-10 11:19:20 +08:00
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.GetCard, seat, card, left_count)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:OnEventOutHint(evt_data)
|
|
|
|
|
|
self._cacheEvent:Enqueue(function()
|
|
|
|
|
|
self._room.curren_outcard_seat = self._room.self_player.seat
|
2025-04-10 11:19:20 +08:00
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.OutHint)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:OnEventTurn(evt_data)
|
|
|
|
|
|
local seat = evt_data["seat"]
|
|
|
|
|
|
self._cacheEvent:Enqueue(function()
|
|
|
|
|
|
-- self._room.curren_outcard_seat = seat
|
2025-04-10 11:19:20 +08:00
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.EventTurn, seat)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:OnEventFzTips(evt_data)
|
|
|
|
|
|
self._cacheEvent:Enqueue(function()
|
|
|
|
|
|
local tiplist = FZTipList.new()
|
2025-04-10 11:19:20 +08:00
|
|
|
|
local list = evt_data["tip_list"]
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local weight = evt_data["weight"]
|
2025-04-10 11:19:20 +08:00
|
|
|
|
for i = 1, #list do
|
|
|
|
|
|
local dtip = list[i]
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local tip = {}
|
|
|
|
|
|
tip.id = dtip["id"]
|
|
|
|
|
|
tip.weight = dtip["weight"]
|
|
|
|
|
|
tip.card = dtip["card"]
|
|
|
|
|
|
tip.type = dtip["type"]
|
|
|
|
|
|
tip.opcard = dtip["opcard"]
|
2025-04-10 11:19:20 +08:00
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
|
-- if (dtip["opcard"]) then
|
|
|
|
|
|
-- local opcard = dtip["opcard"]
|
|
|
|
|
|
-- tip.OpCard = opcard
|
|
|
|
|
|
-- tip.OpCard[3] = tip.Card
|
|
|
|
|
|
-- table.sort(tip.OpCard)
|
|
|
|
|
|
-- end
|
|
|
|
|
|
tiplist:AddTip(tip)
|
|
|
|
|
|
end
|
2025-08-28 19:15:06 +08:00
|
|
|
|
--排序规则,胡杠碰
|
|
|
|
|
|
tiplist:SortList(function(a, b)
|
|
|
|
|
|
return a.type < b.type
|
|
|
|
|
|
end)
|
2025-04-10 11:19:20 +08:00
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.FZTips, tiplist, weight)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:OnEventFzAction(evt_data)
|
2025-07-11 21:37:35 +08:00
|
|
|
|
GameController.OnEventFzAction(self, evt_data)
|
2025-04-10 11:19:20 +08:00
|
|
|
|
local _room = self._room
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local playerid = evt_data["playerid"]
|
|
|
|
|
|
local card = evt_data["card"]
|
|
|
|
|
|
local actice_card = evt_data["active_card"]
|
|
|
|
|
|
local type = evt_data["type"]
|
|
|
|
|
|
local from_seat = evt_data["from_seat"]
|
|
|
|
|
|
local opcard = evt_data["opcard"]
|
|
|
|
|
|
-- local openkong = evt_data["openkong"]
|
|
|
|
|
|
|
|
|
|
|
|
local p = _room:GetPlayerById(playerid)
|
|
|
|
|
|
self._cacheEvent:Enqueue(function()
|
|
|
|
|
|
local fz = nil
|
|
|
|
|
|
local index = -1
|
|
|
|
|
|
local ftype = type
|
|
|
|
|
|
if (ftype == FZType.Gang_Peng) then
|
2025-04-10 11:19:20 +08:00
|
|
|
|
for i = 1, #p.fz_list do
|
2025-04-01 10:48:36 +08:00
|
|
|
|
if (p.fz_list[i].card == card) then
|
|
|
|
|
|
p.fz_list[i].card = card
|
|
|
|
|
|
fz = p.fz_list[i]
|
|
|
|
|
|
fz.type = type
|
2025-04-10 11:19:20 +08:00
|
|
|
|
index = i - 1
|
2025-04-01 10:48:36 +08:00
|
|
|
|
break
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
fz = {}
|
|
|
|
|
|
fz.card = card
|
|
|
|
|
|
fz.type = type
|
|
|
|
|
|
fz.active_card = actice_card
|
|
|
|
|
|
if (index == -1) then
|
|
|
|
|
|
if (ftype == FZType.Chi) then
|
2025-04-10 15:52:04 +08:00
|
|
|
|
local data = {}
|
|
|
|
|
|
data[1] = opcard[1]
|
|
|
|
|
|
data[2] = card
|
|
|
|
|
|
data[3] = opcard[2]
|
|
|
|
|
|
fz.opcard = data
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
2025-04-10 11:19:20 +08:00
|
|
|
|
p.fz_list[#p.fz_list + 1] = fz
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
fz.from_seat = from_seat
|
|
|
|
|
|
local remove_num = #opcard
|
|
|
|
|
|
|
|
|
|
|
|
if (p == _room.self_player) then
|
2025-04-10 11:19:20 +08:00
|
|
|
|
for i = 1, remove_num do
|
|
|
|
|
|
list_remove(p.card_list, opcard[i])
|
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
p.hand_left_count = p.hand_left_count - remove_num
|
2025-09-19 23:25:36 +08:00
|
|
|
|
if from_seat ~= p.seat and ftype ~= FZType.Gang_Peng then
|
2025-04-01 10:48:36 +08:00
|
|
|
|
-- if (fz.Type == FZType.Chi) then card = actice_card end
|
|
|
|
|
|
local fp = _room:GetPlayerBySeat(from_seat)
|
2025-04-10 11:19:20 +08:00
|
|
|
|
table.remove(fp.outcard_list, #fp.outcard_list)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2025-04-10 11:19:20 +08:00
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.FangziAction, fz, p, index)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:OnEventHu(evt_data)
|
2025-04-10 11:19:20 +08:00
|
|
|
|
local cards = evt_data["card"]
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local win_p = self._room:GetPlayerBySeat(evt_data["seat"])
|
|
|
|
|
|
local lose_p = self._room:GetPlayerBySeat(evt_data["from_seat"])
|
|
|
|
|
|
local win_card = evt_data["win_card"]
|
|
|
|
|
|
local win_list = evt_data["win_list"]
|
2025-08-18 21:44:31 +08:00
|
|
|
|
local scoreData = evt_data["result"].info_list
|
2025-04-10 11:19:20 +08:00
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
|
self._cacheEvent:Enqueue(function()
|
|
|
|
|
|
win_p.card_list = cards
|
2025-05-13 10:30:27 +08:00
|
|
|
|
table.sort(win_p.card_list, self.HandCardSortAndJing)
|
2025-04-10 11:19:20 +08:00
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.ZPHuCard, evt_data["seat"], evt_data["from_seat"], win_card, cards,
|
2025-08-18 21:44:31 +08:00
|
|
|
|
win_list, scoreData)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:OneventResult1(evt_data)
|
|
|
|
|
|
local over = evt_data.type
|
|
|
|
|
|
printlog("OneventResult1")
|
|
|
|
|
|
pt(evt_data)
|
|
|
|
|
|
--0:小结算 1:小大结算 2:大结算
|
|
|
|
|
|
self._room._reload_flag = false
|
|
|
|
|
|
self._room.playing = false
|
2025-07-18 19:26:03 +08:00
|
|
|
|
if evt_data.result then
|
|
|
|
|
|
evt_data.result.cardList = evt_data.cardList
|
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
if 0 == over then
|
|
|
|
|
|
local result = evt_data.result
|
|
|
|
|
|
self._cacheEvent:Enqueue(function()
|
|
|
|
|
|
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-04-10 11:19:20 +08:00
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.ZPResult1, result);
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end)
|
|
|
|
|
|
elseif 1 == over or 2 == over then
|
|
|
|
|
|
DataManager.CurrenRoom.Over = true
|
2025-04-10 11:19:20 +08:00
|
|
|
|
ControllerManager.SetGameNetClient(nil, true)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local total_result = evt_data.total_result
|
|
|
|
|
|
local result = evt_data.result
|
|
|
|
|
|
self._cacheEvent:Enqueue(function()
|
2025-04-10 11:19:20 +08:00
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.ZPResult2, result, total_result, over);
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- function M:OnEventResult2(evt_data)
|
|
|
|
|
|
-- DataManager.CurrenRoom.Over = true
|
|
|
|
|
|
-- ControllerManager.SetGameNetClient(nil,true)
|
2025-04-10 11:19:20 +08:00
|
|
|
|
-- local info_list = evt_data["info_list"]
|
|
|
|
|
|
-- if self._result ~= nil then
|
|
|
|
|
|
-- self._cacheEvent:Enqueue(function()
|
|
|
|
|
|
-- self:OneventResult1(self._result)
|
|
|
|
|
|
-- self._result = nil
|
|
|
|
|
|
-- end)
|
|
|
|
|
|
-- end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
-- self._cacheEvent:Enqueue(function()
|
|
|
|
|
|
-- DispatchEvent(self._dispatcher,TX_GameEvent.ZPResult2, info_list)
|
|
|
|
|
|
-- ControllerManager.ChangeController(LoddyController)
|
|
|
|
|
|
-- end)
|
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
|
|
function M:OnEventNiao(evt_data)
|
|
|
|
|
|
local list = evt_data["niao"]
|
|
|
|
|
|
local start_seat = evt_data["start_seat"]
|
|
|
|
|
|
self._cacheEvent:Enqueue(function()
|
2025-04-10 11:19:20 +08:00
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.EventNiao, list, start_seat)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:OnEventPiaoTip()
|
|
|
|
|
|
if ViewManager.GetCurrenView().dview_class == LobbyView then
|
|
|
|
|
|
self:ReturnToRoom()
|
|
|
|
|
|
return
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
self._cacheEvent:Enqueue(function()
|
2025-04-10 11:19:20 +08:00
|
|
|
|
if not self._room._reload_flag then
|
2025-04-01 10:48:36 +08:00
|
|
|
|
self._room.curren_round = self._room.curren_round + 1
|
|
|
|
|
|
end
|
|
|
|
|
|
self._room.playing = true
|
2025-04-10 11:19:20 +08:00
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.EvnetPiaoTip, evt_data)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:OnEventPiao(evt_data)
|
|
|
|
|
|
self._cacheEvent:Enqueue(function()
|
2025-04-10 11:19:20 +08:00
|
|
|
|
DispatchEvent(self._dispatcher, TX_GameEvent.EvnetPiao, evt_data.seat, evt_data.num)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-04-10 11:19:20 +08:00
|
|
|
|
function M:GetPosString(seat)
|
|
|
|
|
|
if DataManager.CurrenRoom.room_config.people_num ~= 4 then return "" end
|
|
|
|
|
|
if seat == 1 then
|
|
|
|
|
|
return "北"
|
|
|
|
|
|
elseif seat == 2 then
|
|
|
|
|
|
return "西"
|
|
|
|
|
|
elseif seat == 3 then
|
|
|
|
|
|
return "南"
|
|
|
|
|
|
elseif seat == 4 then
|
|
|
|
|
|
return "东"
|
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:Discard(card)
|
2025-04-10 11:19:20 +08:00
|
|
|
|
local _data = {}
|
2025-04-01 10:48:36 +08:00
|
|
|
|
_data["card"] = card
|
|
|
|
|
|
local _room = self._room
|
2025-04-10 11:19:20 +08:00
|
|
|
|
local _client = ControllerManager.GameNetClinet
|
2025-04-01 10:48:36 +08:00
|
|
|
|
-- list_remove(_room.SelfPlayer.Cards,card)
|
|
|
|
|
|
-- table.sort(_room.SelfPlayer.Cards)
|
|
|
|
|
|
_client:send(Protocol.Game_Da, _data)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-05-13 10:30:27 +08:00
|
|
|
|
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
|
|
|
|
|
|
|
2025-04-10 11:19:20 +08:00
|
|
|
|
return M
|