Skip to content

Commit 9a38c7e

Browse files
committed
Draw a random card from discard pile when the draw pile is empty while activing HISTORY
1 parent 68e7c5c commit 9a38c7e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

gameplay/card.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,20 @@ function card.add_seen()
204204
seen = seen + 1
205205
draw_pile[seen], draw_pile[idx] = draw_pile[idx], draw_pile[seen]
206206
GAME.seen = seen
207+
else
208+
-- draw a random card from discard pile into draw pile
209+
-- See https://github.com/cloudwu/deepfuture/issues/63
210+
assert(#draw_pile == seen)
211+
local discard_pile = GAME.discard
212+
local discard_n = #discard_pile
213+
if discard_n > 0 then
214+
local idx = math.random(discard_n)
215+
seen = seen + 1
216+
draw_pile[seen] = discard_pile[idx]
217+
discard_pile[idx] = discard_pile[discard_n]
218+
discard_pile[discard_n] = nil
219+
GAME.seen = seen
220+
end
207221
end
208222
return seen
209223
end

gameplay/effect.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ function adv_check.infrastructure()
566566
end
567567

568568
function adv_check.history()
569-
return card.count "draw" - card.seen() > 0
569+
return card.count "draw" + card.count "discard" - card.seen() > 0
570570
end
571571

572572
function adv_check.economy()

0 commit comments

Comments
 (0)