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
---@return boolean
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
end
@ -358,7 +358,7 @@ end
---@param diff boolean
---@return boolean
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
end
@ -373,7 +373,7 @@ end
---@param diff boolean
---@return boolean
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
end

View File

@ -2549,11 +2549,17 @@ end
---@param pattern string
---@param num number|null
---@param fromPile number|null
---@param fromPile string|null @ 查找的来源区域值为drawPile|discardPile|allPiles
---@return cardId[]
function Room:getCardFromPileByRule(pattern, num, fromPile)
function Room:getCardsFromPileByRule(pattern, num, fromPile)
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 = {}
if num < 3 then