Skip to content

Commit 67352dc

Browse files
committed
improve checks for big numbers
1 parent 99f7ac5 commit 67352dc

File tree

7 files changed

+33
-32
lines changed

7 files changed

+33
-32
lines changed

items/epic.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ local circus = {
12271227
if context.forcetrigger then
12281228
local total = 1
12291229
for i, v in pairs(card.ability.extra) do
1230-
if type(v) == "number" or (type(v) == "table" and v.tetrate) then
1230+
if Cryptid.is_number(v) then
12311231
total = total * v
12321232
end
12331233
end

lib/ascended.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function G.FUNCS.get_poker_hand_info(_cards)
132132
ease_colour(G.C.UI_CHIPS, copy_table(G.C.GOLD), 0.3)
133133
ease_colour(G.C.UI_MULT, copy_table(G.C.GOLD), 0.3)
134134
G.GAME.current_round.current_hand.cry_asc_num_text = (
135-
a_power and (type(a_power) == "table" and a_power:gt(to_big(0)) or a_power > 0)
135+
a_power and (Cryptid.is_big(a_power) and a_power:gt(to_big(0)) or a_power > 0)
136136
)
137137
and " (+" .. a_power .. ")"
138138
or ""

lib/calculate.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function Card:cry_copy_ability()
2424
local orig_ability = {}
2525
if self.ability then
2626
for i, j in pairs(self.ability) do
27-
if (type(j) == "table") and is_number(j) then
27+
if Cryptid.is_big(j) then
2828
orig_ability[i] = to_big(j)
2929
elseif type(j) == "table" then
3030
orig_ability[i] = {}

lib/misc.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,3 +1466,11 @@ function Card_Character:say_stuff(n, not_first, quip_key)
14661466
return say_stuff_ref(self, n, not_first, quip_key)
14671467
end
14681468
end
1469+
1470+
1471+
function Cryptid.is_number(x)
1472+
return type(x) == "number" or (type(x) == "table" and is_number(x)) or (is_big and is_big(x))
1473+
end
1474+
function Cryptid.is_big(x)
1475+
return (type(x) == "table" and is_number(x)) or (is_big and is_big(x))
1476+
end

lib/misprintize.lua

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,12 @@ function Cryptid.misprintize_val(val, override, big, grow_type, pow_level)
229229
return val
230230
end
231231
function Cryptid.sanity_check(val, is_big)
232+
if not Talisman then return val end
232233
if is_big then
233234
if not val or type(val) == "number" and (val ~= val or val > 1e300 or val < -1e300) then
234235
val = 1e300
235236
end
236-
if type(val) == "table" then
237+
if Cryptid.is_big(val) then
237238
return val
238239
end
239240
if val > 1e100 or val < -1e100 then
@@ -243,7 +244,7 @@ function Cryptid.sanity_check(val, is_big)
243244
if not val or type(val) == "number" and (val ~= val or val > 1e300 or val < -1e300) then
244245
return 1e300
245246
end
246-
if type(val) == "table" then
247+
if Cryptid.is_big(val) then
247248
if val > to_big(1e300) then
248249
return 1e300
249250
end
@@ -333,7 +334,7 @@ function Cryptid.misprintize(card, override, force_reset, stack, grow_type, pow_
333334
end
334335
if clamps then
335336
for i, v in pairs(clamps) do
336-
if type(v) == "table" and not v.tetrate then
337+
if type(v) == "table" and not Cryptid.is_big(v) then
337338
for i2, v2 in pairs(v) do
338339
if to_big(card.ability[i][i2]) > to_big(v2) then
339340
card.ability[i][i2] = Cryptid.sanity_check(v2, Cryptid.is_card_big(card))
@@ -345,7 +346,7 @@ function Cryptid.misprintize(card, override, force_reset, stack, grow_type, pow_
345346
end
346347
end
347348
end
348-
elseif (type(v) == "table" and v.tetrate) or type(v) == "number" then
349+
elseif Cryptid.is_number(v) then
349350
if to_big(card.ability[i]) > to_big(v) then
350351
card.ability[i] = Cryptid.sanity_check(v, Cryptid.is_card_big(card))
351352
if to_big(card.ability[i]) > to_big(-1e100) or to_big(card.ability[i]) < to_big(1e100) then
@@ -396,11 +397,12 @@ function Card:get_nominal(mod)
396397
end
397398

398399
function Cryptid.manipulate(card, args)
400+
if not card or not card.config or not card.config.center then return end
399401
if not Card.no(card, "immutable", true) or (args and args.bypass_checks) then
400402
if not args then
401403
return Cryptid.manipulate(card, {
402-
min = (G.GAME.modifiers.cry_misprint_min or 1) * (G.GAME.modifiers.cry_jkr_misprint_mod or 1),
403-
max = (G.GAME.modifiers.cry_misprint_max or 1) * (G.GAME.modifiers.cry_jkr_misprint_mod or 1),
404+
min = (G.GAME.modifiers.cry_misprint_min or 1),
405+
max = (G.GAME.modifiers.cry_misprint_max or 1),
404406
type = "X",
405407
dont_stack = true,
406408
no_deck_effects = true,
@@ -438,13 +440,13 @@ function Cryptid.manipulate(card, args)
438440
end
439441
if caps then
440442
for i, v in pairs(caps) do
441-
if type(v) == "table" and not v.tetrate then
443+
if Cryptid.is_big(v) then
442444
for i2, v2 in pairs(v) do
443445
if to_big(card.ability[i][i2]) > to_big(v2) then
444446
card.ability[i][i2] = Cryptid.sanity_check(v2, Cryptid.is_card_big(card))
445447
end
446448
end
447-
elseif (type(v) == "table" and v.tetrate) or type(v) == "number" then
449+
elseif Cryptid.is_number(v) then
448450
if to_big(card.ability[i]) > to_big(v) then
449451
card.ability[i] = Cryptid.sanity_check(v, Cryptid.is_card_big(card))
450452
end
@@ -456,7 +458,7 @@ function Cryptid.manipulate(card, args)
456458
if not Cryptid.base_values[card.config.center.key] then
457459
Cryptid.base_values[card.config.center.key] = {}
458460
for i, v in pairs(config) do
459-
if (type(v) == "table" and v.tetrate) or type(v) == "number" and to_big(v) ~= to_big(0) then
461+
if Cryptid.is_number(v) and to_big(v) ~= to_big(0) then
460462
Cryptid.base_values[card.config.center.key][i .. "ability"] = v
461463
elseif type(v) == "table" then
462464
for i2, v2 in pairs(v) do
@@ -488,7 +490,7 @@ function Cryptid.manipulate_table(card, ref_table, ref_value, args, tblkey)
488490
end
489491
for i, v in pairs(ref_table[ref_value]) do
490492
if
491-
(type(v) == "number" or (type(v) == "table" and v.tetrate))
493+
Cryptid.is_number(v)
492494
and Cryptid.misprintize_value_blacklist[i] ~= false
493495
then
494496
local num = v
@@ -504,19 +506,12 @@ function Cryptid.manipulate_table(card, ref_table, ref_value, args, tblkey)
504506
or Cryptid.base_values[card.config.center.key][i .. "consumeable"]
505507
end
506508
end
507-
local new_val = Cryptid.manipulate_value(num, args, args.big or Cryptid.is_card_big(card), i)
508-
ref_table[ref_value][i] = new_val
509-
510-
-- take double scale / scalae into account
511-
if ref_value == "ability" and ref_table.ability.cry_scaling_info then
512-
ref_table.ability.cry_scaling_info[i] = new_val
509+
if args.big ~= nil then
510+
ref_table[ref_value][i] = Cryptid.manipulate_value(num, args, args.big, i)
511+
else
512+
ref_table[ref_value][i] = Cryptid.manipulate_value(num, args, Cryptid.is_card_big(card), i)
513513
end
514-
elseif
515-
i ~= "immutable"
516-
and not (ref_value == "ability" and i == "cry_scaling_info")
517-
and type(v) == "table"
518-
and Cryptid.misprintize_value_blacklist[i] ~= false
519-
then
514+
elseif i ~= "immutable" and type(v) == "table" and Cryptid.misprintize_value_blacklist[i] ~= false then
520515
Cryptid.manipulate_table(card, ref_table[ref_value], i, args)
521516
end
522517
end
@@ -547,7 +542,7 @@ function Cryptid.manipulate_value(num, args, is_big, name)
547542
end
548543
elseif args.type == "^" then
549544
num = to_big(num) ^ new_value
550-
elseif args.type == "hyper" then
545+
elseif args.type == "hyper" and SMODS.Mods.Talisman and SMODS.Mods.Talisman.can_load then
551546
if to_big(num) ~= to_big(0) and to_big(num) ~= to_big(1) then
552547
num = to_big(num):arrow(args.value.arrows, to_big(new_value))
553548
end
@@ -565,7 +560,7 @@ function Cryptid.manipulate_value(num, args, is_big, name)
565560
end
566561
elseif args.type == "^" then
567562
num = to_big(num) ^ args.value
568-
elseif args.type == "hyper" then
563+
elseif args.type == "hyper" and SMODS.Mods.Talisman and SMODS.Mods.Talisman.can_load then
569564
num = to_big(num):arrow(args.value.arrows, to_big(args.value.height))
570565
end
571566
end

lovely/Ascended.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ G.GAME.hands[text].played_this_round = G.GAME.hands[text].played_this_round + 1
3939
'''
4040
position = "before"
4141
payload = '''
42-
if G.GAME.current_round.current_hand.cry_asc_num and (((type(G.GAME.current_round.current_hand.cry_asc_num) == "table" and G.GAME.current_round.current_hand.cry_asc_num:gt(to_big(G.GAME.cry_exploit_override and 1 or 0)) or G.GAME.current_round.current_hand.cry_asc_num > (G.GAME.cry_exploit_override and 1 or 0)))) then
42+
if G.GAME.current_round.current_hand.cry_asc_num and (((Cryptid.is_big(G.GAME.current_round.current_hand.cry_asc_num) and G.GAME.current_round.current_hand.cry_asc_num:gt(to_big(G.GAME.cry_exploit_override and 1 or 0)) or G.GAME.current_round.current_hand.cry_asc_num > (G.GAME.cry_exploit_override and 1 or 0)))) then
4343
G.GAME.cry_asc_played = G.GAME.cry_asc_played and G.GAME.cry_asc_played+1 or 1
4444
end
4545
'''

lovely/misc.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,8 @@ payload = '''
207207
if args and args.vars and type(args.vars) == "table" then
208208
local reset = {}
209209
for i, j in pairs(args.vars) do
210-
if type(j) == 'table' then
211-
if (j.new and type(j.new) == "function") and ((j.m and j.e) or (j.array and j.sign and (type(j.array) == "table"))) then
212-
reset[i] = number_format(j)
213-
end
210+
if Cryptid.is_big(j) then
211+
reset[i] = number_format(j)
214212
end
215213
end
216214
for i, j in pairs(reset) do

0 commit comments

Comments
 (0)