diff --git a/lua/core/card.lua b/lua/core/card.lua index 5f7e1c24..7ed31ae4 100644 --- a/lua/core/card.lua +++ b/lua/core/card.lua @@ -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 diff --git a/lua/server/room.lua b/lua/server/room.lua index 2f8d9cfc..233a1794 100644 --- a/lua/server/room.lua +++ b/lua/server/room.lua @@ -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