Skip to content

Commit c095236

Browse files
authored
fixed Global sticker and added new context (SpectralPack#685)
Global sticker now prioritizes being drawn, but doesn't force itself being drawn, and no longer exceeds maximum handsize A new context was added to allow for this (also, I'm not sure what the approach is for documenting and crediting code. I'm adding my name mostly so people can ping me if the code isn't clear, or it turns out there's bugs in it, but I'm not sure if that's the proper approach)
1 parent 43d39c8 commit c095236

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

items/code.lua

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3415,12 +3415,28 @@ local global_sticker = {
34153415
card.hover_tilt = card.hover_tilt * 2
34163416
end,
34173417
calculate = function(self, card, context)
3418-
if (context.setting_blind or context.open_booster) and context.cardarea == G.deck then
3419-
draw_card(G.deck, G.hand, nil, nil, nil, card)
3420-
--[[card.globalticks = (card.globalticks or 1) - 1
3421-
if card.globalticks == 0 then
3422-
card.global = nil
3423-
end--]]
3418+
-- Added by IcyEthics
3419+
if context.cry_shuffling_area and context.cardarea == G.deck and context.cry_post_shuffle then
3420+
3421+
local _targetpos = nil
3422+
local _selfpos = nil
3423+
3424+
-- Iterate through every card in the deck to find both the location
3425+
-- of the stickered card, and the highest placed non-stickered card
3426+
for i, _playingcard in ipairs(G.deck.cards) do
3427+
if _playingcard == card then
3428+
_selfpos = i
3429+
elseif not _playingcard.ability.cry_global_sticker then
3430+
_targetpos = i
3431+
end
3432+
end
3433+
3434+
if _targetpos == nil then _targetpos = #G.deck.cards end
3435+
if _selfpos == nil then _selfpos = #G.deck.cards end
3436+
3437+
-- Swaps the positions of the selected cards
3438+
G.deck.cards[_selfpos], G.deck.cards[_targetpos] = G.deck.cards[_targetpos], G.deck.cards[_selfpos]
3439+
34243440
end
34253441
end,
34263442
}

lib/overrides.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,3 +1600,15 @@ G.FUNCS.can_skip_booster = function(e)
16001600
e.config.button = nil
16011601
end
16021602
end
1603+
1604+
-- Added by IcyEthics: Adding a hook to the shuffle function so that there can be a context to modify randomization
1605+
-- Any card using this will most likely want to use cry_post_shuffle.
1606+
-- added cry_pre_shuffle for posterity
1607+
local o_ca_shuffle = CardArea.shuffle
1608+
function CardArea:shuffle(_seed)
1609+
SMODS.calculate_context({cry_shuffling_area = true, cardarea = self, cry_pre_shuffle = true})
1610+
1611+
o_ca_shuffle(self, _seed)
1612+
1613+
SMODS.calculate_context({cry_shuffling_area = true, cardarea = self, cry_post_shuffle = true})
1614+
end

0 commit comments

Comments
 (0)