Skip to content

Commit 86bb740

Browse files
committed
update to new probability api
1 parent 8371c94 commit 86bb740

File tree

9 files changed

+163
-341
lines changed

9 files changed

+163
-341
lines changed

Cryptid.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"version": "0.5.10",
1313
"dependencies": [
1414
"Talisman (>=2.2.0a)",
15-
"Steamodded (>=1.0.0~BETA-0614a)"
15+
"Steamodded (>=1.0.0~BETA-0711a)"
1616
],
1717
"conflicts": [
1818
"Saturn",

items/code.lua

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4889,14 +4889,11 @@ local copypaste = {
48894889
cost = 14,
48904890
blueprint_compat = true,
48914891
loc_vars = function(self, info_queue, card)
4892+
local num, denom = SMODS.get_probability_vars(card, 1, card and card.ability.extra.odds or 2)
48924893
return {
48934894
vars = {
4894-
card and cry_prob(
4895-
math.min(card.ability.extra.odds / 2, card.ability.cry_prob or 1),
4896-
card.ability.extra.odds,
4897-
card.ability.cry_rigged
4898-
) or 1,
4899-
card and card.ability.extra.odds or 2,
4895+
num,
4896+
denom,
49004897
}, -- this effectively prevents a copypaste from ever initially misprinting at above 50% odds. still allows rigging/oops
49014898
key = Cryptid.gameset_loc(self, { madness = "madness", exp_modest = "modest" }),
49024899
}
@@ -4936,13 +4933,12 @@ local copypaste = {
49364933
then
49374934
if #G.consumeables.cards + G.GAME.consumeable_buffer < G.consumeables.config.card_limit then
49384935
if
4939-
pseudorandom("cry_copypaste_joker")
4940-
< cry_prob(
4941-
math.min(card.ability.extra.odds / 2, card.ability.cry_prob),
4942-
card.ability.extra.odds,
4943-
card.ability.cry_rigged
4944-
)
4945-
/ card.ability.extra.odds
4936+
SMODS.pseudorandom_probability(
4937+
card,
4938+
"cry_copypaste_joker",
4939+
1,
4940+
card and card.ability.extra.odds or 2
4941+
)
49464942
then
49474943
G.E_MANAGER:add_event(Event({
49484944
func = function()

items/epic.lua

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,10 +1488,12 @@ local bonusjoker = {
14881488
enhancement_gate = "m_bonus",
14891489
loc_vars = function(self, info_queue, card)
14901490
info_queue[#info_queue + 1] = G.P_CENTERS.m_bonus
1491+
local num, denom =
1492+
SMODS.get_probability_vars(card, 1, card and card.ability.extra.odds or self.config.extra.odds)
14911493
return {
14921494
vars = {
1493-
cry_prob(card.ability.cry_prob, card.ability.extra.odds, card.ability.cry_rigged),
1494-
card.ability.extra.odds,
1495+
num,
1496+
denom,
14951497
number_format(math.min(card.ability.extra.add, card.ability.immutable.max)),
14961498
},
14971499
}
@@ -1501,8 +1503,12 @@ local bonusjoker = {
15011503
if context.individual and context.cardarea == G.play then
15021504
if SMODS.has_enhancement(context.other_card, "m_bonus") then
15031505
if
1504-
pseudorandom("bonusjoker")
1505-
< cry_prob(card.ability.cry_prob, card.ability.extra.odds, card.ability.cry_rigged) / card.ability.extra.odds
1506+
SMODS.pseudorandom_probability(
1507+
card,
1508+
"bonusjoker",
1509+
1,
1510+
card and card.ability.extra.odds or self.config.extra.odds
1511+
)
15061512
and card.ability.immutable.check < 2
15071513
and not context.retrigger_joker
15081514
then
@@ -1605,10 +1611,12 @@ local multjoker = {
16051611
loc_vars = function(self, info_queue, card)
16061612
info_queue[#info_queue + 1] = G.P_CENTERS.m_mult
16071613
info_queue[#info_queue + 1] = G.P_CENTERS.c_cryptid
1614+
local num, denom =
1615+
SMODS.get_probability_vars(card, 1, card and card.ability.extra.odds or self.config.extra.odds)
16081616
return {
16091617
vars = {
1610-
cry_prob(card.ability.cry_prob, card.ability.extra.odds, card.ability.cry_rigged),
1611-
card.ability.extra.odds,
1618+
num,
1619+
denom
16121620
},
16131621
}
16141622
end,
@@ -1620,9 +1628,12 @@ local multjoker = {
16201628
and #G.consumeables.cards + G.GAME.consumeable_buffer < G.consumeables.config.card_limit
16211629
then
16221630
if
1623-
pseudorandom("multjoker")
1624-
< cry_prob(card.ability.cry_prob, card.ability.extra.odds, card.ability.cry_rigged)
1625-
/ card.ability.extra.odds
1631+
SMODS.pseudorandom_probability(
1632+
card,
1633+
"multjoker",
1634+
1,
1635+
card and card.ability.extra.odds or self.config.extra.odds
1636+
)
16261637
then
16271638
G.GAME.consumeable_buffer = G.GAME.consumeable_buffer + 1
16281639
G.E_MANAGER:add_event(Event({

items/misc.lua

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,23 @@ local abstract = {
210210
config = { extra = { Emult = 1.15, odds_after_play = 2, odds_after_round = 4, marked = false, survive = false } },
211211
--#1# emult, #2# in #3# chance card is destroyed after play, #4# in #5$ chance card is destroyed at end of round (even discarded or in deck)
212212
loc_vars = function(self, info_queue, card)
213+
local num1, denom1 = SMODS.get_probability_vars(
214+
card,
215+
1,
216+
card and card.ability.extra.odds_after_play or self.config.extra.odds_after_play
217+
)
218+
local num2, denom2 = SMODS.get_probability_vars(
219+
card,
220+
1,
221+
card and card.ability.extra.odds_after_round or self.config.extra.odds_after_round
222+
)
213223
return {
214224
vars = {
215225
card.ability.extra.Emult,
216-
cry_prob(card.ability.cry_prob, card.ability.extra.odds_after_play, card.ability.cry_rigged),
217-
card.ability.extra.odds_after_play,
218-
cry_prob(card.ability.cry_prob, card.ability.extra.odds_after_round, card.ability.cry_rigged),
219-
card.ability.extra.odds_after_round,
226+
num1,
227+
denom1,
228+
num2,
229+
denom2,
220230
},
221231
}
222232
end,
@@ -228,8 +238,12 @@ local abstract = {
228238
and not card.ability.extra.marked
229239
and not card.ability.eternal
230240
and not card.ability.extra.survive --this presvents repitition of shatter chance by shutting it out once it confirms to "survive"
231-
and pseudorandom("cry_abstract_destroy")
232-
< cry_prob(card.ability.cry_prob, card.ability.extra.odds_after_play, card.ability.cry_rigged) / card.ability.extra.odds_after_play
241+
and SMODS.pseudorandom_probability(
242+
card,
243+
"cry_abstract_destroy",
244+
1,
245+
card and card.ability.extra.odds_after_play or self.config.extra.odds_after_play
246+
)
233247
then -- the 'card.area' part makes sure the card has a chance to survive if in the play area
234248
card.ability.extra.marked = true
235249
elseif context.cardarea == G.play and not card.ability.extra.marked then
@@ -2542,9 +2556,12 @@ return {
25422556
function Card:calculate_abstract_break()
25432557
if self.config.center_key == "m_cry_abstract" and not self.ability.extra.marked then
25442558
if
2545-
pseudorandom("cry_abstract_destroy2")
2546-
< cry_prob(self.ability.cry_prob, self.ability.extra.odds_after_round, self.ability.cry_rigged)
2547-
/ self.ability.extra.odds_after_round
2559+
SMODS.pseudorandom_probability(
2560+
card,
2561+
"cry_abstract_destroy2",
2562+
1,
2563+
card and card.ability.extra.odds_after_round or self.config.extra.odds_after_round
2564+
)
25482565
then
25492566
self.ability.extra.marked = true
25502567
--KUFMO HAS abstract!!!!111!!!

items/misc_joker.lua

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3915,18 +3915,15 @@ local rnjoker = {
39153915
config = {},
39163916
order = 59,
39173917
loc_vars = function(self, info_queue, card)
3918+
local num, denom = SMODS.get_probability_vars(card, 1, card and card.ability.extra.cond_value or 0)
39183919
local vars = {
39193920
vars = {
39203921
(card.ability.extra and card.ability.extra.value_mod and card.ability.extra.value) or 0,
39213922
(card.ability.extra and card.ability.extra.value and card.ability.extra.value_mod)
39223923
or (card.ability.extra and card.ability.extra.value)
39233924
or 0,
39243925
card.ability.extra and card.ability.extra.cond_value or 0,
3925-
cry_prob(
3926-
card.ability.cry_prob,
3927-
card.ability.extra and card.ability.extra.cond_value or 0,
3928-
card.ability.cry_rigged
3929-
),
3926+
num
39303927
},
39313928
}
39323929
if card.ability.extra and card.ability.extra.color then
@@ -4156,13 +4153,11 @@ local rnjoker = {
41564153
end
41574154
elseif j.cond == "odds" then
41584155
if
4159-
pseudorandom("rnj")
4160-
< (
4161-
cry_prob(
4162-
card.ability.cry_prob,
4163-
card.ability.extra.cond_value,
4164-
card.ability.cry_rigged
4165-
) / card.ability.extra.cond_value
4156+
SMODS.pseudorandom_probability(
4157+
card,
4158+
"rnj",
4159+
1,
4160+
card and card.ability.extra.cond_value or 0
41664161
)
41674162
then
41684163
cond_passed = true
@@ -4445,13 +4440,11 @@ local rnjoker = {
44454440
end
44464441
elseif j.cond == "odds" then
44474442
if
4448-
pseudorandom("rnj")
4449-
< (
4450-
cry_prob(
4451-
card.ability.cry_prob,
4452-
card.ability.extra.cond_value,
4453-
card.ability.cry_rigged
4454-
) / card.ability.extra.cond_value
4443+
SMODS.pseudorandom_probability(
4444+
card,
4445+
"rnj",
4446+
1,
4447+
card and card.ability.extra.cond_value or 0
44554448
)
44564449
then
44574450
cond_passed = true
@@ -4535,13 +4528,11 @@ local rnjoker = {
45354528
end
45364529
elseif j.cond == "odds" then
45374530
if
4538-
pseudorandom("rnj")
4539-
< (
4540-
cry_prob(
4541-
card.ability.cry_prob,
4542-
card.ability.extra.cond_value,
4543-
card.ability.cry_rigged
4544-
) / card.ability.extra.cond_value
4531+
SMODS.pseudorandom_probability(
4532+
card,
4533+
"rnj",
4534+
1,
4535+
card and card.ability.extra.cond_value or 0
45454536
)
45464537
then
45474538
cond_passed = true

items/planet.lua

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,12 @@ 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)
316318
return {
317319
vars = {
318-
card and cry_prob(card.ability.cry_prob, card.ability.extra.odds, card.ability.cry_rigged) or 1,
319-
card and card.ability.extra.odds or self.config.extra.odds,
320+
num,
321+
denom,
320322
},
321323
}
322324
end,
@@ -326,9 +328,12 @@ local planetlua = {
326328
use = function(self, card, area, copier)
327329
local used_consumable = copier or card
328330
if
329-
pseudorandom("planetlua")
330-
< cry_prob(card.ability.cry_prob, card.ability.extra.odds, card.ability.cry_rigged)
331-
/ card.ability.extra.odds
331+
SMODS.pseudorandom_probability(
332+
card,
333+
"planetlua",
334+
1,
335+
card and card.ability.extra.odds or self.config.extra.odds
336+
)
332337
then --Code "borrowed" from black hole
333338
update_hand_text(
334339
{ sound = "button", volume = 0.7, pitch = 0.8, delay = 0.3 },
@@ -473,8 +478,12 @@ local planetlua = {
473478
for i = 1, number do
474479
quota = quota
475480
+ (
476-
pseudorandom("planetlua")
477-
< cry_prob(card.ability.cry_prob, card.ability.extra.odds, card.ability.cry_rigged) / card.ability.extra.odds
481+
SMODS.pseudorandom_probability(
482+
card,
483+
"planetlua",
484+
1,
485+
card and card.ability.extra.odds or self.config.extra.odds
486+
)
478487
and 1
479488
or 0
480489
)
@@ -577,9 +586,12 @@ local planetlua = {
577586
G.GAME.used_vouchers.v_observatory
578587
and context.joker_main
579588
and (
580-
pseudorandom("nstar")
581-
< cry_prob(card.ability.cry_prob, card.ability.extra.odds, card.ability.cry_rigged)
582-
/ card.ability.extra.odds
589+
SMODS.pseudorandom_probability(
590+
card,
591+
"nstar", --this is how it was before i didnt make it use the same seed
592+
1,
593+
card and card.ability.extra.odds or self.config.extra.odds
594+
)
583595
)
584596
then
585597
local value = G.P_CENTERS.v_observatory.config.extra

0 commit comments

Comments
 (0)