Skip to content

Commit 2e12dea

Browse files
Wip: Switch to smods probability api
e
1 parent e62cbfc commit 2e12dea

File tree

11 files changed

+76
-136
lines changed

11 files changed

+76
-136
lines changed

items/blind.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ local tornado = {
10491049
order = 94,
10501050
boss_colour = HEX("3dd9ca"),
10511051
loc_vars = function(self)
1052-
return { vars = { "" .. ((Cryptid.safe_get(G.GAME, "probabilities", "normal") or 1) * 2), 3 } }
1052+
return { vars = { SMODS.get_probability_vars(self, 2, 3, "Turquoise Tornado") } }
10531053
end,
10541054
set_blind = function(self, reset, silent)
10551055
if not reset then
@@ -1060,12 +1060,12 @@ local tornado = {
10601060
return #Cryptid.advanced_find_joker("Oops! All 6s", nil, nil, { "eternal" }, nil) == 0
10611061
end,
10621062
collection_loc_vars = function(self)
1063-
return { vars = { "" .. ((Cryptid.safe_get(G.GAME, "probabilities", "normal") or 1) * 2), 3 } }
1063+
return { vars = { SMODS.get_probability_vars(self, 2, 3, "Turquoise Tornado") } }
10641064
end,
10651065
debuff_hand = function(self, cards, hand, handname, check)
10661066
if
10671067
not check
1068-
and (pseudorandom(pseudoseed("tornado")) < ((G.GAME.probabilities.normal * 2) / 3))
1068+
and SMODS.pseudorandom_probability(self, "tornado", 2, 3, "Turquoise Tornado")
10691069
and not G.GAME.blind.disabled
10701070
then
10711071
--check for guarantee
@@ -1546,7 +1546,7 @@ local obsidian_orb = {
15461546
if area == G.hand then
15471547
if
15481548
s.name == "The Wheel"
1549-
and pseudorandom(pseudoseed("ObsidianOrb")) < G.GAME.probabilities.normal / 7
1549+
and SMODS.pseudorandom_probability(self, "ObsidianOrb", 1, 7, "Obsidian Orb")
15501550
then
15511551
return true
15521552
end

items/epic.lua

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,19 @@ local googol_play = {
211211
atlas = "atlasepic",
212212
soul_pos = { x = 10, y = 0, extra = { x = 4, y = 0 } },
213213
loc_vars = function(self, info_queue, card)
214+
local aaa, bbb = SMODS.get_probability_vars(card, 1, card.ability.extra.odds, "Googol Play Card")
214215
return {
215216
vars = {
216-
cry_prob(card.ability.cry_prob, card.ability.extra.odds, card.ability.cry_rigged),
217-
card.ability.extra.odds,
217+
aaa,
218+
bbb,
218219
number_format(card.ability.extra.Xmult),
219220
},
220221
}
221222
end,
222223
calculate = function(self, card, context)
223224
if
224225
context.joker_main
225-
and pseudorandom("cry_googol_play")
226-
< cry_prob(card.ability.cry_prob, card.ability.extra.odds, card.ability.cry_rigged) / card.ability.extra.odds
226+
and SMODS.pseudorandom_probability(card, "cry_googol_play", 1, card.ability.extra.odds, "Googol Play Card")
227227
then
228228
return {
229229
message = localize({
@@ -877,8 +877,7 @@ local boredom = {
877877
cost = 14,
878878
blueprint_compat = true,
879879
loc_vars = function(self, info_queue, card)
880-
local num, denom =
881-
SMODS.get_probability_vars(card, 1, card and card.ability.extra.odds or self.config.extra.odds)
880+
local num, denom = SMODS.get_probability_vars(card, 1, card.ability.extra.odds, "Boredom")
882881

883882
return {
884883
vars = {
@@ -894,14 +893,7 @@ local boredom = {
894893
and not context.retrigger_joker
895894
and not (context.other_card.ability and context.other_card.ability.name == "cry-Boredom")
896895
then
897-
if
898-
SMODS.pseudorandom_probability(
899-
card,
900-
"cry_boredom_joker",
901-
1,
902-
card and card.ability.extra.odds or self.config.extra.odds
903-
)
904-
then
896+
if SMODS.pseudorandom_probability(card, "cry_boredom_joker", 1, card.ability.extra.odds, "Boredom") then
905897
return {
906898
message = localize("k_again_ex"),
907899
repetitions = 1,
@@ -914,12 +906,7 @@ local boredom = {
914906
if
915907
context.repetition
916908
and context.cardarea == G.play
917-
and SMODS.pseudorandom_probability(
918-
card,
919-
"cry_boredom_joker",
920-
1,
921-
card and card.ability.extra.odds or self.config.extra.odds
922-
)
909+
and SMODS.pseudorandom_probability(card, "cry_boredom_joker", 1, card.ability.extra.odds, "Boredom")
923910
then
924911
return {
925912
message = localize("k_again_ex"),
@@ -1498,12 +1485,11 @@ local bonusjoker = {
14981485
enhancement_gate = "m_bonus",
14991486
loc_vars = function(self, info_queue, card)
15001487
info_queue[#info_queue + 1] = G.P_CENTERS.m_bonus
1501-
local num, denom =
1502-
SMODS.get_probability_vars(card, 1, card and card.ability.extra.odds or self.config.extra.odds)
1488+
local aaa, bbb = SMODS.get_probability_vars(card, 1, card.ability.extra.odds, "Bonus Joker")
15031489
return {
15041490
vars = {
1505-
num,
1506-
denom,
1491+
aaa,
1492+
bbb,
15071493
number_format(math.min(card.ability.extra.add, card.ability.immutable.max)),
15081494
},
15091495
}
@@ -1513,12 +1499,7 @@ local bonusjoker = {
15131499
if context.individual and context.cardarea == G.play then
15141500
if SMODS.has_enhancement(context.other_card, "m_bonus") then
15151501
if
1516-
SMODS.pseudorandom_probability(
1517-
card,
1518-
"bonusjoker",
1519-
1,
1520-
card and card.ability.extra.odds or self.config.extra.odds
1521-
)
1502+
SMODS.pseudorandom_probability(card, "bonusjoker", 1, card.ability.extra.odds, "Bonus Joker")
15221503
and card.ability.immutable.check < 2
15231504
and not context.retrigger_joker
15241505
then
@@ -1621,13 +1602,8 @@ local multjoker = {
16211602
loc_vars = function(self, info_queue, card)
16221603
info_queue[#info_queue + 1] = G.P_CENTERS.m_mult
16231604
info_queue[#info_queue + 1] = G.P_CENTERS.c_cryptid
1624-
local num, denom =
1625-
SMODS.get_probability_vars(card, 1, card and card.ability.extra.odds or self.config.extra.odds)
16261605
return {
1627-
vars = {
1628-
num,
1629-
denom,
1630-
},
1606+
vars = { SMODS.get_probability_vars(card, 1, card.ability.extra.odds, "Mult Joker") },
16311607
}
16321608
end,
16331609
atlas = "atlasepic",
@@ -1637,14 +1613,7 @@ local multjoker = {
16371613
SMODS.has_enhancement(context.other_card, "m_mult")
16381614
and #G.consumeables.cards + G.GAME.consumeable_buffer < G.consumeables.config.card_limit
16391615
then
1640-
if
1641-
SMODS.pseudorandom_probability(
1642-
card,
1643-
"multjoker",
1644-
1,
1645-
card and card.ability.extra.odds or self.config.extra.odds
1646-
)
1647-
then
1616+
if SMODS.pseudorandom_probability(card, "multjoker", 1, card.ability.extra.odds, "Mult Joker") then
16481617
G.GAME.consumeable_buffer = G.GAME.consumeable_buffer + 1
16491618
G.E_MANAGER:add_event(Event({
16501619
func = function()

items/m.lua

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,11 @@ local notebook = {
538538
demicoloncompat = true,
539539
loc_vars = function(self, info_queue, card)
540540
info_queue[#info_queue + 1] = G.P_CENTERS.j_jolly
541+
local aaa, bbb = SMODS.get_probability_vars(card, 1, card.ability.extra.odds, "Notebook")
541542
return {
542543
vars = {
543-
cry_prob(card.ability.cry_prob, card.ability.extra.odds, card.ability.cry_rigged),
544-
card.ability.extra.odds,
544+
aaa,
545+
bbb,
545546
number_format(card.ability.immutable.slots),
546547
number_format(card.ability.extra.active),
547548
number_format(card.ability.extra.jollies),
@@ -563,11 +564,8 @@ local notebook = {
563564
jollycount = jollycount + 1
564565
end
565566
end
566-
if
567-
to_number(jollycount) >= to_number(card.ability.extra.jollies) --if there are 5 or more jolly jokers
568-
or pseudorandom("cry_notebook")
569-
< cry_prob(card.ability.cry_prob, card.ability.extra.odds, card.ability.cry_rigged) / card.ability.extra.odds
570-
then
567+
local aaa = to_number(jollycount) >= to_number(card.ability.extra.jollies) and 1e20 or 1
568+
if SMODS.pseudorandom_probability(card, "cry_notebook", 1 * aaa, card.ability.extra.odds, "Notebook") then
571569
card.ability.immutable.slots = to_number(
572570
math.min(
573571
card.ability.immutable.max_slots,
@@ -832,20 +830,13 @@ local scrabble = {
832830
info_queue[#info_queue + 1] = G.P_CENTERS.e_cry_m
833831
end
834832
return {
835-
vars = {
836-
cry_prob(card.ability.cry_prob, card.ability.extra.odds, card.ability.cry_rigged),
837-
card.ability.extra.odds,
838-
},
833+
vars = { SMODS.get_probability_vars(card, 1, card.ability.extra.odds, "Scrabble Tile") },
839834
}
840835
end,
841836
calculate = function(self, card, context)
842837
if context.cardarea == G.jokers and context.before and not context.retrigger_joker then
843838
local check = false
844-
if
845-
pseudorandom("scrabbleother")
846-
< cry_prob(card.ability.cry_prob, card.ability.extra.odds, card.ability.cry_rigged)
847-
/ card.ability.extra.odds
848-
then
839+
if SMODS.pseudorandom_probability(card, "scrabbleother", 1, card.ability.extra.odds, "Scrabble Tile") then
849840
check = true
850841
local card = create_card("Joker", G.jokers, nil, 0.9, nil, nil, nil, "scrabbletile")
851842
if Cryptid.enabled("e_cry_m") == true then

items/misc_joker.lua

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7618,11 +7618,8 @@ local wheelhope = {
76187618
Xmult_mod = lenient_bignum(card.ability.extra.x_mult),
76197619
}
76207620
end
7621-
if context.consumeable then
7622-
if
7623-
context.consumeable.ability.name == "The Wheel of Fortune"
7624-
and not context.consumeable.cry_wheel_success
7625-
then
7621+
if context.pseudorandom_result and not context.result then
7622+
if context.identifier and context.identifier == "wheel_of_fortune" then
76267623
card.ability.extra.x_mult = lenient_bignum(to_big(card.ability.extra.x_mult) + card.ability.extra.extra)
76277624
card_eval_status_text(card, "extra", nil, nil, nil, {
76287625
message = localize({
@@ -7718,8 +7715,7 @@ local oldblueprint = {
77187715
end
77197716
return {
77207717
vars = {
7721-
cry_prob(card.ability.cry_prob, card.ability.extra.odds, card.ability.cry_rigged),
7722-
card.ability.extra.odds,
7718+
SMODS.get_probability_vars(card, 1, card.ability.extra.odds, "Old Blueprint"),
77237719
},
77247720
main_end = main_end,
77257721
}
@@ -7734,7 +7730,7 @@ local oldblueprint = {
77347730
and not context.repetition
77357731
and not context.retrigger_joker
77367732
then
7737-
if pseudorandom("oldblueprint") < G.GAME.probabilities.normal / card.ability.extra.odds then
7733+
if SMODS.pseudorandom_probability(card, "oldblueprint", 1, card.ability.extra.odds, "Old Blueprint") then
77387734
G.E_MANAGER:add_event(Event({
77397735
card:start_dissolve(),
77407736
}))
@@ -9503,7 +9499,7 @@ local digitalhallucinations = {
95039499
config = { odds = 2 },
95049500
loc_vars = function(self, info_queue, card)
95059501
return {
9506-
vars = { cry_prob(card.ability.cry_prob, card.ability.odds, card.ability.cry_rigged), card.ability.odds },
9502+
vars = { SMODS.get_probability_vars(card, 1, card.ability.odds, "Digital Hallucinations") },
95079503
}
95089504
end,
95099505
atlas = "atlasthree",
@@ -9513,13 +9509,9 @@ local digitalhallucinations = {
95139509
calculate = function(self, card, context)
95149510
-- you know, i was totally ready to do something smart here but vanilla hardcodes this stuff, so i will too
95159511
-- some cards need to be handled slightly differently anyway, adding mod support can't really be automatic in some circumstances
9516-
95179512
if
95189513
context.open_booster
9519-
and (
9520-
pseudorandom("digi")
9521-
< cry_prob(card.ability.cry_prob, card.ability.odds, card.ability.cry_rigged) / card.ability.odds
9522-
)
9514+
and (SMODS.pseudorandom_probability(card, "digi", 1, card.ability.odds, "Digital Hallucinations"))
95239515
then
95249516
local boosty = context.card
95259517
-- finally mod compat?
@@ -10221,6 +10213,7 @@ local brokenhome = { -- X11.4 Mult, 1 in 4 chance to self-destruct at end of rou
1022110213
rarity = 3,
1022210214
cost = 8,
1022310215
order = 139,
10216+
blueprint_compat = true,
1022410217
eternal_compat = false,
1022510218
demicoloncompat = true,
1022610219
config = { extra = { Xmult = 11.4, odds = 4 } },
@@ -10233,7 +10226,12 @@ local brokenhome = { -- X11.4 Mult, 1 in 4 chance to self-destruct at end of rou
1023310226
},
1023410227
},
1023510228
loc_vars = function(self, info_queue, card) -- the humble cavendish example mod:
10236-
return { vars = { card.ability.extra.Xmult, (G.GAME.probabilities.normal or 1), card.ability.extra.odds } }
10229+
return {
10230+
vars = {
10231+
card.ability.extra.Xmult,
10232+
SMODS.get_probability_vars(card, 1, card.ability.extra.odds, "Broken Home"),
10233+
},
10234+
}
1023710235
end,
1023810236
calculate = function(self, card, context)
1023910237
if context.joker_main then
@@ -10243,7 +10241,7 @@ local brokenhome = { -- X11.4 Mult, 1 in 4 chance to self-destruct at end of rou
1024310241
}
1024410242
end
1024510243
if context.end_of_round and context.game_over == false and not context.repetition and not context.blueprint then
10246-
if pseudorandom("brokenhome") < G.GAME.probabilities.normal / card.ability.extra.odds then
10244+
if SMODS.pseudorandom_probability(card, "brokenhome", 1, card.ability.extra.odds, "Broken Home") then
1024710245
G.E_MANAGER:add_event(Event({
1024810246
func = function()
1024910247
play_sound("tarot1")
@@ -10277,7 +10275,7 @@ local brokenhome = { -- X11.4 Mult, 1 in 4 chance to self-destruct at end of rou
1027710275
end
1027810276
end
1027910277
if context.forcetrigger then
10280-
if pseudorandom("brokenhome") < G.GAME.probabilities.normal / card.ability.extra.odds then
10278+
if SMODS.pseudorandom_probability(card, "brokenhome", 1, card.ability.extra.odds, "Broken Home") then
1028110279
G.E_MANAGER:add_event(Event({
1028210280
func = function()
1028310281
play_sound("tarot1")

items/planet.lua

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,9 @@ local planetlua = {
313313
atlas = "atlasnotjokers",
314314
order = 101,
315315
loc_vars = function(self, info_queue, card)
316-
local num, denom =
317-
SMODS.get_probability_vars(card, 1, card and card.ability.extra.odds or self.config.extra.odds)
318316
return {
319317
vars = {
320-
num,
321-
denom,
318+
SMODS.get_probability_vars(card, 1, card.ability.extra.odds, "Planet.lua"),
322319
},
323320
}
324321
end,
@@ -327,14 +324,7 @@ local planetlua = {
327324
end,
328325
use = function(self, card, area, copier)
329326
local used_consumable = copier or card
330-
if
331-
SMODS.pseudorandom_probability(
332-
card,
333-
"planetlua",
334-
1,
335-
card and card.ability.extra.odds or self.config.extra.odds
336-
)
337-
then --Code "borrowed" from black hole
327+
if SMODS.pseudorandom_probability(card, "planetlua", 1, card.ability.extra.odds, "Planet.lua") then --Code "borrowed" from black hole
338328
update_hand_text(
339329
{ sound = "button", volume = 0.7, pitch = 0.8, delay = 0.3 },
340330
{ handname = localize("k_all_hands"), chips = "...", mult = "...", level = "" }
@@ -478,12 +468,7 @@ local planetlua = {
478468
for i = 1, number do
479469
quota = quota
480470
+ (
481-
SMODS.pseudorandom_probability(
482-
card,
483-
"planetlua",
484-
1,
485-
card and card.ability.extra.odds or self.config.extra.odds
486-
)
471+
SMODS.pseudorandom_probability(card, "planetlua", 1, card.ability.extra.odds, "Planet.lua")
487472
and 1
488473
or 0
489474
)
@@ -588,9 +573,10 @@ local planetlua = {
588573
and (
589574
SMODS.pseudorandom_probability(
590575
card,
591-
"nstar", --this is how it was before i didnt make it use the same seed
576+
"mstar", --this is how it was before i didnt make it use the same seed
592577
1,
593-
card and card.ability.extra.odds or self.config.extra.odds
578+
card.ability.extra.odds,
579+
"Planet.lua"
594580
)
595581
)
596582
then

0 commit comments

Comments
 (0)