Skip to content

Commit 50aea32

Browse files
authored
Merge pull request #715 from real-niacat/main
fix pointer on tags (plus optimizations!)
2 parents 11a9d74 + 615e49e commit 50aea32

File tree

4 files changed

+66
-57
lines changed

4 files changed

+66
-57
lines changed

Cryptid.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ function SMODS.injectItems(...)
187187
end
188188
end
189189
end
190+
Cryptid.inject_pointer_aliases()
190191
end
191192

192193
local old_repitions = SMODS.calculate_repetitions

items/pointer.lua

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,17 +259,28 @@ local pointer = {
259259
end
260260

261261
for i, v in pairs(G.P_TAGS) do -- TAGS
262-
if Cryptid.pointergetalias(i) and not Cryptid.pointergetblist(i) then
262+
local blacklist = Cryptid.pointergetblist(i)
263+
-- gonna be real w/ you idk why pointergetblist is a table now so im just gonna check if everything in it is falsey
264+
local can_spawn = true
265+
for _,val in pairs(blacklist) do
266+
can_spawn = can_spawn and (not val)
267+
end
268+
269+
if Cryptid.pointergetalias(i) and can_spawn then
270+
263271
if v.name and apply_lower(entered_card) == apply_lower(v.name) then
264272
current_card = i
273+
break --no clue why this wasn't done before, you can't create 2 tags with one pointer
265274
end
266275
if apply_lower(entered_card) == apply_lower(i) then
267276
current_card = i
277+
break
268278
end
269279
if
270280
apply_lower(entered_card) == apply_lower(localize({ type = "name_text", set = v.set, key = i }))
271281
then
272282
current_card = i
283+
break
273284
end
274285
end
275286
end
@@ -2569,12 +2580,33 @@ return {
25692580
name = "Pointer://",
25702581
items = pointeritems,
25712582
init = function()
2572-
print("[CRYPTID] Inserting Pointer Aliases")
2573-
local alify = Cryptid.pointeraliasify
2574-
Cryptid.pointerblistifytype("rarity", "cry_exotic", nil)
2575-
for key, aliasesTable in pairs(aliases) do
2576-
for _, alias in pairs(aliasesTable) do
2577-
alify(key, alias, nil)
2583+
function Cryptid.inject_pointer_aliases()
2584+
--print("[CRYPTID] Inserting Pointer Aliases")
2585+
local alify = Cryptid.pointeraliasify
2586+
Cryptid.pointerblistifytype("rarity", "cry_exotic", nil)
2587+
for key, aliasesTable in pairs(aliases) do
2588+
for _, alias in pairs(aliasesTable) do
2589+
alify(key, alias, nil)
2590+
end
2591+
alify(key, key, nil)
2592+
end
2593+
for _, group in pairs(G.localization.descriptions) do
2594+
if
2595+
_ ~= "Back"
2596+
and _ ~= "Content Set"
2597+
and _ ~= "Edition"
2598+
and _ ~= "Enhanced"
2599+
and _ ~= "Stake"
2600+
and _ ~= "Other"
2601+
then
2602+
for key, card in pairs(group) do
2603+
if G.P_CENTERS[key] then
2604+
alify(key, card.name, nil)
2605+
if G.P_CENTERS[key].name then alify(key, G.P_CENTERS[key].name, nil) end
2606+
if G.P_CENTERS[key].original_key then alify(key, G.P_CENTERS[key].original_key, nil) end
2607+
end
2608+
end
2609+
end
25782610
end
25792611
end
25802612
end,

lib/overrides.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,24 @@ function init_localization()
13631363
end
13641364
end
13651365
end
1366+
1367+
for _, group in pairs(G.localization.descriptions) do
1368+
if
1369+
_ ~= "Back"
1370+
and _ ~= "Content Set"
1371+
and _ ~= "Edition"
1372+
and _ ~= "Enhanced"
1373+
and _ ~= "Stake"
1374+
and _ ~= "Other"
1375+
then
1376+
for key, card in pairs(group) do
1377+
if G.P_CENTERS[key] then
1378+
Cryptid.pointeraliasify(key, card.name, true)
1379+
end
1380+
end
1381+
end
1382+
end
1383+
Cryptid.inject_pointer_aliases()
13661384
end
13671385

13681386
--Fix a corrupted game state

lib/pointerlib.lua

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,10 @@ function Cryptid.pointeraliasify(target, key, remove) -- Add a specific alias/ke
2525
key = string.lower(key:gsub("%b{}", ""):gsub("%s+", ""))
2626
end
2727
if not remove then
28-
if not Cryptid.pointeralias[target] then
29-
Cryptid.pointeralias[target] = {}
30-
end
31-
Cryptid.pointeralias[target][#Cryptid.pointeralias[target] + 1] = key
28+
Cryptid.pointeralias[key] = target
3229
return true
3330
else
34-
for v = 1, #Cryptid.pointeralias[target] do
35-
if Cryptid.pointeralias[target][v] == key then
36-
table.remove(Cryptid.pointeralias, v)
37-
return true
38-
end
39-
end
31+
Cryptid.pointeralias[key] = nil
4032
end
4133
return false
4234
end
@@ -90,50 +82,16 @@ function Cryptid.pointergetalias(target) -- "Is this alias legit?"
9082
end
9183
return string.lower(strn)
9284
end
93-
for _, group in pairs(G.localization.descriptions) do
94-
if
95-
_ ~= "Back"
96-
and _ ~= "Content Set"
97-
and _ ~= "Edition"
98-
and _ ~= "Enhanced"
99-
and _ ~= "Stake"
100-
and _ ~= "Other"
101-
then
102-
for key, card in pairs(group) do
103-
if G.P_CENTERS[key] then
104-
if apply_lower(card.name) == apply_lower(target) then
105-
return key
106-
end
107-
end
108-
end
109-
end
110-
end
111-
for card, _ in pairs(Cryptid.pointeralias) do
112-
if apply_lower(card) == apply_lower(target) then
113-
return card
114-
end
115-
for _, alias in ipairs(Cryptid.pointeralias[card]) do
116-
if apply_lower(alias) == apply_lower(target) then
117-
return card
118-
end
119-
end
120-
end
121-
for keym, card in pairs(G.P_CENTERS) do
122-
if apply_lower(card.name) == apply_lower(target) then
123-
return keym
124-
end
125-
if apply_lower(card.original_key) == apply_lower(target) then
126-
return keym
127-
end
128-
if apply_lower(keym) == apply_lower(target) then
129-
return keym
130-
end
131-
end
85+
if Cryptid.pointeralias[apply_lower(target)] then return Cryptid.pointeralias[apply_lower(target)] end
86+
if G.P_CENTERS[apply_lower(target)] then return G.P_CENTERS[apply_lower(target)].key end
87+
if Cryptid.pointeralias[target] then return Cryptid.pointeralias[target] end
88+
if G.P_CENTERS[target] then return G.P_CENTERS[target].key end
13289
return false
13390
end
13491

13592
function Cryptid.pointergetblist(target) -- "Is this card pointer banned?"
136-
target = Cryptid.pointergetalias(target)
93+
target = Cryptid.pointergetalias(target) or target
94+
target = G.P_CENTERS[target] or target
13795
results = {}
13896
results[1] = false
13997
if not target then

0 commit comments

Comments
 (0)