Skip to content

Commit

Permalink
Cosmic Collapse and Power Grid fixes (#12)
Browse files Browse the repository at this point in the history
* Added jucing to tenpin

* Fix for Cosmic Collapse

* Fixed Power Grid with latest SMOD

* New Power Grid fix

* Reverted tenpin
  • Loading branch information
jumbocarrot0 authored Jan 25, 2025
1 parent 74a4650 commit 9c85cd2
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 84 deletions.
10 changes: 9 additions & 1 deletion jokers/collapse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ SMODS.Joker {
end

for i, planet in ipairs(success_planets) do
-- need this bc OG doesn't accomodate for transforming planets
-- Balatro vanilla doesn't do this on set_ability, only on card removal
-- Doesn't matter in Vanilla, but it does here
for k, v in pairs(G.P_CENTERS) do
if v.name == planet.ability.name then
G.GAME.used_jokers[k] = nil
end
end

-- need this because vanilla doesn't accomodate for transforming planets
planet.config.card = {}
G.E_MANAGER:add_event(Event({
func = function()
Expand Down
19 changes: 10 additions & 9 deletions jokers/powergrid.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-- SMODS.Enhancement:take_ownership('m_mult', {
-- calculate = function(self, card, context)
-- if context.main_scoring then
-- G.GAME.current_round.kcv_mults_scored = (G.GAME.current_round.kcv_mults_scored or 0) + 1
-- end
-- end
-- }, true)

SMODS.Joker {
key = "powergrid",
name = "Power Grid",
Expand All @@ -21,26 +29,19 @@ SMODS.Joker {
info_queue[#info_queue + 1] = G.P_CENTERS.m_mult
local xmult = 1 + card.ability.extra + ((G.GAME.current_round.kcv_mults_scored or 0) * card.ability.extra)
return {
vars = {card.ability.extra, xmult}
vars = { card.ability.extra, xmult }
}
end,
calculate = function(self, card, context)
if context.setting_blind then
G.GAME.current_round.kcv_mults_scored = 0
end
if context.individual and context.cardarea == G.play then
local other = context.other_card
local other_enhancements = SMODS.get_enhancements(other)
if other_enhancements and other_enhancements.m_mult and not other.debuff then
if SMODS.has_enhancement(other, 'm_mult') and not other.debuff then
local xmult = 1 + ((G.GAME.current_round.kcv_mults_scored or 0) * card.ability.extra)
return {
x_mult = xmult,
card = context.blueprint_card or card
}
end
end
if context.end_of_round then
G.GAME.current_round.kcv_mults_scored = 0
end
end
}
137 changes: 71 additions & 66 deletions jokers/tenpin.lua
Original file line number Diff line number Diff line change
@@ -1,66 +1,71 @@
SMODS.Joker {
key = "tenpin",
name = "Ten-Pin",
atlas = 'kcvanillajokeratlas',
pos = {
x = 0,
y = kcv_getJokerAtlasIndex('tenpin')
},
rarity = 1,
cost = 6,
unlocked = true,
discovered = true,
eternal_compat = true,
perishable_compat = true,
blueprint_compat = true,
config = {
x_mult = 1,
hands_remaining = 0
},
loc_vars = function(self, info_queue, card)
local remaining_txt
if card.ability.hands_remaining > 0 then
remaining_txt = localize {
type = 'variable',
key = 'kcv_active_for_X_more_hands',
vars = {card.ability.hands_remaining}
}
else
remaining_txt = localize('kcv_inactive')
end
return {
vars = {remaining_txt}
}
end,
calculate = function(self, card, context)
if context.after and context.scoring_hand and not context.blueprint then
local has_10
for i, other_card in ipairs(context.scoring_hand) do
if other_card:get_id() == 10 and not other_card.debuff then
has_10 = true
break
end
end
if has_10 then
card.ability.hands_remaining = 2
card.ability.x_mult = 2
card_eval_status_text(card, 'extra', nil, nil, nil, {
message = localize('k_active_ex')
});
else
card.ability.hands_remaining = card.ability.hands_remaining - 1
if card.ability.hands_remaining > 0 then
card_eval_status_text(card, 'extra', nil, nil, nil, {
message = card.ability.hands_remaining .. ' remaining'
});
elseif card.ability.x_mult == 2 then
card.ability.x_mult = 1
card_eval_status_text(card, 'extra', nil, nil, nil, {
message = localize('k_reset')
});

end
end
end
end
}
SMODS.Joker {
key = "tenpin",
name = "Ten-Pin",
atlas = 'kcvanillajokeratlas',
pos = {
x = 0,
y = kcv_getJokerAtlasIndex('tenpin')
},
rarity = 1,
cost = 6,
unlocked = true,
discovered = true,
eternal_compat = true,
perishable_compat = true,
blueprint_compat = true,
config = {
x_mult = 1,
hands_remaining = 0
},
loc_vars = function(self, info_queue, card)
local remaining_txt
if card.ability.hands_remaining > 0 then
remaining_txt = localize {
type = 'variable',
key = 'kcv_active_for_X_more_hands',
vars = {card.ability.hands_remaining}
}
else
remaining_txt = localize('kcv_inactive')
end
return {
vars = {remaining_txt}
}
end,
calculate = function(self, card, context)
if context.after and context.scoring_hand and not context.blueprint then
local has_10
for i, other_card in ipairs(context.scoring_hand) do
if other_card:get_id() == 10 and not other_card.debuff then
has_10 = true
break
end
end
if has_10 then
card.ability.hands_remaining = 2
card.ability.x_mult = 2
card_eval_status_text(card, 'extra', nil, nil, nil, {
message = localize('k_active_ex')
});
else
card.ability.hands_remaining = card.ability.hands_remaining - 1
if card.ability.hands_remaining > 0 then
card_eval_status_text(card, 'extra', nil, nil, nil, {
message = card.ability.hands_remaining .. ' remaining'
});
elseif card.ability.x_mult == 2 then
card_eval_status_text(card, 'extra', nil, nil, nil, {
message = localize('k_reset')
});
G.E_MANAGER:add_event(Event({
trigger = 'immediate',
func = function()
card.ability.x_mult = 1
return true
end
}))
end
end
end
end
}
12 changes: 12 additions & 0 deletions kcvanilla.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
KCVanilla = SMODS.current_mod

-- Using this to reset Power Grid, in the scenario Power Grid was destroyed mid-round
function KCVanilla.reset_game_globals(run_start)
if run_start then
-- Globals for a whole run (like Fortune Teller)
else
-- Globals for a single blind (like Idol)
G.GAME.current_round.kcv_mults_scored = 0 -- Power Grid
end
end

SMODS.Atlas {
key = 'kcvanillajokeratlas',
path = "jokeratlas.png",
Expand Down
15 changes: 7 additions & 8 deletions lovely.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,15 @@ if not initial and not self.kcv_ignore_debuff_check then G.GAME.blind:debuff_car
# Powergrid: increment count when mult card scored
[[patches]]
[patches.pattern]
target = 'functions/state_events.lua'
pattern = "local effects = {eval_card(scoring_hand[i],*"
position = 'before'
target = 'functions/common_events.lua'
pattern = "if context.cardarea == G.play and context.main_scoring then"
position = 'after'
match_indent = true
payload = '''
-- KCVanilla check for Power Grid
local kc_scored_enhancements = SMODS.get_enhancements(scoring_hand[i])
if kc_scored_enhancements and kc_scored_enhancements.m_mult then
G.GAME.current_round.kcv_mults_scored = (G.GAME.current_round.kcv_mults_scored or 0) + 1
end
-- KCVanilla check for Power Grid
if SMODS.has_enhancement(card, 'm_mult') and not card.debuff then
G.GAME.current_round.kcv_mults_scored = (G.GAME.current_round.kcv_mults_scored or 0) + 1
end
'''

0 comments on commit 9c85cd2

Please sign in to comment.