Skip to content

Commit 352cb68

Browse files
committed
refactor library functions to use Cryptid global
1 parent cbf68ce commit 352cb68

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+531
-578
lines changed

Cryptid.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@
1717
-- If you're looking for a specific feature, browse the Items folder to see how it is implemented.
1818
-- If you're looking for a specific function, check the lib folder to see if it is there.
1919

20-
-- Initialize some important variables
2120
if not Cryptid then
2221
Cryptid = {}
2322
end
2423
local mod_path = "" .. SMODS.current_mod.path -- this path changes when each mod is loaded, but the local variable will retain Cryptid's path
2524
Cryptid.path = mod_path
2625
Cryptid_config = SMODS.current_mod.config
27-
-- This will save the current state even when settings are modified
28-
Cryptid.enabled = copy_table(Cryptid_config)
2926

3027
-- Enable optional features
3128
SMODS.current_mod.optional_features = {
@@ -184,7 +181,7 @@ end
184181
local inj = SMODS.injectItems
185182
function SMODS.injectItems(...)
186183
inj(...)
187-
cry_update_obj_registry()
184+
Cryptid.update_obj_registry()
188185
for _, t in ipairs({
189186
G.P_CENTERS,
190187
G.P_BLINDS,
@@ -241,7 +238,7 @@ local cryptidConfigTab = function()
241238
active_colour = HEX("40c76d"),
242239
ref_table = Cryptid_config,
243240
ref_value = "family_mode",
244-
callback = reload_cryptid_localization,
241+
callback = Cryptid.reload_localization,
245242
})
246243
cry_nodes[#cry_nodes + 1] = create_toggle({
247244
label = localize("cry_experimental"),
@@ -355,4 +352,4 @@ local cryptidTabs = function()
355352
}
356353
end
357354
SMODS.current_mod.extra_tabs = cryptidTabs
358-
SMODS.current_mod.config_tab = cryptidConfigTab
355+
SMODS.current_mod.config_tab = cryptidConfigTab

items/blind.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,10 @@ local shackle = {
546546
if G.GAME.modifiers.cry_force_edition and G.GAME.modifiers.cry_force_edition == "negative" then
547547
return false
548548
end
549-
return #advanced_find_joker(nil, nil, "e_negative", nil, true) ~= 0
549+
return #Cryptid.advanced_find_joker(nil, nil, "e_negative", nil, true) ~= 0
550550
end,
551551
recalc_debuff = function(self, card, from_blind)
552-
if (card.area == G.jokers) and not G.GAME.blind.disabled and safe_get(card, "edition", "negative") == true then
552+
if (card.area == G.jokers) and not G.GAME.blind.disabled and Cryptid.safe_get(card, "edition", "negative") == true then
553553
return true
554554
end
555555
return false
@@ -577,7 +577,7 @@ local pin = {
577577
if not G.jokers or not G.jokers.cards then
578578
return false
579579
end
580-
return #advanced_find_joker(nil, { 1, 2, 3 }, nil, nil, true) < #G.jokers.cards
580+
return #Cryptid.advanced_find_joker(nil, { 1, 2, 3 }, nil, nil, true) < #G.jokers.cards
581581
end,
582582
recalc_debuff = function(self, card, from_blind)
583583
if
@@ -665,18 +665,18 @@ local tornado = {
665665
order = 94,
666666
boss_colour = HEX("3dd9ca"),
667667
loc_vars = function(self)
668-
return { vars = { "" .. ((safe_get(G.GAME, "probabilities", "normal") or 1) * 2), 3 } }
668+
return { vars = { "" .. ((Cryptid.safe_get(G.GAME, "probabilities", "normal") or 1) * 2), 3 } }
669669
end,
670670
set_blind = function(self, reset, silent)
671671
if not reset then
672672
G.GAME.blind.tornado_guarantee = pseudorandom(pseudoseed("tornado"), 1, G.GAME.round_resets.hands)
673673
end
674674
end,
675675
in_pool = function()
676-
return #advanced_find_joker("Oops! All 6s", nil, nil, { "eternal" }, nil) == 0
676+
return #Cryptid.advanced_find_joker("Oops! All 6s", nil, nil, { "eternal" }, nil) == 0
677677
end,
678678
collection_loc_vars = function(self)
679-
return { vars = { "" .. ((safe_get(G.GAME, "probabilities", "normal") or 1) * 2), 3 } }
679+
return { vars = { "" .. ((Cryptid.safe_get(G.GAME, "probabilities", "normal") or 1) * 2), 3 } }
680680
end,
681681
debuff_hand = function(self, cards, hand, handname, check)
682682
if

items/challenge.lua

Lines changed: 61 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ local sticker_sheet = {
1616
modifiers = {},
1717
},
1818
restrictions = {
19-
banned_cards = {},
19+
banned_cards = {
20+
{ id = "c_cry_lock" }
21+
},
2022
banned_other = {},
2123
},
2224
deck = {
@@ -35,7 +37,9 @@ local sticker_sheet_plus = {
3537
modifiers = {},
3638
},
3739
restrictions = {
38-
banned_cards = {},
40+
banned_cards = {
41+
{ id = "c_cry_lock" }
42+
},
3943
banned_other = {},
4044
},
4145
deck = {
@@ -74,6 +78,8 @@ local ballin = {
7478
{ id = "c_familiar" },
7579
{ id = "c_grim" },
7680
{ id = "c_incantation" },
81+
{ id = "c_cry_eclipse" },
82+
{ id = "c_cry_class" },
7783
},
7884
banned_other = {},
7985
},
@@ -122,6 +128,10 @@ local rush_hour_ii = {
122128
{ id = "j_diet_cola" },
123129
{ id = "v_directors_cut" },
124130
{ id = "v_retcon" },
131+
{ id = "j_cry_pickle" },
132+
{ id = "v_cry_copies" },
133+
{ id = "v_cry_tag_printer" },
134+
{ id = "v_cry_clone_machine" },
125135
},
126136
banned_other = {},
127137
},
@@ -212,6 +222,10 @@ local rush_hour_iii = {
212222
{ id = "j_diet_cola" },
213223
{ id = "v_directors_cut" },
214224
{ id = "v_retcon" },
225+
{ id = "j_cry_pickle" },
226+
{ id = "v_cry_copies" },
227+
{ id = "v_cry_tag_printer" },
228+
{ id = "v_cry_clone_machine" },
215229
},
216230
banned_other = {},
217231
},
@@ -241,6 +255,10 @@ local boss_rush = {
241255
{ id = "j_diet_cola" },
242256
{ id = "v_directors_cut" },
243257
{ id = "v_retcon" },
258+
{ id = "j_cry_pickle" },
259+
{ id = "v_cry_copies" },
260+
{ id = "v_cry_tag_printer" },
261+
{ id = "v_cry_clone_machine" },
244262
},
245263
banned_other = {},
246264
},
@@ -264,8 +282,13 @@ local rng = {
264282
{ id = "tag_uncommon" },
265283
{ id = "tag_rare" },
266284
{ id = "tag_top_up" },
285+
{ id = "tag_cry_epic" },
286+
},
287+
banned_cards = {
288+
{ id = "j_cry_equilib" },
289+
{ id = "c_cry_delete" },
290+
{ id = "p_cry_meme_1", ids = { "p_cry_meme_1", "p_cry_meme_two", "p_cry_meme_three" } },
267291
},
268-
banned_cards = {},
269292
banned_other = {},
270293
},
271294
}
@@ -311,15 +334,22 @@ local onlycard = {
311334
{ id = "tag_meteor" },
312335
{ id = "tag_buffoon" },
313336
{ id = "tag_ethereal" },
337+
{ id = "tag_cry_bundle" },
338+
{ id = "tag_cry_loss" },
339+
{ id = "tag_cry_gambler" },
340+
{ id = "tag_cry_empowered" },
341+
{ id = "tag_cry_console" },
314342
},
315343
banned_cards = {
316344
{ id = "j_marble" },
317345
{ id = "j_dna" },
318346
{ id = "j_certificate" },
347+
{ id = "j_cry_multjoker" },
319348
{ id = "c_familiar" },
320349
{ id = "c_grim" },
321350
{ id = "c_incantation" },
322351
{ id = "c_cryptid" },
352+
{ id = "c_cry_replica" },
323353
{
324354
id = "p_celestial_normal_1",
325355
ids = {
@@ -364,6 +394,19 @@ local onlycard = {
364394
"p_buffoon_mega_1",
365395
},
366396
},
397+
{
398+
id = "p_cry_meme_1",
399+
ids = {
400+
"p_cry_meme_1",
401+
"p_cry_meme_two",
402+
"p_cry_meme_three",
403+
},
404+
},
405+
{ id = "p_cry_empowered" },
406+
{
407+
id = "p_cry_code_normal_1",
408+
ids = { "p_cry_code_normal_1", "p_cry_code_normal_2", "p_cry_code_jumbo_1", "p_cry_code_mega_1" },
409+
}
367410
},
368411
banned_other = {
369412
{ id = "bl_house", type = "blind" },
@@ -427,11 +470,25 @@ local joker_poker = {
427470
{ id = "j_yorick" },
428471
{ id = "j_perkeo" },
429472
{ id = "j_constellation" },
473+
{ id = "j_cry_booster" },
474+
{ id = "j_cry_wheelhope" },
475+
{ id = "j_cry_hunger" },
476+
{ id = "j_cry_sacrifice" },
477+
{ id = "j_cry_doodlem" },
478+
{ id = "j_cry_multjoker" },
479+
{ id = "j_cry_stella_mortis" },
480+
{ id = "j_cry_crustulum" },
481+
{ id = "j_cry_cut" },
482+
{ id = "j_cry_CodeJoker" },
483+
{ id = "j_cry_copypaste" },
484+
{ id = "j_cry_blender" },
485+
{ id = "j_cry_python" }
430486
},
431487
banned_other = {
432488
{ id = "bl_hook", type = "blind" },
433489
{ id = "bl_arm", type = "blind" },
434490
{ id = "bl_water", type = "blind" },
491+
{ id = "bl_cry_oldmanacle", type = "blind" },
435492
},
436493
},
437494
}
@@ -453,82 +510,6 @@ function Game:start_run(args)
453510
end
454511
--Add banned cards when specific features/mods are enabled here
455512
--TODO other mods
456-
if Cryptid.enabled["Blinds"] then
457-
joker_poker.restrictions.banned_other[#joker_poker.restrictions.banned_other + 1] =
458-
{ id = "bl_cry_oldmanacle", type = "blind" }
459-
end
460-
if Cryptid.enabled["Tags"] then
461-
onlycard.restrictions.banned_tags[#onlycard.restrictions.banned_tags + 1] = { id = "tag_cry_bundle" }
462-
onlycard.restrictions.banned_tags[#onlycard.restrictions.banned_tags + 1] = { id = "tag_cry_loss" }
463-
onlycard.restrictions.banned_tags[#onlycard.restrictions.banned_tags + 1] = { id = "tag_cry_gambler" }
464-
onlycard.restrictions.banned_tags[#onlycard.restrictions.banned_tags + 1] = { id = "tag_cry_empowered" }
465-
onlycard.restrictions.banned_cards[#onlycard.restrictions.banned_cards + 1] = { id = "p_cry_empowered" }
466-
if Cryptid.enabled["Epic Jokers"] then
467-
rng.restrictions.banned_tags[#rng.restrictions.banned_tags + 1] = { id = "tag_cry_epic" }
468-
end
469-
end
470-
if Cryptid.enabled["Misc."] then
471-
ballin.restrictions.banned_cards[#ballin.restrictions.banned_cards + 1] = { id = "c_cry_eclipse" }
472-
rng.restrictions.banned_cards[#rng.restrictions.banned_cards + 1] =
473-
{ id = "p_cry_meme_1", ids = { "p_cry_meme_1", "p_cry_meme_two", "p_cry_meme_three" } }
474-
onlycard.restrictions.banned_cards[#onlycard.restrictions.banned_cards + 1] =
475-
{ id = "p_cry_meme_1", ids = { "p_cry_meme_1", "p_cry_meme_two", "p_cry_meme_three" } }
476-
end
477-
if Cryptid.enabled["Misc. Jokers"] then
478-
rush_hour_ii.restrictions.banned_cards[#rush_hour_ii.restrictions.banned_cards + 1] = { id = "j_cry_pickle" }
479-
rush_hour_iii.restrictions.banned_cards[#rush_hour_iii.restrictions.banned_cards + 1] = { id = "j_cry_pickle" }
480-
boss_rush.restrictions.banned_cards[#boss_rush.restrictions.banned_cards + 1] = { id = "j_cry_pickle" }
481-
joker_poker.restrictions.banned_cards[#joker_poker.restrictions.banned_cards + 1] = { id = "j_cry_booster" }
482-
joker_poker.restrictions.banned_cards[#joker_poker.restrictions.banned_cards + 1] = { id = "j_cry_wheelhope" }
483-
joker_poker.restrictions.banned_cards[#joker_poker.restrictions.banned_cards + 1] = { id = "j_cry_hunger" }
484-
end
485-
if Cryptid.enabled["M Jokers"] then
486-
joker_poker.restrictions.banned_cards[#joker_poker.restrictions.banned_cards + 1] = { id = "j_cry_sacrifice" }
487-
if Cryptid.enabled["Epic Jokers"] then
488-
joker_poker.restrictions.banned_cards[#joker_poker.restrictions.banned_cards + 1] = { id = "j_cry_doodlem" }
489-
end
490-
end
491-
if Cryptid.enabled["Epic Jokers"] then
492-
onlycard.restrictions.banned_cards[#onlycard.restrictions.banned_cards + 1] = { id = "j_cry_multjoker" }
493-
joker_poker.restrictions.banned_cards[#joker_poker.restrictions.banned_cards + 1] = { id = "j_cry_multjoker" }
494-
end
495-
if Cryptid.enabled["Exotic Jokers"] then
496-
rng.restrictions.banned_cards[#rng.restrictions.banned_cards + 1] = { id = "j_cry_equilib" }
497-
joker_poker.restrictions.banned_cards[#joker_poker.restrictions.banned_cards + 1] = { id = "j_cry_stella_mortis" }
498-
joker_poker.restrictions.banned_cards[#joker_poker.restrictions.banned_cards + 1] = { id = "j_cry_crustulum" }
499-
end
500-
if Cryptid.enabled["Code Cards"] then
501-
ballin.restrictions.banned_cards[#ballin.restrictions.banned_cards + 1] = { id = "c_cry_class" }
502-
rng.restrictions.banned_cards[#rng.restrictions.banned_cards + 1] = { id = "c_cry_delete" }
503-
onlycard.restrictions.banned_tags[#onlycard.restrictions.banned_tags + 1] = { id = "tag_cry_console" }
504-
onlycard.restrictions.banned_cards[#onlycard.restrictions.banned_cards + 1] = {
505-
id = "p_cry_code_normal_1",
506-
ids = { "p_cry_code_normal_1", "p_cry_code_normal_2", "p_cry_code_jumbo_1", "p_cry_code_mega_1" },
507-
}
508-
joker_poker.restrictions.banned_cards[#joker_poker.restrictions.banned_cards + 1] = { id = "j_cry_cut" }
509-
joker_poker.restrictions.banned_cards[#joker_poker.restrictions.banned_cards + 1] = { id = "j_cry_CodeJoker" }
510-
joker_poker.restrictions.banned_cards[#joker_poker.restrictions.banned_cards + 1] = { id = "j_cry_copypaste" }
511-
joker_poker.restrictions.banned_cards[#joker_poker.restrictions.banned_cards + 1] = { id = "j_cry_blender" }
512-
joker_poker.restrictions.banned_cards[#joker_poker.restrictions.banned_cards + 1] = { id = "j_cry_python" }
513-
end
514-
if Cryptid.enabled["Spectrals"] then
515-
sticker_sheet.restrictions.banned_cards[#sticker_sheet.restrictions.banned_cards + 1] = { id = "c_cry_lock" }
516-
sticker_sheet_plus.restrictions.banned_cards[#sticker_sheet_plus.restrictions.banned_cards + 1] =
517-
{ id = "c_cry_lock" }
518-
onlycard.restrictions.banned_cards[#onlycard.restrictions.banned_cards + 1] = { id = "c_cry_replica" }
519-
end
520-
if Cryptid.enabled["Vouchers"] then
521-
rush_hour_ii.restrictions.banned_cards[#rush_hour_ii.restrictions.banned_cards + 1] = { id = "v_cry_copies" }
522-
rush_hour_iii.restrictions.banned_cards[#rush_hour_iii.restrictions.banned_cards + 1] = { id = "v_cry_copies" }
523-
boss_rush.restrictions.banned_cards[#boss_rush.restrictions.banned_cards + 1] = { id = "v_cry_copies" }
524-
rush_hour_ii.restrictions.banned_cards[#rush_hour_ii.restrictions.banned_cards + 1] = { id = "v_cry_tag_printer" }
525-
rush_hour_iii.restrictions.banned_cards[#rush_hour_iii.restrictions.banned_cards + 1] = { id = "v_cry_tag_printer" }
526-
boss_rush.restrictions.banned_cards[#boss_rush.restrictions.banned_cards + 1] = { id = "v_cry_tag_printer" }
527-
rush_hour_ii.restrictions.banned_cards[#rush_hour_ii.restrictions.banned_cards + 1] = { id = "v_cry_clone_machine" }
528-
rush_hour_iii.restrictions.banned_cards[#rush_hour_iii.restrictions.banned_cards + 1] =
529-
{ id = "v_cry_clone_machine" }
530-
boss_rush.restrictions.banned_cards[#boss_rush.restrictions.banned_cards + 1] = { id = "v_cry_clone_machine" }
531-
end
532513
if (SMODS.Mods["jen"] or {}).can_load then
533514
ballin.restrictions.banned_cards[#ballin.restrictions.banned_cards + 1] = { id = "c_jen_chance" }
534515
ballin.restrictions.banned_cards[#ballin.restrictions.banned_cards + 1] = { id = "c_jen_token_tag_cry_bundle" }
@@ -581,21 +562,7 @@ if (SMODS.Mods["jen"] or {}).can_load then
581562
onlycard.restrictions.banned_cards[#onlycard.restrictions.banned_cards + 1] = { id = "c_jen_cryptid_ex" }
582563
end
583564
--end of banned cards
584-
local challenges = { sticker_sheet, sticker_sheet_plus, onlycard }
585-
if Cryptid.enabled["Misc. Jokers"] then
586-
challenges[#challenges + 1] = ballin
587-
challenges[#challenges + 1] = boss_rush
588-
challenges[#challenges + 1] = rng
589-
challenges[#challenges + 1] = dagger_war
590-
end
591-
if Cryptid.enabled["Blinds"] and Cryptid.enabled["Timer Mechanics"] then
592-
challenges[#challenges + 1] = rush_hour
593-
challenges[#challenges + 1] = rush_hour_ii
594-
challenges[#challenges + 1] = rush_hour_iii
595-
end
596-
if Cryptid.enabled["Misc. Decks"] then --yoinking vfd code here
597-
challenges[#challenges + 1] = joker_poker
598-
end
565+
local challenges = { sticker_sheet, sticker_sheet_plus, onlycard, ballin, boss_rush, rng, dagger_war, rush_hour, rush_hour_ii, rush_hour_iii, joker_poker }
599566

600567
for k, v in pairs(G.P_CENTERS) do
601568
if v.set == "Joker" then

0 commit comments

Comments
 (0)