-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfunctions.lua
338 lines (298 loc) · 10.9 KB
/
functions.lua
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
local function has_joker(e)
for k, v in pairs(G.jokers.cards) do
if v.ability.set == 'Joker' and v.config.center.key == e then
return k
end
end
return -1
end
function JokerEvolution.evolutions:add_evolution(joker, evolved_joker, amount, carry_stat)
table.insert(self, {key = joker, evo = evolved_joker, amount = amount, carry_stat = carry_stat})
end
function has_evo(c)
for _, joker in ipairs(JokerEvolution.evolutions) do
if c.key == joker.key then
return true
end
end
return false
end
function is_evo(c)
for _, joker in ipairs(JokerEvolution.evolutions) do
if c.key == joker.evo then
return true
end
end
return false
end
function Card:check_evo_condition()
local evol = get_card_evolution(self)
if evol and (self.ability.amount and self.ability.amount >= evol.amount) and not self.ability.can_evolve then
self.ability.can_evolve = true
end
end
function Card:increment_evo_condition(amount)
local amount = amount or 1
if self.ability.amount then
self.ability.amount = self.ability.amount + amount
self:check_evo_condition()
end
end
function Card:decrement_evo_condition(amount)
local amount = amount or 1
if self.ability.amount then
self.ability.amount = self.ability.amount - amount
self:check_evo_condition()
end
end
function Card:set_evo_condition(amount)
local amount = amount or ((self.ability and self.ability.amount) or 0)
if self.ability.amount then
self.ability.amount = amount
self:check_evo_condition()
end
end
function Card:can_evolve_card()
for _, joker in ipairs(JokerEvolution.evolutions) do
local exists = false
local all_jokers = true
if G.jokers and G.jokers.cards and not (has_joker(joker.key) > -1) then
all_jokers = false
end
if joker.key == self.config.center.key then
exists = true
end
if not self.debuff and exists and all_jokers and self.ability.can_evolve then
return true
end
end
return false
end
function get_card_evolution(card)
if not card.config then print(tprint(card)); return false end --Cryptid failsafe
for _, evo in ipairs(JokerEvolution.evolutions) do
if evo.key == card.config.center.key then
return evo
end
end
return false
end
function Card:evolve_card()
G.CONTROLLER.locks.selling_card = true
stop_use()
local area = self.area
G.CONTROLLER:save_cardarea_focus('jokers')
if self.children.use_button then self.children.use_button:remove(); self.children.use_button = nil end
if self.children.sell_button then self.children.sell_button:remove(); self.children.sell_button = nil end
local final_evo = nil
for _, joker in ipairs(JokerEvolution.evolutions) do
if joker.key == self.config.center.key then
final_evo = joker
break
end
end
if final_evo ~= nil then
G.GAME.evolution_total = (G.GAME.evolution_total and G.GAME.evolution_total + 1) or 1
if G.jokers and G.jokers.cards and #G.jokers.cards > 0 then
for i = 1, #G.jokers.cards do
G.jokers.cards[i]:calculate_joker({evolution = true})
end
end
G.E_MANAGER:add_event(Event({trigger = 'after',delay = 0.2, func = function()
play_sound('whoosh1')
self:juice_up(0.3, 0.4)
return true
end}))
delay(0.2)
G.E_MANAGER:add_event(Event({trigger = 'immediate', func = function()
local carry_stat = {ability = {extra = {}}}
if final_evo.carry_stat then
for _, val in ipairs(final_evo.carry_stat) do
if self[val] then
carry_stat[val] = self[val]
end
if self.ability[val] ~= nil then
carry_stat.ability[val] = self.ability[val]
end
if self.ability.extra and type(self.ability.extra) ~= "table" then
carry_stat.ability.extra = self.ability.extra
elseif self.ability.extra and self.ability.extra[val] ~= nil then
carry_stat.ability.extra[val] = self.ability.extra[val]
end
end
end
self:start_materialize({G.C.MONEY}, true)
play_sound('explosion_release1')
self:juice_up(0.3, 0.5)
self:set_ability(G.P_CENTERS[final_evo.evo], true)
if final_evo.carry_stat then
for _, val in ipairs(final_evo.carry_stat) do
if carry_stat[val] then
self[val] = carry_stat[val]
end
if carry_stat.ability[val] ~= nil then
self.ability[val] = carry_stat.ability[val]
end
if carry_stat.ability.extra and type(carry_stat.ability.extra) ~= "table" then
self.ability.extra = carry_stat.ability.extra
elseif carry_stat.ability.extra and carry_stat.ability.extra[val] ~= nil then
self.ability.extra[val] = carry_stat.ability.extra[val]
end
end
end
self.area:remove_from_highlighted(self)
G.E_MANAGER:add_event(Event({trigger = 'after',delay = 0.3, blocking = false, func = function()
card_eval_status_text(self, 'extra', nil, nil, nil, {message = "Evolved!", colour = G.C.MONEY})
return true
end}))
delay(0.1)
G.E_MANAGER:add_event(Event({trigger = 'after',delay = 0.3, blocking = false,
func = function()
G.E_MANAGER:add_event(Event({trigger = 'immediate',
func = function()
G.E_MANAGER:add_event(Event({trigger = 'immediate',
func = function()
G.CONTROLLER.locks.selling_card = nil
G.CONTROLLER:recall_cardarea_focus(area == G.jokers and 'jokers' or 'consumeables')
return true
end}))
return true
end}))
return true
end}))
return true
end}))
end
G.CONTROLLER.locks.selling_card = nil
G.CONTROLLER:recall_cardarea_focus('jokers')
end
function Card:calculate_evo(context)
if get_card_evolution(self) and not context.blueprint then
local obj = self.config.center
local evol = get_card_evolution(self)
if not obj.calculate_evo and G.P_CENTERS[evol.evo].calculate_evo then
obj.calculate_evo = G.P_CENTERS[evol.evo].calculate_evo
end
if obj and obj.calculate_evo and type(obj.calculate_evo) == 'function' then
local o = obj:calculate_evo(self, context)
if o then return o end
end
end
end
function Card:add_to_deck_evo(from_debuff)
if get_card_evolution(self) then
local obj = self.config.center
local evol = get_card_evolution(self)
if not obj.add_to_deck_evo and G.P_CENTERS[evol.evo].add_to_deck_evo then
obj.add_to_deck_evo = G.P_CENTERS[evol.evo].add_to_deck_evo
end
if obj and obj.add_to_deck_evo and type(obj.add_to_deck_evo) == 'function' then
local o = obj:add_to_deck_evo(self, from_debuff)
if o then return o end
end
self:check_evo_condition()
end
end
function set_evo_tooltip(_c)
for _, joker in ipairs(JokerEvolution.evolutions) do
if _c.key == joker.key then
if (G.jokers and G.jokers.cards and #G.jokers.cards > 0) and Evolution_tooltip_object then -- Evolution_tooltip_object defined in "lovely.toml"
local my_pos = nil
for i = 1, #G.jokers.cards do
if G.jokers.cards[i] == Evolution_tooltip_object then my_pos = i; break end
end
if my_pos and (G.jokers.cards[my_pos].ability and G.jokers.cards[my_pos].ability.amount) then
return {key = "je_" .. joker.key, set = "Other", vars = {math.min(G.jokers.cards[my_pos].ability.amount, joker.amount), joker.amount}}
end
end
return {key = "je_" .. joker.key, set = "Other", vars = {0, joker.amount}}
end
end
end
G.FUNCS.evolve_card = function(e)
local card = e.config.ref_table
card:evolve_card()
end
G.FUNCS.can_evolve_card = function(e)
if (G.play and #G.play.cards > 0) or
(G.CONTROLLER.locked) or
(G.GAME.STOP_USE and G.GAME.STOP_USE > 0) or
not e.config.ref_table:can_evolve_card()
then
e.config.colour = G.C.UI.BACKGROUND_INACTIVE
e.config.button = nil
else
e.config.colour = G.C.GOLD
e.config.button = 'evolve_card'
end
end
-- Pseudo-overrides
function create_card_alt(_type, area, legendary, _rarity, skip_materialize, soulable, forced_key, key_append, edition_append, forced_edition)
local area = area or G.jokers
local center = G.P_CENTERS.b_red
--should pool be skipped with a forced key
if not forced_key and soulable and (not G.GAME.banned_keys['c_soul']) then
if (_type == 'Tarot' or _type == 'Spectral' or _type == 'Tarot_Planet') and
not (G.GAME.used_jokers['c_soul'] and not next(find_joker("Showman"))) then
if pseudorandom('soul_'.._type..G.GAME.round_resets.ante) > 0.997 then
forced_key = 'c_soul'
end
end
if (_type == 'Planet' or _type == 'Spectral') and
not (G.GAME.used_jokers['c_black_hole'] and not next(find_joker("Showman"))) then
if pseudorandom('soul_'.._type..G.GAME.round_resets.ante) > 0.997 then
forced_key = 'c_black_hole'
end
end
end
if _type == 'Base' then
forced_key = 'c_base'
end
if forced_key and not G.GAME.banned_keys[forced_key] then
center = G.P_CENTERS[forced_key]
_type = (center.set ~= 'Default' and center.set or _type)
else
local _pool, _pool_key = get_current_pool(_type, _rarity, legendary, key_append)
center = pseudorandom_element(_pool, pseudoseed(_pool_key))
local it = 1
while center == 'UNAVAILABLE' do
it = it + 1
center = pseudorandom_element(_pool, pseudoseed(_pool_key..'_resample'..it))
end
center = G.P_CENTERS[center]
end
local front = ((_type=='Base' or _type == 'Enhanced') and pseudorandom_element(G.P_CARDS, pseudoseed('front'..(key_append or '')..G.GAME.round_resets.ante))) or nil
local card = Card(area.T.x + area.T.w/2, area.T.y, G.CARD_W, G.CARD_H, front, center,
{bypass_discovery_center = area==G.shop_jokers or area == G.pack_cards or area == G.shop_vouchers or (G.shop_demo and area==G.shop_demo) or area==G.jokers or area==G.consumeables,
bypass_discovery_ui = area==G.shop_jokers or area == G.pack_cards or area==G.shop_vouchers or (G.shop_demo and area==G.shop_demo),
discover = area==G.jokers or area==G.consumeables,
bypass_back = G.GAME.selected_back.pos})
if card.ability.consumeable and not skip_materialize then card:start_materialize() end
if _type == 'Joker' then
if G.GAME.modifiers.all_eternal then
card:set_eternal(true)
end
if (area == G.shop_jokers) or (area == G.pack_cards) then
local eternal_perishable_poll = pseudorandom((area == G.pack_cards and 'packetper' or 'etperpoll')..G.GAME.round_resets.ante)
if G.GAME.modifiers.enable_eternals_in_shop and eternal_perishable_poll > 0.7 then
card:set_eternal(true)
elseif G.GAME.modifiers.enable_perishables_in_shop and ((eternal_perishable_poll > 0.4) and (eternal_perishable_poll <= 0.7)) then
card:set_perishable(true)
end
if G.GAME.modifiers.enable_rentals_in_shop and pseudorandom((area == G.pack_cards and 'packssjr' or 'ssjr')..G.GAME.round_resets.ante) > 0.7 then
card:set_rental(true)
end
end
if edition_append then
if forced_edition == nil then
local edition = poll_edition('edi'..(key_append or '')..G.GAME.round_resets.ante)
card:set_edition(edition)
else
card:set_edition(forced_edition)
end
check_for_unlock({type = 'have_edition'})
end
end
return card
end
return