jx_client_neibu/lua_probject/main_project/main/majiang/FZData.lua

84 lines
1.3 KiB
Lua
Raw Permalink Normal View History

2025-04-01 10:48:36 +08:00
--放子数据对象
--author--
--[[
--数据字段参考
local FZData = {
-- 放子类型
type = TX_FZType.Chi,
-- 吃的牌
card = 0,
-- 激活牌
active_card = 0,
2025-04-25 15:09:34 +08:00
--
2025-04-01 10:48:36 +08:00
from_seat = 0,
}
local FZTip = {
--提示ID
id = 0,
--权重
weight = 0,
--类型
type = 0,
--牌
card = 0,
--手牌吃牌组
op_card = nil
}
2025-04-25 15:09:34 +08:00
]] --
2025-04-01 10:48:36 +08:00
FZType =
{
Chi = 1,
Peng = 2,
Gang = 3,
Gang_An = 4,
Gang_Peng = 5,
HU = 6,
}
local FZTipList = {
tip_map_id = nil,
2025-06-13 13:33:34 +08:00
tip_map_type = nil,
is_hu = false
2025-04-01 10:48:36 +08:00
}
local M = FZTipList
function M.new()
local self = {}
2025-04-25 15:09:34 +08:00
setmetatable(self, { __index = FZTipList })
2025-04-01 10:48:36 +08:00
self.tip_map_id = {}
self.tip_map_type = {}
2025-08-23 22:23:17 +08:00
self.tip_sortList = {}
2025-04-25 15:09:34 +08:00
self.tip_num = 0
2025-06-13 13:33:34 +08:00
self.is_hu = false
2025-04-01 10:48:36 +08:00
return self
end
function M:AddTip(tip)
self.tip_map_id[tip.id] = tip
2025-06-13 13:33:34 +08:00
if not self.is_hu then
self.is_hu = tip.type == FZType.HU
end
2025-04-01 10:48:36 +08:00
local tiplist = self.tip_map_type[tip.weight]
if not tiplist then
tiplist = {}
self.tip_map_type[tip.weight] = tiplist
end
2025-04-25 15:09:34 +08:00
tiplist[#tiplist + 1] = tip
2025-08-23 22:23:17 +08:00
table.insert(self.tip_sortList, tip)
2025-04-25 15:09:34 +08:00
self.tip_num = self.tip_num + 1
2025-04-01 10:48:36 +08:00
end
2025-08-23 22:23:17 +08:00
function M:SortList(fct)
table.sort(self.tip_sortList, fct)
end
2025-04-25 15:09:34 +08:00
return M