Fix The Tranquilizer

This commit is contained in:
Emik 2026-02-26 11:34:24 +01:00
parent 8fdd9a4062
commit 04e131f449
Signed by: emik
GPG key ID: 6B0CD72A5E503BDF
3 changed files with 26 additions and 57 deletions

View file

@ -6,7 +6,7 @@
"author": [ "author": [
"Emik" "Emik"
], ],
"version": "2.0.2", "version": "2.0.3",
"badge_colour": "8BE9FD", "badge_colour": "8BE9FD",
"main_file": "src/main.lua", "main_file": "src/main.lua",
"badge_text_colour": "44475A", "badge_text_colour": "44475A",

View file

@ -29,31 +29,19 @@ SMODS.Sound {
} }
local function common_rank() local function common_rank()
local tally = {} ---@type { [integer]: integer }, { [integer]: string }
local to_name = {} local tally, to_name = {}, {}
--- Tallies up a card area's cards. f(G.playing_cards):where(function(v)
---@param card_area CardArea return not SMODS.has_no_rank(v)
local function tally_up(card_area) end):each(function(v)
f(card_area.cards):where(function(v) local id = v:get_id()
return not SMODS.has_no_rank(v) to_name[id] = v.base.value
end):each(function(v) tally[id] = (tally[id] or 0) + 1
local id = v:get_id() end)
to_name[id] = v.base.value
tally[id] = (tally[id] or 0) + 1
end)
end
tally_up(G.deck) local max_key = f(tally, pairs):fold({-1 / 0, -1 / 0}, function(a, v, k)
tally_up(G.hand) return (v > a[1] or v == a[1] and k > a[2]) and {v, k} or a
tally_up(G.discard)
local max_key = f(tally):fold({-1 / 0, -1 / 0}, function(a, v, k)
if v > a[1] or k > a[2] and v == a[1] then
return {v, k}
end
return a
end)[2] end)[2]
return max_key, to_name[max_key] return max_key, to_name[max_key]
@ -73,6 +61,10 @@ local function has_enhancement(card)
return not not (e and next(e)) return not not (e and next(e))
end end
local function sort_by_enhancement(v1, v2)
return has_enhancement(v1) and not has_enhancement(v2)
end
local function hsv_to_rgb(h, s, v) local function hsv_to_rgb(h, s, v)
s, v = s or 1, v or 1 s, v = s or 1, v or 1
@ -112,28 +104,23 @@ blind {
boss_colour = HEX "0291fbff", boss_colour = HEX "0291fbff",
pronouns = "she_her", pronouns = "she_her",
config = {draw = 5}, config = {draw = 5},
defeat = function()
G.GAME.Roland_nimble_disabled = nil
end,
disable = function()
G.GAME.Roland_nimble_disabled = true
end,
drawn_to_hand = function(self) drawn_to_hand = function(self)
local function force_hand() local function force_hand()
if is_locked() then if is_locked() then
return false return false
end end
f(G.hand.cards, ipairs):take(self.config.draw):each(function(v) f(G.hand.cards):take(self.config.draw):each(function(v)
G.hand:add_to_highlighted(v, true) G.hand:add_to_highlighted(v, true)
end) end)
G.FUNCS.play_cards_from_highlighted(nil) G.FUNCS.play_cards_from_highlighted()
self:disable()
end end
if not G.GAME.Roland_nimble_disabled then local g = G.GAME
G.GAME.Roland_nimble_disabled = true
if not g.blind.disabled and not g.Roland_nimble_disabled then
g.Roland_nimble_disabled = true
q {func = force_hand, blocking = false} q {func = force_hand, blocking = false}
end end
end, end,
@ -148,29 +135,14 @@ blind {
boss_colour = HEX "ff7f3dff", boss_colour = HEX "ff7f3dff",
pronouns = "any_all", pronouns = "any_all",
disable = function() disable = function()
q(function() G.FUNCS.draw_from_hand_to_deck()
f(G.hand.cards):each(function(v, i)
draw_card(G.hand, G.deck, i / #G.hand.cards * 100, "up", false, v)
end)
end)
q(function() q(function()
pseudoshuffle(G.deck.cards, pseudoseed "RolandFalseShuffle") pseudoshuffle(G.deck.cards, pseudoseed "RolandFalseShuffle")
end) end)
end, end,
calculate = function(_, b, context) calculate = function(_, b, context)
if b.disabled or not context.drawing_cards then local _ = not b.disabled and context.drawing_cards and table.sort(G.deck.cards, sort_by_enhancement)
return
end
b:wiggle()
table.sort(
G.deck.cards,
function(v1, v2)
return has_enhancement(v1) and not has_enhancement(v2)
end
)
end, end,
in_pool = function() in_pool = function()
return G.playing_cards and f(G.playing_cards):any(has_enhancement) return G.playing_cards and f(G.playing_cards):any(has_enhancement)
@ -223,7 +195,7 @@ blind {
local cards_added = {} local cards_added = {}
local count = #G.hand.highlighted local count = #G.hand.highlighted
f(G.hand.highlighted, ipairs):take(count):each(function(v, i) f(G.hand.highlighted):take(count):each(function(v, i)
local copy = copy_card(v) local copy = copy_card(v)
copy:add_to_deck() copy:add_to_deck()
table.insert(G.hand, copy) table.insert(G.hand, copy)
@ -255,9 +227,6 @@ blind {
local _, name = common_rank() local _, name = common_rank()
return {vars = {localize(name or "Ace", "ranks")}} return {vars = {localize(name or "Ace", "ranks")}}
end, end,
disable = function(self)
self.disabled = true
end,
calculate = function(self, b, context) calculate = function(self, b, context)
if not context.card_added and if not context.card_added and
not context.drawing_cards and not context.drawing_cards and

View file

@ -80,7 +80,7 @@ spectral {
return u() and #G.hand.cards > 0 return u() and #G.hand.cards > 0
end, end,
use = function(_, card, _) use = function(_, card, _)
local cards = f(G.hand.cards, ipairs):table() local cards = f(G.hand.cards):table()
pseudoshuffle(cards, pseudoseed "RolandDual") pseudoshuffle(cards, pseudoseed "RolandDual")
f(cards):take(card.ability.extra.amount):each(function(v) f(cards):take(card.ability.extra.amount):each(function(v)