Skip to content

Commit ea13509

Browse files
Merge pull request #510 from bobjoe400/working-big-num_
It's a me, mario
2 parents 7f9f0b5 + 1671bbb commit ea13509

File tree

5 files changed

+175
-77
lines changed

5 files changed

+175
-77
lines changed

items/misc_joker.lua

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ local potofjokes = {
221221
},
222222
name = "cry-Pot of Jokes",
223223
key = "pot_of_jokes",
224-
config = { extra = { h_size = -2, h_mod = 1 } },
224+
config = { extra = { h_size = -2, h_mod = 1,},
225+
immutable = { h_added = 0, h_mod_max = 1000,}},
225226
pos = { x = 5, y = 0 },
226227
rarity = 3,
227228
order = 104,
@@ -234,19 +235,32 @@ local potofjokes = {
234235
center.ability.extra.h_size < 0 and center.ability.extra.h_size
235236
or "+" .. math.min(1000, center.ability.extra.h_size),
236237
center.ability.extra.h_mod,
238+
"+" .. center.ability.immutable.h_mod_max,
237239
},
238240
}
239241
end,
240242
calculate = function(self, card, context)
241243
if context.end_of_round and not context.individual and not context.repetition and not context.blueprint then
242-
if to_big(card.ability.extra.h_size) + to_big(card.ability.extra.h_mod) >= to_big(1000) then
243-
card.ability.extra.h_size = 1000
244+
if to_big(card.ability.extra.h_size) + to_big(card.ability.extra.h_mod) >= to_big(card.ability.immutable.h_mod_max) then
245+
card.ability.extra.h_size = card.ability.immutable.h_mod_max
244246
card.ability.extra.h_mod = 0
247+
248+
-- Fallback for if Pot of Jokes comes into this calcuate function with large h_size
249+
if card.ability.immutable.h_added < card.ability.immutable.h_mod_max then
250+
local delta = card.ability.immutable.h_mod_max - card.ability.immutable.h_added
251+
252+
G.hand:change_size(delta)
253+
254+
card.ability.immutable.h_added = card.ability.immutable.h_mod_max
255+
end
245256
end
246257

247-
G.hand:change_size(math.min(math.max(0, 1000 - card.ability.extra.h_size), card.ability.extra.h_mod))
258+
local delta = math.min(math.max(0, card.ability.immutable.h_mod_max - card.ability.extra.h_size), card.ability.extra.h_mod)
259+
260+
G.hand:change_size(delta)
248261

249262
card.ability.extra.h_size = card.ability.extra.h_size + card.ability.extra.h_mod
263+
card.ability.immutable.h_added = card.ability.immutable.h_added + delta
250264

