-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmanipulate.lua
More file actions
289 lines (281 loc) · 8.8 KB
/
manipulate.lua
File metadata and controls
289 lines (281 loc) · 8.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
Cryptid.base_values = {}
Cryptid.misprintize_value_blacklist = {
perish_tally = false,
id = false,
suit_nominal = false,
base_nominal = false,
face_nominal = false,
qty = false,
h_x_chips = false,
d_size = false,
h_size = false,
selected_d6_face = false,
cry_hook_id = false,
colour = false,
suit_nominal_original = false,
times_played = false,
extra_slots_used = false,
card_limit = false,
-- TARGET: Misprintize Value Blacklist (format: key = false, )
}
Cryptid.misprintize_bignum_blacklist = {
odds = false,
cry_prob = false,
perma_repetitions = false,
repetitions = false,
nominal = false, --no clue why this was commented, it causes a crash if not
}
Cryptid.misprintize_value_cap = { --yeahh.. this is mostly just for retriggers, but i might as well make it fully functional
perma_repetitions = 40,
repetitions = 40,
}
function Cryptid.log_random(seed, min, max)
math.randomseed(seed)
local lmin = math.log(min, 2.718281828459045)
local lmax = math.log(max, 2.718281828459045)
local poll = math.random() * (lmax - lmin) + lmin
return math.exp(poll)
end
function cry_format(number, str)
if math.abs(to_big(number)) >= to_big(1e300) then
return number
end
return tonumber(str:format((Big and to_number(to_big(number)) or number)))
end
--use ID to work with glitched/misprint
function Card:get_nominal(mod)
local mult = 1
local rank_mult = 1
if mod == "suit" then
mult = 1000000
end
if self.ability.effect == "Stone Card" or (self.config.center.no_suit and self.config.center.no_rank) then
mult = -10000
elseif self.config.center.no_suit then
mult = 0
elseif self.config.center.no_rank then
rank_mult = 0
end
return 10 * (self.base.id or 0.1) * rank_mult
+ self.base.suit_nominal * mult
+ (self.base.suit_nominal_original or 0) * 0.0001 * mult
+ 10 * self.base.face_nominal * rank_mult
+ 0.000001 * self.unique_val
end
function Cryptid.manipulate(card, args)
if not card or not card.config or not card.config.center then return end
if not Card.no(card, "immutable", true) or (args and args.bypass_checks) then
if not args then
return Cryptid.manipulate(card, {
min = (G.GAME.modifiers.cry_misprint_min or 1),
max = (G.GAME.modifiers.cry_misprint_max or 1),
type = "X",
dont_stack = true,
no_deck_effects = true,
})
else
local func = function(card)
if not args.type then
args.type = "X"
end
--hardcoded whatever
if card.config.center.set == "Booster" then
args.big = false
end
local caps = card.config.center.misprintize_caps or {}
if card.infinifusion then
if card.config.center == card.infinifusion_center or card.config.center.key == "j_infus_fused" then
calculate_infinifusion(card, nil, function(i)
Cryptid.manipulate(card, args)
end)
end
end
Cryptid.manipulate_table(card, card, "ability", args)
if card.base then
Cryptid.manipulate_table(card, card, "base", args)
end
if G.GAME.modifiers.cry_misprint_min then
--card.cost = cry_format(card.cost / Cryptid.log_random(pseudoseed('cry_misprint'..G.GAME.round_resets.ante),override and override.min or G.GAME.modifiers.cry_misprint_min,override and override.max or G.GAME.modifiers.cry_misprint_max),"%.2f")
card.misprint_cost_fac = 1
/ Cryptid.log_random(
pseudoseed("cry_misprint" .. G.GAME.round_resets.ante),
override and override.min or G.GAME.modifiers.cry_misprint_min,
override and override.max or G.GAME.modifiers.cry_misprint_max
)
card:set_cost()
end
if caps then
for i, v in pairs(caps) do
if Cryptid.is_big(v) then
for i2, v2 in pairs(v) do
if to_big(card.ability[i][i2]) > to_big(v2) then
card.ability[i][i2] = Cryptid.sanity_check(v2, Cryptid.is_card_big(card))
end
end
elseif Cryptid.is_number(v) then
if to_big(card.ability[i]) > to_big(v) then
card.ability[i] = Cryptid.sanity_check(v, Cryptid.is_card_big(card))
end
end
end
end
end
local config = copy_table(card.config.center.config)
if not Cryptid.base_values[card.config.center.key] then
Cryptid.base_values[card.config.center.key] = {}
for i, v in pairs(config) do
if Cryptid.is_number(v) and to_big(v) ~= to_big(0) then
Cryptid.base_values[card.config.center.key][i .. "ability"] = v
elseif type(v) == "table" then
for i2, v2 in pairs(v) do
Cryptid.base_values[card.config.center.key][i2 .. i] = v2
end
end
end
end
if not args.bypass_checks and not args.no_deck_effects then
Cryptid.with_deck_effects(card, func)
else
func(card)
end
if card.ability.consumeable then
for k, v in pairs(card.ability.consumeable) do
card.ability.consumeable[k] = Cryptid.deep_copy(card.ability[k])
end
end
--ew ew ew ew
G.P_CENTERS[card.config.center.key].config = config
end
return true
end
end
function Cryptid.manipulate_table(card, ref_table, ref_value, args, tblkey)
if ref_value == "consumeable" then
return
end
for i, v in pairs(ref_table[ref_value]) do
if
Cryptid.is_number(v)
and Cryptid.misprintize_value_blacklist[i] ~= false
then
local num = v
if args.dont_stack then
if
Cryptid.base_values[card.config.center.key]
and (
Cryptid.base_values[card.config.center.key][i .. ref_value]
or (ref_value == "ability" and Cryptid.base_values[card.config.center.key][i .. "consumeable"])
)
then
num = Cryptid.base_values[card.config.center.key][i .. ref_value]
or Cryptid.base_values[card.config.center.key][i .. "consumeable"]
end
end
if args.big ~= nil then
ref_table[ref_value][i] = Cryptid.manipulate_value(num, args, args.big, i)
else
ref_table[ref_value][i] = Cryptid.manipulate_value(num, args, Cryptid.is_card_big(card), i)
end
elseif i ~= "immutable" and type(v) == "table" and Cryptid.misprintize_value_blacklist[i] ~= false then
Cryptid.manipulate_table(card, ref_table[ref_value], i, args)
end
end
end
function Cryptid.manipulate_value(num, args, is_big, name)
if not Cryptid.is_number(num) then return end
if args.func then
num = args.func(num, args, is_big, name)
else
if args.min and args.max then
local new_args = args
local big_min = to_big(args.min)
local big_max = to_big(args.max)
local new_value = Cryptid.log_random(
pseudoseed(args.seed or ("cry_misprint" .. G.GAME.round_resets.ante)),
big_min,
big_max
)
if args.type == "+" then
if to_big(num) ~= to_big(0) and to_big(num) ~= to_big(1) then
num = num + new_value
end
elseif args.type == "X" then
if
to_big(num) ~= to_big(0) and (to_big(num) ~= to_big(1) or (name ~= "x_chips" and name ~= "x_mult"))
then
num = num * new_value
end
elseif args.type == "^" then
num = to_big(num) ^ new_value
elseif args.type == "hyper" and SMODS.Mods.Talisman and SMODS.Mods.Talisman.can_load then
if to_big(num) ~= to_big(0) and to_big(num) ~= to_big(1) then
num = to_big(num):arrow(args.value.arrows, to_big(new_value))
end
end
elseif args.value then
if args.type == "+" then
if to_big(num) ~= to_big(0) and to_big(num) ~= to_big(1) then
num = num + to_big(args.value)
end
elseif args.type == "X" then
if
to_big(num) ~= to_big(0) and (to_big(num) ~= to_big(1) or (name ~= "x_chips" and name ~= "x_mult"))
then
num = num * args.value
end
elseif args.type == "^" then
num = to_big(num) ^ args.value
elseif args.type == "hyper" and SMODS.Mods.Talisman and SMODS.Mods.Talisman.can_load then
num = to_big(num):arrow(args.value.arrows, to_big(args.value.height))
end
end
end
if Cryptid.misprintize_value_cap[name] then
num = math.min(num, Cryptid.misprintize_value_cap[name])
end
if Cryptid.misprintize_bignum_blacklist[name] == false then
num = to_number(num)
return to_number(Cryptid.sanity_check(num, false))
end
local val = Cryptid.sanity_check(num, is_big)
if to_big(val) > to_big(-1e100) and to_big(val) < to_big(1e100) then
return to_number(val)
end
return val
end
local get_nominalref = Card.get_nominal
function Card:get_nominal(...)
return to_number(get_nominalref(self, ...))
end
local gsr = Game.start_run
function Game:start_run(args)
gsr(self, args)
Cryptid.base_values = {}
end
function Cryptid.sanity_check(val, is_big)
if not Talisman then return val end
if is_big then
if not val or type(val) == "number" and (val ~= val or val > 1e300 or val < -1e300) then
val = 1e300
end
if Cryptid.is_big(val) then
return val
end
if val > 1e100 or val < -1e100 then
return to_big(val)
end
end
if not val or type(val) == "number" and (val ~= val or val > 1e300 or val < -1e300) then
return 1e300
end
if Cryptid.is_big(val) then
if val > to_big(1e300) then
return 1e300
end
if val < to_big(-1e300) then
return -1e300
end
return to_number(val)
end
return val
end