modify functions

This commit is contained in:
Ho-spair 2023-05-13 15:03:35 +08:00
parent ad97c5d5f5
commit 6e2687a3ab
2 changed files with 12 additions and 6 deletions

View File

@ -343,7 +343,7 @@ end
---@param diff boolean ---@param diff boolean
---@return boolean ---@return boolean
function Card:compareSuitWith(anotherCard, diff) function Card:compareSuitWith(anotherCard, diff)
if table.contains({ self.suit, anotherCard.suit }, Card.NoSuit) then if self ~= anotherCard and table.contains({ self.suit, anotherCard.suit }, Card.NoSuit) then
return false return false
end end
@ -358,7 +358,7 @@ end
---@param diff boolean ---@param diff boolean
---@return boolean ---@return boolean
function Card:compareColorWith(anotherCard, diff) function Card:compareColorWith(anotherCard, diff)
if table.contains({ self.color, anotherCard.color }, Card.NoColor) then if self ~= anotherCard and table.contains({ self.color, anotherCard.color }, Card.NoColor) then
return false return false
end end
@ -373,7 +373,7 @@ end
---@param diff boolean ---@param diff boolean
---@return boolean ---@return boolean
function Card:compareNumberWith(anotherCard, diff) function Card:compareNumberWith(anotherCard, diff)
if self.number < 1 or anotherCard.number < 1 then if self ~= anotherCard and self.number < 1 or anotherCard.number < 1 then
return false return false
end end

View File

@ -2549,11 +2549,17 @@ end
---@param pattern string ---@param pattern string
---@param num number|null ---@param num number|null
---@param fromPile number|null ---@param fromPile string|null @ 查找的来源区域值为drawPile|discardPile|allPiles
---@return cardId[] ---@return cardId[]
function Room:getCardFromPileByRule(pattern, num, fromPile) function Room:getCardsFromPileByRule(pattern, num, fromPile)
num = num or 1 num = num or 1
local pileToSearch = fromPile == Card.DiscardPile and self.discard_pile or self.draw_pile local pileToSearch = self.draw_pile
if fromPile == "discardPile" then
pileToSearch = self.discard_pile
elseif fromPile == "allPiles" then
pileToSearch = table.clone(self.draw_pile)
table.insertTable(pileToSearch, self.discard_pile)
end
local cardPack = {} local cardPack = {}
if num < 3 then if num < 3 then