Skip to content

Commit 2265585

Browse files
authored
add shiny tag collection + file saving
1 parent e2db5c4 commit 2265585

File tree

5 files changed

+235
-39
lines changed

5 files changed

+235
-39
lines changed

lib/misc.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,28 @@ function cry_bonusvouchermod(mod)
383383
end
384384
end
385385

386+
function save_cryptid()
387+
local data = {
388+
shinytags = {},
389+
}
390+
data.shinytags = copy_table(Cryptid.shinytagdata)
391+
compress_and_save( G.SETTINGS.profile..'/'..'cryptidsave.jkr', STR_PACK(data))
392+
end
393+
394+
local sppref = set_profile_progress
395+
function set_profile_progress()
396+
sppref()
397+
if not Cryptid.shinytagdata.init then
398+
for k, v in pairs(G.P_TAGS) do
399+
if Cryptid.shinytagdata[k] == nil then
400+
Cryptid.shinytagdata.init = true
401+
Cryptid.shinytagdata[k] = false
402+
print(k)
403+
end
404+
end
405+
end
406+
end
407+
386408
Cryptid.big_num_whitelist = {
387409
j_ride_the_bus = true,
388410
j_egg = true,

lib/modifiers.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,28 @@ function Tag:set_ability()
693693
end
694694
end
695695

696+
local ycollecref = G.FUNCS.your_collection
697+
G.FUNCS.your_collection = function(e)
698+
ycollecref(e)
699+
G.cry_current_tagpage = nil
700+
end
701+
local omuicryref = G.FUNCS.openModUI_Cryptid
702+
G.FUNCS.openModUI_Cryptid = function(e)
703+
omuicryref(e)
704+
G.cry_current_tagpage = nil
705+
end
706+
707+
function cry_shinytag_tally()
708+
local ret = 0
709+
for k, v in pairs(Cryptid.shinytagdata) do
710+
if Cryptid.shinytagdata[k] then
711+
ret = ret + 1
712+
end
713+
end
714+
print(ret)
715+
return ret
716+
end
717+
696718
-- temp crappy overwrite for voucher ui until smods does stuff
697719

698720
function G.UIDEF.used_vouchers()

localization/en-us.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4274,6 +4274,7 @@ return {
42744274
b_pull = "PULL",
42754275
cry_hooked_ex = "Hooked!",
42764276
k_end_blind = "End Blind",
4277+
k_cry_shiny = "Shiny",
42774278

42784279
cry_code_rank = "ENTER RANK",
42794280
cry_code_enh = "ENTER ENHANCEMENT",

lovely/cat.toml

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ tag_sprite.click = function(_self)
9191
9292
other_cat.ability.level = other_cat.ability.level + 1
9393
94+
if self.ability.shiny then
95+
if not Cryptid.shinytagdata[self.key] then
96+
Cryptid.shinytagdata[self.key] = true
97+
save_cryptid()
98+
end
99+
end
100+
94101
G.E_MANAGER:add_event(Event({
95102
trigger = 'after',
96103
delay = 0.7,
@@ -174,3 +181,186 @@ if self.key == 'tag_cry_cat' then
174181
play_sound('cry_meow'..math.random(4), 1.26, 0.12);
175182
end'''
176183
match_indent = true
184+
185+
186+
187+
188+
# shiny tags
189+
[[patches]]
190+
[patches.pattern]
191+
target = "tag.lua"
192+
pattern = '''local tag_sprite = Sprite(0,0,_size*1,_size*1,G.ASSET_ATLAS[(not self.hide_ability) and G.P_TAGS[self.key].atlas or "tags"], (self.hide_ability) and G.tag_undiscovered.pos or self.pos)'''
193+
position = "at"
194+
payload = '''
195+
local tagatlas = G.ASSET_ATLAS[(not self.hide_ability) and G.P_TAGS[self.key].atlas or "tags"]
196+
if self.ability.shiny and not self.hide_ability then
197+
if not G.P_TAGS[self.key].atlas then
198+
tagatlas = G.ASSET_ATLAS['cry_shinyv']
199+
elseif G.P_TAGS[self.key].atlas == 'cry_tag_cry' then
200+
tagatlas = G.ASSET_ATLAS['cry_shinyc']
201+
end
202+
end
203+
204+
local tag_sprite = Sprite(0,0,_size*1,_size*1,tagatlas, (self.hide_ability) and G.tag_undiscovered.pos or self.pos)
205+
'''
206+
match_indent = true
207+
208+
# define function
209+
[[patches]]
210+
[patches.pattern]
211+
target = "functions/misc_functions.lua"
212+
pattern = "function save_run()"
213+
position = "before"
214+
payload = '''
215+
function cry_rollshiny()
216+
local prob = 1
217+
if next(SMODS.find_card('j_lucky_cat')) then prob = 3 end
218+
if pseudorandom("cry_shiny") < prob / 4096 then
219+
print("true")
220+
return 'shiny'
221+
end
222+
return 'normal'
223+
end
224+
225+
function cry_rollshinybool()
226+
if cry_rollshiny() == 'shiny' then
227+
return true
228+
end
229+
return false
230+
end
231+
'''
232+
match_indent = true
233+
234+
# collection
235+
# nice pattern match?
236+
[[patches]]
237+
[patches.pattern]
238+
target = '''=[SMODS _ "src/overrides.lua"]'''
239+
pattern = '''
240+
opt_callback = 'your_collection_tags_page',
241+
focus_args = { snap_to = true, nav = 'wide' },
242+
current_option = page,
243+
colour = G.C.RED,
244+
no_pips = true
245+
})
246+
}
247+
}'''
248+
position = "after"
249+
payload = '''
250+
,
251+
cry_shinytag_tally() > 0 and create_toggle{ -- tally function runs way too often but whatever
252+
label = localize('k_cry_shiny'),
253+
w = 0,
254+
ref_table = G,
255+
ref_value = "showshinytags"
256+
} or nil,
257+
'''
258+
match_indent = true
259+
260+
[[patches]]
261+
[patches.pattern]
262+
target = '''=[SMODS _ "src/overrides.lua"]'''
263+
pattern = '''
264+
if not v.discovered then temp_tag.hide_ability = true end
265+
'''
266+
position = "before"
267+
payload = '''
268+
if G.showshinytags then
269+
temp_tag.ability.shiny = true
270+
if not Cryptid.shinytagdata[temp_tag.key] then
271+
temp_tag.hide_ability = true
272+
end
273+
end
274+
'''
275+
match_indent = true
276+
277+
# i can't seem to get the tag page easily
278+
# i'm also surprised this doesn't multipatch
279+
[[patches]]
280+
[patches.pattern]
281+
target = '''=[SMODS _ "src/overrides.lua"]'''
282+
pattern = '''
283+
local page = args.cycle_config.current_option or 1
284+
'''
285+
position = "at"
286+
payload = '''
287+
if args then G.cry_current_tagpage = args.cycle_config.current_option end
288+
local page = args and args.cycle_config.current_option or G.cry_current_tagpage or 1
289+
'''
290+
match_indent = true
291+
292+
# update collection
293+
# scuffed
294+
[[patches]]
295+
[patches.pattern]
296+
target = '''game.lua'''
297+
pattern = '''
298+
self.E_MANAGER:update(self.real_dt)
299+
'''
300+
position = "before"
301+
payload = '''
302+
if not G.showshinytags then G.showshinytags = false end
303+
if not G.showshinytags_b then G.showshinytags_b = false end
304+
305+
if G.showshinytags ~= G.showshinytags_b then
306+
G.showshinytags_b = G.showshinytags
307+
G.FUNCS.your_collection_tags_page()
308+
end
309+
'''
310+
match_indent = true
311+
312+
# save+loading time
313+
314+
# cryptidsave stuff
315+
[[patches]]
316+
[patches.pattern]
317+
target = '''game.lua'''
318+
pattern = '''
319+
if not love.filesystem.getInfo(G.SETTINGS.profile..'/'..'meta.jkr') then love.filesystem.append( G.SETTINGS.profile..'/'..'meta.jkr', 'return {}') end
320+
'''
321+
position = "after"
322+
payload = '''
323+
if not love.filesystem.getInfo(G.SETTINGS.profile..'/'..'cryptidsave.jkr') then love.filesystem.append( G.SETTINGS.profile..'/'..'cryptidsave.jkr', 'return {}') end
324+
'''
325+
match_indent = true
326+
327+
[[patches]]
328+
[patches.pattern]
329+
target = '''game.lua'''
330+
pattern = '''
331+
local meta = STR_UNPACK(get_compressed(G.SETTINGS.profile..'/'..'meta.jkr') or 'return {}')
332+
'''
333+
position = "after"
334+
payload = '''
335+
local cryptidsave = STR_UNPACK(get_compressed(G.SETTINGS.profile..'/'..'cryptidsave.jkr') or 'return {}')
336+
337+
for k, v in pairs(cryptidsave) do
338+
print('loaded CRYPTIDSAVE')
339+
print(k)
340+
end
341+
342+
if cryptidsave and cryptidsave.shinytags then
343+
Cryptid.shinytagdata = copy_table(cryptidsave.shinytags)
344+
else
345+
-- populated later when tags actually exist
346+
Cryptid.shinytagdata = {}
347+
end
348+
'''
349+
match_indent = true
350+
351+
[[patches]]
352+
[patches.pattern]
353+
target = '''tag.lua'''
354+
pattern = '''
355+
function Tag:yep(message, _colour, func)
356+
'''
357+
position = "after"
358+
payload = '''
359+
if self.ability.shiny then
360+
if not Cryptid.shinytagdata[self.key] then
361+
Cryptid.shinytagdata[self.key] = true
362+
save_cryptid()
363+
end
364+
end
365+
'''
366+
match_indent = true

lovely/misc.toml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -422,43 +422,4 @@ if (not self.ability.orbital_hand) or (not G.GAME.hands[self.ability.orbital_han
422422
self.ability.orbital_hand = pseudorandom_element(_poker_hands, pseudoseed('orbital'))
423423
end
424424
'''
425-
match_indent = true
426-
427-
# shiny tags
428-
[[patches]]
429-
[patches.pattern]
430-
target = "tag.lua"
431-
pattern = '''local tag_sprite = Sprite(0,0,_size*1,_size*1,G.ASSET_ATLAS[(not self.hide_ability) and G.P_TAGS[self.key].atlas or "tags"], (self.hide_ability) and G.tag_undiscovered.pos or self.pos)'''
432-
position = "at"
433-
payload = '''
434-
local tagatlas = G.ASSET_ATLAS[(not self.hide_ability) and G.P_TAGS[self.key].atlas or "tags"]
435-
if self.ability.shiny and not self.hide_ability then
436-
if not G.P_TAGS[self.key].atlas then
437-
tagatlas = G.ASSET_ATLAS['cry_shinyv']
438-
elseif G.P_TAGS[self.key].atlas == 'cry_tag_cry' then
439-
tagatlas = G.ASSET_ATLAS['cry_shinyc']
440-
end
441-
end
442-
443-
local tag_sprite = Sprite(0,0,_size*1,_size*1,tagatlas, (self.hide_ability) and G.tag_undiscovered.pos or self.pos)
444-
'''
445-
match_indent = true
446-
447-
# define function
448-
[[patches]]
449-
[patches.pattern]
450-
target = "functions/misc_functions.lua"
451-
pattern = "function save_run()"
452-
position = "before"
453-
payload = '''
454-
function cry_rollshiny()
455-
local prob = 1
456-
if next(SMODS.find_card('j_lucky_cat')) then prob = 3 end
457-
if pseudorandom("shiny") < prob / 4096 then
458-
print("true")
459-
return 'shiny'
460-
end
461-
return 'normal'
462-
end
463-
'''
464425
match_indent = true

0 commit comments

Comments
 (0)