Roland/src/tweaks.lua
2026-06-20 12:00:11 +02:00

129 lines
3.9 KiB
Lua

local f, q = (... or require "lib.shared")[1], (... or require "lib.shared")[2]
SMODS.Joker:take_ownership("joker", {cost = 1}, true)
local orig_set_debuff = Card.set_debuff
function Card:set_debuff(should_debuff, ...)
if self.ability.Roland_crimson ~= nil then
self.ability.Roland_crimson = not not should_debuff
return
end
if SMODS.get_enhancements(self).m_wild and SMODS.Mods.Roland.config.no_wild_debuff then
self.debuff = false
else
orig_set_debuff(self, should_debuff, ...)
end
end
local orig_use_consumeable = Card.use_consumeable
function Card:use_consumeable(area, copier, ...)
if SMODS.Mods.Roland.config.faster_planets and self.ability.consumeable.hand_type then
set_consumeable_usage(self)
level_up_hand(copier or self, self.ability.consumeable.hand_type, true)
return
end
local seal_spectrals = {["Deja Vu"] = true, Medium = true, Talisman = true, Trance = true}
if not seal_spectrals[self.ability.name] then
return orig_use_consumeable(self, area, copier, ...)
end
local card = copier or self
f(Bakery_API.get_highlighted()):each(function(v)
q(function()
play_sound "tarot1"
card:juice_up(0.3, 0.5)
end)
q {
delay = 0.1,
trigger = "after",
func = function()
v:set_seal(self.ability.extra, nil, true)
end,
}
end)
q {delay = 0.7, trigger = "after", func = Bakery_API.unhighlight_all}
end
local orig_use_card = G.FUNCS.use_card
function G.FUNCS.use_card(e, ...)
local ref = e.config.ref_table or {}
local consumeable = (ref.ability or {}).consumeable or {}
if not SMODS.Mods.Roland.config.faster_planets or
(not consumeable.hand_type and not consumeable.hand_types) then
return orig_use_card(e, ...)
end
local normal = ref.area ~= G.pack_cards or not G.GAME.pack_choices or G.GAME.pack_choices <= 0
ref.from_area = ref.from_area or ref.area
play_sound("tarot1", percent, 0.6)
discover_card(ref.config.center)
ref:use_consumeable(ref.area)
SMODS.calculate_context {area = ref.area, consumeable = ref, using_consumeable = true}
q(function()
ref:remove()
end)
if normal then
return
end
G.GAME.pack_choices = G.GAME.pack_choices - 1
local _ = G.GAME.pack_choices <= 0 and G.FUNCS.end_consumeable()
end
local orig_create_card_for_shop = create_card_for_shop
function create_card_for_shop(...)
local ret = orig_create_card_for_shop(...)
if not SMODS.Mods.Roland.config.illusion_seal or
not G.GAME.used_vouchers.v_illusion or
not ({Default = true, Enhanced = true})[(((ret or {}).config or {}).center or {}).set] or
pseudorandom(pseudoseed "Roland_illusion") <= 0.8 then
return ret
end
local seal = SMODS.poll_seal {type_key = "Roland_illusion_seal", guaranteed = true}
ret:set_seal(seal, true, true)
return ret
end
local orig_get_blind_amount = get_blind_amount
---@param ante number
---@return table|number
local function blind(ante)
return ante == 39 and 1e294 or (to_number or f.id)(orig_get_blind_amount(ante))
end
local function no_harsh_ante_scaling()
return not Talisman or not SMODS.Mods.Roland.config.harsh_ante_scaling
end
function get_blind_amount(ante, ...)
local loop = 39
if ante < loop or no_harsh_ante_scaling() then
return orig_get_blind_amount(ante, ...)
end
if (ante - 9) / 15 >= loop then
return 1 / 0
end
local rem = tonumber(blind((ante % loop) + 1))
return ante / 15 >= loop and Big:new(f(blind(ante - (loop * 15))):map(f.const(10)):table()) or
(ante / 9 >= loop and Big:new(f(ante / loop - 8):map(f.const(10)):concat {rem}:table()) or
(ante / 2 >= loop and Big:new {rem, ante / loop} or
(Big.constants and Big.constants.TEN or Big:new {10}):pow(rem)))
end