2025-05-07 16:49:21 +08:00
|
|
|
local RunFast_CardType = import('.RunFast_CardType')
|
|
|
|
|
|
2025-04-29 19:34:41 +08:00
|
|
|
local CardCheck = {
|
|
|
|
|
|
|
|
|
|
cardList = {},
|
2025-04-30 10:53:04 +08:00
|
|
|
cardListSord = {},
|
2025-04-29 19:34:41 +08:00
|
|
|
cardNum = 0,
|
|
|
|
|
cardSize = 0,
|
|
|
|
|
long = false,
|
|
|
|
|
planeNoBelt = false,
|
|
|
|
|
threeNoBelt = false,
|
|
|
|
|
planelack = false,
|
|
|
|
|
threelack = false,
|
|
|
|
|
fourDaiThree = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local M = CardCheck
|
|
|
|
|
|
|
|
|
|
function M:initFlag()
|
|
|
|
|
local config = DataManager.CurrenRoom.room_config.config
|
|
|
|
|
self.planeNoBelt = config.planeNoBelt == 1
|
|
|
|
|
self.threeNoBelt = config.threeNoBelt == 1
|
|
|
|
|
self.planelack = config.planelack == 1
|
|
|
|
|
self.threelack = config.threelack == 1
|
|
|
|
|
self.fourDaiThree = config.fourDaiThree
|
|
|
|
|
print("==============================lingmengcheckinitFlag")
|
|
|
|
|
pt(config)
|
|
|
|
|
pt(self)
|
|
|
|
|
return self
|
|
|
|
|
end
|
|
|
|
|
|
2025-05-07 16:49:21 +08:00
|
|
|
function M:initCards(cardList, flag, flag_allCards, lastCards)
|
2025-04-30 10:53:04 +08:00
|
|
|
print("lingmenginitCards")
|
|
|
|
|
pt(cardList)
|
2025-04-29 19:34:41 +08:00
|
|
|
local temp_long = 0
|
|
|
|
|
self:Clear()
|
2025-05-07 11:58:53 +08:00
|
|
|
self._flag_allCards = flag_allCards or false
|
2025-05-07 16:49:21 +08:00
|
|
|
self.cardType = lastCards.type or -1
|
|
|
|
|
self.cardMaxNum = lastCards.maxNum or 0
|
|
|
|
|
self.length = lastCards.length or 0
|
2025-04-29 19:34:41 +08:00
|
|
|
if flag then
|
|
|
|
|
for i = 1, #cardList do
|
|
|
|
|
local number = math.floor(cardList[i][1].card_code_number / 10)
|
|
|
|
|
if self.cardList[number] then
|
|
|
|
|
self.cardList[number] = self.cardList[number] + 1
|
|
|
|
|
else
|
|
|
|
|
self.cardList[number] = 1
|
|
|
|
|
self.cardSize = self.cardSize + 1
|
2025-04-30 10:53:04 +08:00
|
|
|
table.insert(self.cardListSord, number)
|
2025-04-29 19:34:41 +08:00
|
|
|
end
|
|
|
|
|
self.cardNum = self.cardNum + 1
|
|
|
|
|
if i == 1 then
|
|
|
|
|
temp_long = 1
|
|
|
|
|
elseif temp_long == i - 1 then
|
|
|
|
|
if math.abs(math.floor(cardList[i - 1][1].card_code_number / 10) - number) == 1 then
|
|
|
|
|
temp_long = i
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
for i = 1, #cardList do
|
|
|
|
|
local number = math.floor(cardList[i].card_code_number / 10)
|
|
|
|
|
if self.cardList[number] then
|
|
|
|
|
self.cardList[number] = self.cardList[number] + 1
|
|
|
|
|
else
|
|
|
|
|
self.cardList[number] = 1
|
|
|
|
|
self.cardSize = self.cardSize + 1
|
2025-04-30 10:53:04 +08:00
|
|
|
table.insert(self.cardListSord, number)
|
2025-04-29 19:34:41 +08:00
|
|
|
end
|
|
|
|
|
self.cardNum = self.cardNum + 1
|
|
|
|
|
if i == 1 then
|
|
|
|
|
temp_long = 1
|
|
|
|
|
elseif temp_long == i - 1 then
|
|
|
|
|
if math.abs(math.floor(cardList[i - 1].card_code_number / 10) - number) == 1 then
|
|
|
|
|
temp_long = i
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2025-04-29 19:48:08 +08:00
|
|
|
|
2025-04-29 19:34:41 +08:00
|
|
|
print(self.cardNum, self.cardSize, temp_long)
|
|
|
|
|
pt(self.cardList)
|
2025-04-30 10:53:04 +08:00
|
|
|
self.long = temp_long == self.cardNum and self.cardNum >= 5
|
2025-04-29 19:34:41 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:CheckCards()
|
2025-05-07 16:49:21 +08:00
|
|
|
-- local zha
|
|
|
|
|
|
2025-05-07 15:38:38 +08:00
|
|
|
print("lingmengCheckAloneOrLong")
|
2025-04-29 19:34:41 +08:00
|
|
|
if self:CheckAloneOrLong() then
|
|
|
|
|
return true
|
|
|
|
|
end
|
2025-05-07 15:38:38 +08:00
|
|
|
print("lingmengCheckDuiZi")
|
2025-04-29 19:34:41 +08:00
|
|
|
|
|
|
|
|
if self:CheckDuiZi() then
|
|
|
|
|
return true
|
|
|
|
|
end
|
2025-05-07 15:38:38 +08:00
|
|
|
print("lingmengCheckSanDai")
|
2025-04-29 19:34:41 +08:00
|
|
|
|
|
|
|
|
if self:CheckSanDai() then
|
|
|
|
|
return true
|
|
|
|
|
end
|
2025-05-07 15:38:38 +08:00
|
|
|
print("lingmengCheckZha")
|
2025-04-29 19:34:41 +08:00
|
|
|
|
|
|
|
|
if self:CheckZha() then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:CheckAloneOrLong()
|
|
|
|
|
if self.cardNum == 1 or self.long then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:CheckDuiZi()
|
|
|
|
|
if self.cardNum == 2 and self.cardSize == 1 then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
if self.cardNum % 2 == 0 then
|
|
|
|
|
local last_k
|
2025-04-30 10:53:04 +08:00
|
|
|
for i = 1, self.cardSize do
|
|
|
|
|
local k = self.cardListSord[i]
|
|
|
|
|
local v = self.cardList[k]
|
2025-04-29 19:34:41 +08:00
|
|
|
if v == 2 then
|
|
|
|
|
if not last_k then
|
|
|
|
|
last_k = k
|
|
|
|
|
else
|
|
|
|
|
if math.abs(last_k - k) ~= 1 then
|
|
|
|
|
return
|
|
|
|
|
end
|
2025-04-30 10:53:04 +08:00
|
|
|
last_k = k
|
2025-04-29 19:34:41 +08:00
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:CheckSanDai()
|
|
|
|
|
--三张
|
|
|
|
|
if self.cardNum == 5 and self.cardSize < 4 then
|
|
|
|
|
return true
|
|
|
|
|
end
|
2025-05-07 15:38:38 +08:00
|
|
|
|
|
|
|
|
if self.threelack and self.cardNum == 4 and self.cardSize == 2 and self._flag_allCards then
|
2025-04-29 19:34:41 +08:00
|
|
|
return true
|
|
|
|
|
end
|
2025-05-07 15:38:38 +08:00
|
|
|
|
|
|
|
|
if self.threeNoBelt and self.cardNum == 3 and self.cardSize == 1 then
|
2025-05-07 11:58:53 +08:00
|
|
|
return true
|
|
|
|
|
end
|
2025-04-29 19:34:41 +08:00
|
|
|
|
2025-05-07 15:38:38 +08:00
|
|
|
|
2025-04-29 19:34:41 +08:00
|
|
|
--飞机
|
|
|
|
|
local temp_normol_feiji
|
|
|
|
|
if self.cardNum % 5 == 0 then
|
|
|
|
|
temp_normol_feiji = self.cardNum / 5
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if temp_normol_feiji then
|
|
|
|
|
local last_k
|
|
|
|
|
local num_san = 0
|
2025-04-30 10:53:04 +08:00
|
|
|
for i = 1, self.cardSize do
|
|
|
|
|
local k = self.cardListSord[i]
|
|
|
|
|
local v = self.cardList[k]
|
2025-04-29 19:34:41 +08:00
|
|
|
if v >= 3 then
|
|
|
|
|
num_san = num_san + 1
|
|
|
|
|
if not last_k then
|
|
|
|
|
last_k = k
|
|
|
|
|
else
|
|
|
|
|
if math.abs(last_k - k) ~= 1 then
|
|
|
|
|
return
|
|
|
|
|
end
|
2025-04-30 10:53:04 +08:00
|
|
|
last_k = k
|
2025-04-29 19:34:41 +08:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2025-04-30 10:53:04 +08:00
|
|
|
if num_san >= temp_normol_feiji then
|
2025-04-29 19:34:41 +08:00
|
|
|
return true
|
|
|
|
|
else
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-05-07 15:38:38 +08:00
|
|
|
print("liengmengCheckthreelack", self.threelack, self._flag_allCards)
|
|
|
|
|
|
|
|
|
|
if self.threelack and self._flag_allCards then
|
2025-04-29 19:34:41 +08:00
|
|
|
local last_k
|
2025-05-07 15:38:38 +08:00
|
|
|
local num_san = 0
|
|
|
|
|
for k, v in pairs(self.cardList) do
|
|
|
|
|
if v >= 3 then
|
|
|
|
|
num_san = num_san + 1
|
|
|
|
|
print("liengmengCheckthreelack2", last_k, k)
|
|
|
|
|
|
2025-04-29 19:34:41 +08:00
|
|
|
if not last_k then
|
|
|
|
|
last_k = k
|
|
|
|
|
else
|
|
|
|
|
if math.abs(last_k - k) ~= 1 then
|
|
|
|
|
return
|
|
|
|
|
end
|
2025-04-30 10:53:04 +08:00
|
|
|
last_k = k
|
2025-04-29 19:34:41 +08:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2025-05-07 15:38:38 +08:00
|
|
|
print("liengmengCheckthreelack4", num_san, self.cardNum - num_san * 3 < num_san * 2)
|
|
|
|
|
|
|
|
|
|
if self.cardNum - num_san * 3 < num_san * 2 then
|
|
|
|
|
return true
|
|
|
|
|
else
|
|
|
|
|
return
|
|
|
|
|
end
|
2025-04-29 19:34:41 +08:00
|
|
|
end
|
|
|
|
|
|
2025-05-07 15:38:38 +08:00
|
|
|
print("liengmengCheckplaneNoBelt", self.planeNoBelt, self.cardNum % 3)
|
|
|
|
|
|
|
|
|
|
if self.planeNoBelt and self.cardNum % 3 == 0 then
|
2025-05-07 11:58:53 +08:00
|
|
|
local last_k
|
2025-05-07 15:38:38 +08:00
|
|
|
for i = 1, self.cardSize do
|
|
|
|
|
local k = self.cardListSord[i]
|
|
|
|
|
local v = self.cardList[k]
|
|
|
|
|
if v == 3 then
|
2025-05-07 11:58:53 +08:00
|
|
|
if not last_k then
|
|
|
|
|
last_k = k
|
|
|
|
|
else
|
|
|
|
|
if math.abs(last_k - k) ~= 1 then
|
|
|
|
|
return
|
|
|
|
|
end
|
2025-05-07 15:38:38 +08:00
|
|
|
last_k = k
|
2025-05-07 11:58:53 +08:00
|
|
|
end
|
2025-05-07 15:38:38 +08:00
|
|
|
else
|
|
|
|
|
return
|
2025-05-07 11:58:53 +08:00
|
|
|
end
|
|
|
|
|
end
|
2025-05-07 15:38:38 +08:00
|
|
|
return true
|
2025-05-07 11:58:53 +08:00
|
|
|
end
|
2025-04-29 19:34:41 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:CheckZha()
|
|
|
|
|
if self.cardNum == 4 and self.cardSize == 1 then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if self.fourDaiThree and self.cardNum == 7 then
|
|
|
|
|
local flag_four
|
2025-04-30 10:53:04 +08:00
|
|
|
for i = 1, self.cardSize do
|
|
|
|
|
local k = self.cardListSord[i]
|
|
|
|
|
local v = self.cardList[k]
|
2025-04-29 19:34:41 +08:00
|
|
|
if v == 4 then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:Clear()
|
|
|
|
|
self.cardList = {}
|
2025-04-30 10:53:04 +08:00
|
|
|
self.cardListSord = {}
|
2025-04-29 19:34:41 +08:00
|
|
|
self.cardNum = 0
|
|
|
|
|
self.cardSize = 0
|
|
|
|
|
self.long = false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return M
|