251265
return {
252266
message = localize({ type = "variable", key = "a_handsize", vars = { card.ability.extra.h_mod } }),
@@ -256,10 +270,10 @@ local potofjokes = {
256270
end
257271
end,
258272
add_to_deck = function(self, card, from_debuff)
259-
G.hand:change_size(math.min(1000, card.ability.extra.h_size))
273+
G.hand:change_size(math.min(card.ability.immutable.h_mod_max, card.ability.extra.h_size))
260274
end,
261275
remove_from_deck = function(self, card, from_debuff)
262-
G.hand:change_size(-1 * math.min(1000, card.ability.extra.h_size))
276+
G.hand:change_size(-1 * math.min(card.ability.immutable.h_mod_max, card.ability.extra.h_size))
263277
end,
264278
cry_credits = {
265279
idea = {

lib/misc.lua

Lines changed: 96 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -512,62 +512,109 @@ function set_profile_progress()
512512
end
513513
end
514514

515-
Cryptid.big_num_whitelist = {
516-
j_ride_the_bus = true,
517-
j_egg = true,
518-
j_runner = true,
519-
j_ice_cream = true,
520-
j_constellation = true,
521-
j_green_joker = true,
522-
j_red_card = true,
523-
j_madness = true,
524-
j_square = true,
525-
j_vampire = true,
526-
j_hologram = true,
527-
j_obelisk = true,
528-
j_turtle_bean = true,
529-
j_lucky_cat = true,
530-
j_flash = true,
531-
j_popcorn = true,
532-
j_trousers = true,
533-
j_ramen = true,
534-
j_castle = true,
535-
j_campfire = true,
536-
j_throwback = true,
537-
j_glass = true,
538-
j_wee = true,
539-
j_hit_the_road = true,
540-
j_caino = true,
541-
j_yorick = true,
542-
-- Once all Cryptid Jokers get support for this, these can be removed
543-
j_cry_dropshot = true,
544-
j_cry_wee_fib = true,
545-
j_cry_whip = true,
546-
j_cry_pickle = true,
547-
j_cry_chili_pepper = true,
548-
j_cry_cursor = true,
549-
j_cry_jimball = true,
550-
j_cry_eternalflame = true,
551-
j_cry_fspinner = true,
552-
j_cry_krustytheclown = true,
553-
j_cry_antennastoheaven = true,
554-
j_cry_mondrian = true,
555-
j_cry_spaceglobe = true,
556-
j_cry_m = true,
557-
j_cry_exponentia = true,
558-
j_cry_crustulum = true,
559-
j_cry_primus = true,
560-
j_cry_stella_mortis = true,
561-
j_cry_hugem = true,
562-
j_cry_mprime = true,
515+
Cryptid.big_num_blacklist = {
516+
-- empty for now add more later
563517
}
564518

519+
--[[
520+
List of immutable jokers (these will return false for is_card_big):
521+
Cryptid:
522+
Epic:
523+
sync_catalyst
524+
canvas
525+
error_joker
526+
M
527+
double_scale
528+
curse_sob
529+
bonusjoker
530+
altgoogol
531+
soccer
532+
533+
Exotic:
534+
speculo
535+
effarcire
536+
circulus_pistoris
537+
gemino
538+
539+
M:
540+
jollysus
541+
bubblem
542+
loopy
543+
reverse
544+
545+
Misc_Jokers:
546+
happyhouse
547+
maximized
548+
queensgambit
549+
seal_the_deal
550+
maze
551+
panopticon
552+
happy
553+
translucent
554+
kscope
555+
oldinvisible
556+
necromancer
557+
lebaron_james
558+
huntingseason
559+
eyeofhagane
560+
561+
Spooky:
562+
wrapped
563+
choco_dice
564+
565+
Base:
566+
Fortune Teller
567+
Shoot the Moon
568+
Riff-raff
569+
Chaos the Clown
570+
Dusk
571+
Mime
572+
Hack
573+
Sock and Buskin
574+
Invisible Joker
575+
Swashbuckler
576+
Smeared Joker
577+
Certificate
578+
Mr. Bones
579+
Diet Cola
580+
Luchador
581+
Midas Mask
582+
Shortcut
583+
Seance
584+
Superposition
585+
Sixth Sense
586+
DNA
587+
Splash
588+
Supernova
589+
Pareidolia
590+
Raised Fist
591+
Marble Joker
592+
Four Fingers
593+
Joker Stencil
594+
Showman
595+
Blueprint
596+
Oops! All 6s
597+
Brainstorm
598+
Cartomancer
599+
Astronomer
600+
Burnt Joker
601+
Chicot
602+
Perkeo
603+
]]
604+
565605
function Cryptid.is_card_big(joker)
566606
local center = joker.config and joker.config.center
567607
if not center then
568608
return false
569609
end
570-
return Cryptid.big_num_whitelist[center.key or "Nope!"] --[[or
610+
611+
if center.immutable and center.immutable == true then
612+
return false
613+
end
614+
615+
local in_blacklist = Cryptid.big_num_blacklist[center.key or "Nope!"] or false
616+
617+
return not in_blacklist --[[or
571618
(center.mod and center.mod.id == "Cryptid" and not center.no_break_infinity) or center.break_infinity--]]
572619
end
573620

lib/misprintize.lua

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33
--Redefine these here because they're always used
44
Cryptid.base_values = {}
5+
function Cryptid.calculate_misprint(initial, min, max)
6+
local big_initial = (type(initial) ~= "table" and to_big(initial)) or initial
7+
local big_min = (type(min) ~= "table" and to_big(min)) or min
8+
local big_max = (type(max) ~= "table" and to_big(max)) or max
9+
10+
local grow = Cryptid.log_random(
11+
pseudoseed("cry_misprint" .. G.GAME.round_resets.ante),
12+
big_min,
13+
big_max
14+
)
15+
16+
local calc = big_initial * grow
17+
18+
if calc > to_big(-1e100) and calc < to_big(1e100) then
19+
calc = to_number(calc)
20+
end
21+
22+
return calc
23+
end
24+
525
function Cryptid.misprintize_tbl(name, ref_tbl, ref_value, clear, override, stack, big)
626
if name and ref_tbl and ref_value then
727
tbl = Cryptid.deep_copy(ref_tbl[ref_value])
@@ -18,28 +38,33 @@ function Cryptid.misprintize_tbl(name, ref_tbl, ref_value, clear, override, stac
1838
and not (k == "qty")
1939
and not (k == "x_mult" and v == 1 and not tbl.override_x_mult_check)
2040
and not (k == "selected_d6_face")
41+
and not (k == "d_size")
42+
and not (k == "h_size")
2143
then --Temp fix, even if I did clamp the number to values that wouldn't crash the game, the fact that it did get randomized means that there's a higher chance for 1 or 6 than other values
2244
if not Cryptid.base_values[name] then
2345
Cryptid.base_values[name] = {}
2446
end
2547
if not Cryptid.base_values[name][k] then
2648
Cryptid.base_values[name][k] = tbl[k]
2749
end
50+
51+
local initial = (stack and tbl[k] or Cryptid.base_values[name][k])
52+
local min = override and override.min or G.GAME.modifiers.cry_misprint_min
53+
local max = override and override.max or G.GAME.modifiers.cry_misprint_max
54+
2855
tbl[k] = Cryptid.sanity_check(
2956
clear and Cryptid.base_values[name][k]
3057
or cry_format(
31-
(stack and tbl[k] or Cryptid.base_values[name][k])
32-
* Cryptid.log_random(
33-
pseudoseed("cry_misprint" .. G.GAME.round_resets.ante),
34-
override and override.min or G.GAME.modifiers.cry_misprint_min,
35-
override and override.max or G.GAME.modifiers.cry_misprint_max
36-
),
58+
Cryptid.calculate_misprint(initial, min, max),
3759
"%.2g"
3860
),
3961
big
4062
)
4163
end
42-
else
64+
elseif
65+
not (k == "immutable")
66+
then
67+
4368
for _k, _v in pairs(tbl[k]) do
4469
if
4570
is_number(tbl[k][_k])
@@ -51,6 +76,8 @@ function Cryptid.misprintize_tbl(name, ref_tbl, ref_value, clear, override, stac
5176
and not (_k == "qty")
5277
and not (k == "x_mult" and v == 1 and not tbl[k].override_x_mult_check)
5378
and not (_k == "selected_d6_face")
79+
and not (k == "d_size")
80+
and not (k == "h_size")
5481
then --Refer to above
5582
if not Cryptid.base_values[name] then
5683
Cryptid.base_values[name] = {}
@@ -61,15 +88,15 @@ function Cryptid.misprintize_tbl(name, ref_tbl, ref_value, clear, override, stac
6188
if not Cryptid.base_values[name][k][_k] then
6289
Cryptid.base_values[name][k][_k] = tbl[k][_k]
6390
end
91+
92+
local initial = (stack and tbl[k][_k] or Cryptid.base_values[name][k][_k])
93+
local min = override and override.min or G.GAME.modifiers.cry_misprint_min
94+
local max = override and override.max or G.GAME.modifiers.cry_misprint_max
95+
6496
tbl[k][_k] = Cryptid.sanity_check(
6597
clear and Cryptid.base_values[name][k][_k]
6698
or cry_format(
67-
(stack and tbl[k][_k] or Cryptid.base_values[name][k][_k])
68-
* Cryptid.log_random(
69-
pseudoseed("cry_misprint" .. G.GAME.round_resets.ante),
70-
override and override.min or G.GAME.modifiers.cry_misprint_min,
71-
override and override.max or G.GAME.modifiers.cry_misprint_max
72-
),
99+
Cryptid.calculate_misprint(initial, min, max),
73100
"%.2g"
74101
),
75102
big
@@ -83,14 +110,14 @@ function Cryptid.misprintize_tbl(name, ref_tbl, ref_value, clear, override, stac
83110
end
84111
function Cryptid.misprintize_val(val, override, big)
85112
if is_number(val) then
113+
114+
86115
val = Cryptid.sanity_check(
87116
cry_format(
88-
val
89-
* Cryptid.log_random(
90-
pseudoseed("cry_misprint" .. G.GAME.round_resets.ante),
91-
override and override.min or G.GAME.modifiers.cry_misprint_min,
92-
override and override.max or G.GAME.modifiers.cry_misprint_max
93-
),
117+
Cryptid.calculate_misprint(
118+
val,
119+
override and override.min or G.GAME.modifiers.cry_misprint_min,
120+
override and override.max or G.GAME.modifiers.cry_misprint_max),
94121
"%.2g"
95122
),
96123
big
@@ -113,6 +140,15 @@ function Cryptid.sanity_check(val, is_big)
113140
if not val or type(val) == "number" and (val ~= val or val > 1e300 or val < -1e300) then
114141
return 1e300
115142
end
143+
if type(val) == "table" then
144+
if val > to_big(1e300) then
145+
return 1e300
146+
end
147+
if val < to_big(-1e300) then
148+
return -1e300
149+
end
150+
return to_number(val)
151+
end
116152
return val
117153
end
118154
function Cryptid.misprintize(card, override, force_reset, stack)

localization/en-us.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,6 +2177,7 @@ return {
21772177
"{C:attention}#1#{} hand size,",
21782178
"increases by",
21792179
"{C:blue}#2#{} every round",
2180+
"{C:inactive}(Maximum {}{C:attention}#3#{}{C:inactive} hand size){}"
21802181
},
21812182
unlock = {
21822183
"Increase your {C:attention}handsize",

lovely/misc.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ target = "card.lua"
6262
pattern = "if self.ability.name ~= 'Seeing Double' and self.ability.x_mult > 1 and (self.ability.type == '' or next(context.poker_hands[self.ability.type])) then"
6363
position = "at"
6464
payload = '''
65-
if self.ability.name ~= 'Seeing Double' and to_big(self.ability.x_mult) > to_big(1) and (self.ability.type == '' or next(context.poker_hands[self.ability.type])) then
65+
if self.ability.name ~= 'Seeing Double' and to_big(self.ability.x_mult) > to_big(1) and (self.ability.type == '' or (context.poker_hands[self.ability.type] and next(context.poker_hands[self.ability.type]))) then
6666
'''
6767
match_indent = true
6868

@@ -82,7 +82,7 @@ target = "card.lua"
8282
pattern = "if self.ability.t_mult > 0 and next(context.poker_hands[self.ability.type]) then"
8383
position = "at"
8484
payload = '''
85-
if to_big(self.ability.t_mult) > to_big(0) and next(context.poker_hands[self.ability.type]) then
85+
if to_big(self.ability.t_mult) > to_big(0) and (context.poker_hands[self.ability.type] and next(context.poker_hands[self.ability.type])) then
8686
'''
8787
match_indent = true
8888

@@ -92,7 +92,7 @@ target = "card.lua"
9292
pattern = "if self.ability.t_chips > 0 and next(context.poker_hands[self.ability.type]) then"
9393
position = "at"
9494
payload = '''
95-
if to_big(self.ability.t_chips) > to_big(0) and next(context.poker_hands[self.ability.type]) then
95+
if to_big(self.ability.t_chips) > to_big(0) and (context.poker_hands[self.ability.type] and next(context.poker_hands[self.ability.type])) then
9696
'''
9797
match_indent = true
9898

0 commit comments

Comments
 (0)