Skip to content

Commit 9c97cd3

Browse files
committed
add Cryptid.manipulate
more flexible and (hopefully) less jank version of misprintize, which is still kept around for backwards compatibility. does the exact same thing with different parameters i hope
1 parent 1d15814 commit 9c97cd3

File tree

15 files changed

+144
-48
lines changed

15 files changed

+144
-48
lines changed

items/code.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3966,7 +3966,7 @@ local multiply = {
39663966
end
39673967
G.jokers.highlighted[1].config.cry_multiply = G.jokers.highlighted[1].config.cry_multiply * 2
39683968
Cryptid.with_deck_effects(G.jokers.highlighted[1], function(card)
3969-
Cryptid.misprintize(card, { min = 2, max = 2 }, nil, true)
3969+
Cryptid.manipulate(card, { value = 2 })
39703970
end)
39713971
end,
39723972
init = function(self)
@@ -3978,7 +3978,7 @@ local multiply = {
39783978
if G.jokers.cards[i].config.cry_multiply then
39793979
m = G.jokers.cards[i].config.cry_multiply
39803980
Cryptid.with_deck_effects(G.jokers.cards[i], function(card)
3981-
Cryptid.misprintize(card, { min = 1 / m, max = 1 / m }, nil, true)
3981+
Cryptid.manipulate(card, { value = 1 /m })
39823982
end)
39833983
G.jokers.cards[i].config.cry_multiply = nil
39843984
end

items/deck.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ local glowing = {
534534
for i = 1, #G.jokers.cards do
535535
if not Card.no(G.jokers.cards[i], "immutable", true) then
536536
Cryptid.with_deck_effects(G.jokers.cards[i], function(card)
537-
Cryptid.misprintize(card, { min = 1.25, max = 1.25 }, nil, true)
537+
Cryptid.manipulate(card, { value = 1.25 })
538538
end)
539539
end
540540
end
@@ -1081,7 +1081,7 @@ local antimatter = {
10811081
then
10821082
for i = 1, #G.jokers.cards do
10831083
Cryptid.with_deck_effects(G.jokers.cards[i], function(card)
1084-
Cryptid.misprintize(card, { min = 1.25, max = 1.25 }, nil, true)
1084+
Cryptid.manipulate(card, { value = 1.25 })
10851085
end)
10861086
end
10871087
end

items/exotic.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ local gemino = {
12391239
local card = G.jokers.cards[1]
12401240
if not Card.no(G.jokers.cards[1], "immutable", true) then
12411241
Cryptid.with_deck_effects(G.jokers.cards[1], function(card)
1242-
Cryptid.misprintize(card, { min = 2, max = 2 }, nil, true)
1242+
Cryptid.manipulate(card, { value = 2 })
12431243
end)
12441244
check = true
12451245
end

items/misc.lua

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -809,9 +809,8 @@ local oversat = {
809809
on_apply = function(card)
810810
if not card.ability.cry_oversat then
811811
Cryptid.with_deck_effects(card, function(card)
812-
Cryptid.misprintize(card, {
813-
min = 2,
814-
max = 2,
812+
Cryptid.manipulate(card, {
813+
value = 2,
815814
}, nil, true)
816815
end)
817816
if card.config.center.apply_oversat then
@@ -827,8 +826,8 @@ local oversat = {
827826
end,
828827
on_remove = function(card)
829828
Cryptid.with_deck_effects(card, function(card)
830-
Cryptid.misprintize(card, { min = 1, max = 1 }, true)
831-
Cryptid.misprintize(card) -- Correct me if i'm wrong but this is for misprint deck. or atleast it is after this patch
829+
Cryptid.manipulate(card, { value = 1 / 2 })
830+
Cryptid.manipulate(card) -- Correct me if i'm wrong but this is for misprint deck. or atleast it is after this patch
832831
end)
833832
card.ability.cry_oversat = nil
834833
end,
@@ -934,16 +933,17 @@ local glitched = {
934933
on_apply = function(card)
935934
if not card.ability.cry_glitched then
936935
Cryptid.with_deck_effects(card, function(card)
937-
Cryptid.misprintize(card, {
938-
min = 0.1,
939-
max = 10,
940-
}, nil, true)
936+
Cryptid.manipulate(card, {
937+
min = 0.1, max = 10
938+
})
941939
end)
940+
942941
if card.config.center.apply_glitched then
943942
card.config.center:apply_glitched(card, function(val)
944-
return Cryptid.misprintize_val(val, {
943+
return Cryptid.manipulate_value(val, {
945944
min = 0.1 * (G.GAME.modifiers.cry_misprint_min or 1),
946945
max = 10 * (G.GAME.modifiers.cry_misprint_max or 1),
946+
type = "X"
947947
}, Cryptid.is_card_big(card))
948948
end)
949949
end
@@ -952,8 +952,8 @@ local glitched = {
952952
end,
953953
on_remove = function(card)
954954
Cryptid.with_deck_effects(card, function(card)
955-
Cryptid.misprintize(card, { min = 1, max = 1 }, true)
956-
Cryptid.misprintize(card) -- Correct me if i'm wrong but this is for misprint deck. or atleast it is after this patch
955+
Cryptid.manipulate(card, { min = 1, max = 1, dont_stack = true })
956+
Cryptid.manipulate(card) -- Correct me if i'm wrong but this is for misprint deck. or atleast it is after this patch
957957
end)
958958
card.ability.cry_glitched = nil
959959
end,

items/misc_joker.lua

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8816,11 +8816,9 @@ local tropical_smoothie = {
88168816
if v ~= card then
88178817
if not Card.no(v, "immutable", true) then
88188818
Cryptid.with_deck_effects(v, function(cards)
8819-
Cryptid.misprintize(
8819+
Cryptid.manipulate(
88208820
cards,
8821-
{ min = card.ability.extra, max = card.ability.extra },
8822-
nil,
8823-
true
8821+
{ value = card.ability.extra }
88248822
)
88258823
end)
88268824
check = true
@@ -9199,11 +9197,9 @@ local oil_lamp = { --You want it? It's yours my friend
91999197
if not Card.no(G.jokers.cards[i + 1], "immutable", true) then
92009198
check = true
92019199
Cryptid.with_deck_effects(G.jokers.cards[i + 1], function(cards)
9202-
Cryptid.misprintize(
9200+
Cryptid.manipulate(
92039201
cards,
9204-
{ min = card.ability.extra.increase, max = card.ability.extra.increase },
9205-
nil,
9206-
true
9202+
{ value = card.ability.extra.increase }
92079203
)
92089204
end)
92099205
end

items/sleeve.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ if CardSleeves then
186186
for i = 1, #G.jokers.cards do
187187
if not Card.no(G.jokers.cards[i], "immutable", true) then
188188
Cryptid.with_deck_effects(G.jokers.cards[i], function(card)
189-
Cryptid.misprintize(card, { min = 1.25, max = 1.25 }, nil, true)
189+
Cryptid.manipulate(card, { value = 1.25 })
190190
end)
191191
end
192192
end
@@ -484,7 +484,7 @@ if CardSleeves then
484484
for i = 1, #G.jokers.cards do
485485
if not Card.no(G.jokers.cards[i], "immutable", true) then
486486
Cryptid.with_deck_effects(G.jokers.cards[i], function(card)
487-
Cryptid.misprintize(card, { min = 1.25, max = 1.25 }, nil, true)
487+
Cryptid.manipulate(card, { value = 1.25 })
488488
end)
489489
end
490490
end
@@ -695,7 +695,7 @@ if CardSleeves then
695695
then
696696
for i = 1, #G.jokers.cards do
697697
Cryptid.with_deck_effects(G.jokers.cards[i], function(card)
698-
Cryptid.misprintize(card, { min = 1.25, max = 1.25 }, nil, true)
698+
Cryptid.manipulate(card, { value = 1.25 })
699699
end)
700700
end
701701
end

items/spooky.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,14 +1557,14 @@ local jawbreaker = {
15571557
if i > 1 then
15581558
if not Card.no(G.jokers.cards[i - 1], "immutable", true) then
15591559
Cryptid.with_deck_effects(G.jokers.cards[i - 1], function(card)
1560-
Cryptid.misprintize(card, { min = 2, max = 2 }, nil, true)
1560+
Cryptid.manipulate(card, { value = 2 })
15611561
end)
15621562
end
15631563
end
15641564
if i < #G.jokers.cards then
15651565
if not Card.no(G.jokers.cards[i + 1], "immutable", true) then
15661566
Cryptid.with_deck_effects(G.jokers.cards[i + 1], function(card)
1567-
Cryptid.misprintize(card, { min = 2, max = 2 }, nil, true)
1567+
Cryptid.manipulate(card, { value = 2})
15681568
end)
15691569
end
15701570
end
@@ -1602,14 +1602,14 @@ local jawbreaker = {
16021602
if i > 1 then
16031603
if not Card.no(G.jokers.cards[i - 1], "immutable", true) then
16041604
Cryptid.with_deck_effects(G.jokers.cards[i - 1], function(card)
1605-
Cryptid.misprintize(card, { min = 2, max = 2 }, nil, true)
1605+
Cryptid.manipulate(card, { value = 2 })
16061606
end)
16071607
end
16081608
end
16091609
if i < #G.jokers.cards then
16101610
if not Card.no(G.jokers.cards[i + 1], "immutable", true) then
16111611
Cryptid.with_deck_effects(G.jokers.cards[i + 1], function(card)
1612-
Cryptid.misprintize(card, { min = 2, max = 2 }, nil, true)
1612+
Cryptid.manipulate(card, { value = 2 })
16131613
end)
16141614
end
16151615
end

items/tag.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ local better_voucher = {
13311331
G.P_CENTERS[voucher_key],
13321332
{ bypass_discovery_center = true, bypass_discovery_ui = true }
13331333
)
1334-
Cryptid.misprintize(card)
1334+
Cryptid.manipulate(card)
13351335
create_shop_card_ui(card, "Voucher", G.shop_vouchers)
13361336
card:start_materialize()
13371337
if G.GAME.modifiers.cry_force_edition and not G.GAME.modifiers.cry_force_random_edition then

lib/misc.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ function Cryptid.bonus_voucher_mod(mod)
468468
{ bypass_discovery_center = true, bypass_discovery_ui = true }
469469
)
470470
card.shop_cry_bonusvoucher = #curr_bonus
471-
Cryptid.misprintize(card)
471+
Cryptid.manipulate(card)
472472
if G.GAME.events.ev_cry_choco2 then
473473
card.misprint_cost_fac = (card.misprint_cost_fac or 1) * 2
474474
card:set_cost()

lib/misprintize.lua

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Cryptid.misprintize_value_blacklist = {
1515
h_size = false,
1616
selected_d6_face = false,
1717
cry_hook_id = false,
18+
colour = false
1819
-- TARGET: Misprintize Value Blacklist (format: key = false, )
1920
}
2021

@@ -379,3 +380,99 @@ function Card:get_nominal(mod)
379380
+ 10 * self.base.face_nominal * rank_mult
380381
+ 0.000001 * self.unique_val
381382
end
383+
384+
function Cryptid.manipulate(card, args)
385+
if not args then
386+
Cryptid.manipulate(card, {
387+
min = G.GAME.modifiers.cry_misprint_min,
388+
max = G.GAME.modifiers.cry_misprint_max,
389+
type = "X",
390+
dont_stack = true
391+
})
392+
else
393+
if not args.type then args.type = "X" end
394+
local caps = card.config.center.misprintize_caps or {}
395+
if card.infinifusion then
396+
if card.config.center == card.infinifusion_center or card.config.center.key == "j_infus_fused" then
397+
calculate_infinifusion(card, nil, function(i)
398+
Cryptid.manipulate(card, args)
399+
end)
400+
end
401+
end
402+
Cryptid.manipulate_table(card, card, "ability", args)
403+
if card.base then Cryptid.manipulate_table(card, card, "base", args) end
404+
if caps then
405+
for i, v in pairs(caps) do
406+
if type(v) == "table" and not v.tetrate then
407+
for i2, v2 in pairs(v) do
408+
if to_big(card.ability[i][i2]) > to_big(v2) then
409+
card.ability[i][i2] = Cryptid.sanity_check(v2, Cryptid.is_card_big(card))
410+
end
411+
end
412+
elseif (type(v) == "table" and v.tetrate) or type(v) == "number" then
413+
if to_big(card.ability[i]) > to_big(v) then
414+
card.ability[i] = Cryptid.sanity_check(v, Cryptid.is_card_big(card))
415+
end
416+
end
417+
end
418+
end
419+
if card.ability.consumeable then
420+
for k, v in pairs(card.ability.consumeable) do
421+
card.ability.consumeable[k] = Cryptid.deep_copy(card.ability[k])
422+
end
423+
end
424+
end
425+
end
426+
427+
function Cryptid.manipulate_table(card, ref_table, ref_value, args)
428+
for i, v in pairs(ref_table[ref_value]) do
429+
if (type(v) == "number" or (type(v) == "table" and v.tetrate)) and Cryptid.misprintize_value_blacklist[i] ~= false then
430+
local num = v
431+
if args.dont_stack then
432+
if not Cryptid.base_values[card.config.center.key] then Cryptid.base_values[card.config.center.key] = {} end
433+
if not Cryptid.base_values[card.config.center.key][i] then Cryptid.base_values[card.config.center.key][i] = v end
434+
num = Cryptid.base_values[card.config.center.key][i]
435+
end
436+
if args.big then
437+
ref_table[ref_value][i] = Cryptid.manipulate_value(num, args, args.big)
438+
else
439+
ref_table[ref_value][i] = Cryptid.manipulate_value(num, args, Cryptid.is_card_big(card))
440+
end
441+
elseif i ~= "immutable" and type(v) == "table" and Cryptid.misprintize_value_blacklist[i] ~= false then
442+
Cryptid.manipulate_table(card, ref_table[ref_value], i, args)
443+
end
444+
end
445+
end
446+
447+
function Cryptid.manipulate_value(num, args, is_big)
448+
if args.func then
449+
num = args.func(num, args, is_big)
450+
else
451+
if args.min and args.max then
452+
local new_args = args
453+
local big_min = to_big(args.min)
454+
local big_max = to_big(args.max)
455+
local new_value = Cryptid.log_random(pseudoseed(args.seed or ("cry_misprint" .. G.GAME.round_resets.ante)), big_min, big_max)
456+
if args.type == "+" then
457+
if to_big(num) ~= to_big(0) and to_big(num) ~= to_big(1) then
458+
num = to_big(num) + to_big(new_value)
459+
end
460+
elseif args.type == "X" then
461+
num = to_big(num) * to_big(new_value)
462+
elseif args.type == "hyper" then
463+
if to_big(num) ~= to_big(0) and to_big(num) ~= to_big(1) then
464+
num = to_big(num):arrow(args.value.arrows, to_big(new_value))
465+
end
466+
end
467+
elseif args.value then
468+
if args.type == "+" then
469+
num = to_big(num) + to_big(args.value)
470+
elseif args.type == "X" then
471+
num = to_big(num) * to_big(args.value)
472+
elseif args.type == "hyper" then
473+
num = to_big(num):arrow(args.value.arrows, to_big(args.value.height))
474+
end
475+
end
476+
end
477+
return Cryptid.sanity_check(num, is_big)
478+
end

0 commit comments

Comments
 (0)