Skip to content

Commit f1739de

Browse files
committed
Fixes #1077
1 parent 331bc7a commit f1739de

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

lovely/card_limit.toml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -254,22 +254,21 @@ position = "at"
254254
payload = """local hand_space = e
255255
local cards_to_draw = {}
256256
local space_taken = 0
257-
local limit = G.hand.config.card_limit - #G.hand.cards - (SMODS.cards_to_draw or 0)
258-
local unfixed = not G.hand.config.fixed_limit
259-
local n = 0
260-
while n < #G.deck.cards do
261-
local card = G.deck.cards[#G.deck.cards-n]
262-
local mod = unfixed and (card.ability.card_limit - card.ability.extra_slots_used) or 0
263-
if limit - 1 + mod < 0 then
264-
else
265-
limit = limit - 1 + mod
266-
table.insert(cards_to_draw, card)
267-
space_taken = space_taken + (1 - mod)
268-
if limit <= 0 then break end
269-
end
270-
n = n + 1
257+
local limit = G.hand.config.card_limit - #G.hand.cards - (SMODS.cards_to_draw or 0)
258+
local unfixed = not G.hand.config.fixed_limit
259+
local n = 0
260+
while n < #G.deck.cards and limit > 0 do
261+
local card = G.deck.cards[#G.deck.cards-n]
262+
local mod = unfixed and (card.ability.card_limit - card.ability.extra_slots_used) or 0
263+
if limit - 1 + mod < 0 then
264+
else
265+
limit = limit - 1 + mod
266+
table.insert(cards_to_draw, card)
267+
space_taken = space_taken + (1 - mod)
271268
end
272-
hand_space = #cards_to_draw
269+
n = n + 1
270+
end
271+
hand_space = #cards_to_draw
273272
"""
274273
match_indent = true
275274

src/utils.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3186,9 +3186,9 @@ function CardArea:handle_card_limit()
31863186
if SMODS.should_handle_limit(self) then
31873187
self.config.card_limits.old_slots = self.config.card_limits.total_slots or 0
31883188
self.config.card_limits.extra_slots = self:count_property('card_limit')
3189-
self.config.card_limits.total_slots = self:count_property('card_limit') + (self.config.card_limits.base or 0) + (self.config.card_limits.mod or 0)
3189+
self.config.card_limits.total_slots = self.config.card_limits.extra_slots + (self.config.card_limits.base or 0) + (self.config.card_limits.mod or 0)
31903190
self.config.card_limits.extra_slots_used = self:count_property('extra_slots_used')
3191-
self.config.card_count = #self.cards + self:count_property('extra_slots_used')
3191+
self.config.card_count = #self.cards + self.config.card_limits.extra_slots_used
31923192

31933193
if G.hand and self == G.hand and self.config.card_count + (SMODS.cards_to_draw or 0) < self.config.card_limits.total_slots then
31943194
if G.STATE == G.STATES.DRAW_TO_HAND and not SMODS.blind_modifies_draw(G.GAME.blind.config.blind.key) and not SMODS.draw_queued then

0 commit comments

Comments
 (0)