Skip to content

Commit 58014f9

Browse files
committed
reuse some logic across all enhanced decks
1 parent 2577b00 commit 58014f9

File tree

3 files changed

+35
-50
lines changed

3 files changed

+35
-50
lines changed

items/enhanced.lua

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,13 @@ local e_deck = {
1313
order = 17,
1414
pos = { x = 5, y = 2 },
1515
loc_vars = function(self, info_queue, center)
16-
local aaa
17-
-- Won't update to the correct value if it's switched while in a game and then viewing the new value while in that same game
18-
-- Oh well
19-
if G.GAME.modifiers.cry_force_edition and not G.GAME.viewed_back then
20-
aaa = G.GAME.modifiers.cry_force_edition
21-
elseif self.config.cry_force_edition then
22-
aaa = self.config.cry_force_edition
23-
else
24-
aaa = cry_get_enchanced_deck_info()
25-
end
16+
local aaa = cry_get_enchanced_deck_info(self)
2617
return { vars = { localize{type = "name_text", set = "Edition", key = "e_" .. aaa} } }
2718
end,
2819
edeck_type = "edition",
2920
config = {},
3021
apply = function(self)
31-
local aaa = cry_get_enchanced_deck_info()
22+
local aaa = cry_get_enchanced_deck_info(self)
3223
G.GAME.modifiers.cry_force_edition = aaa
3324
--Ban Edition tags (They will never redeem)
3425
for k, v in pairs(G.P_TAGS) do
@@ -46,6 +37,7 @@ local e_deck = {
4637
}))
4738
end
4839
}
40+
-- I set up some WIP tables for sprites here, will finish later
4941
local et_deck = {
5042
object_type = "Back",
5143
name = "cry-Enhancement Deck",
@@ -54,19 +46,15 @@ local et_deck = {
5446
pos = { x = 5, y = 2},
5547
edeck_type = "enhancement",
5648
config = {},
49+
sprites = {
50+
default = { atlas = "centers", pos = { x = 5, y = 2 } },
51+
},
5752
loc_vars = function(self, info_queue, center)
58-
local aaa,bbb
59-
if G.GAME.modifiers.cry_force_enhancement and not G.GAME.viewed_back then
60-
bbb = G.GAME.modifiers.cry_force_enhancement
61-
elseif self.config.cry_force_enhancement then
62-
bbb = self.config.cry_force_enhancement
63-
else
64-
aaa,bbb = cry_get_enchanced_deck_info()
65-
end
53+
local _, bbb = cry_get_enchanced_deck_info(self)
6654
return { vars = { localize{type = "name_text", set = "Enhanced", key = bbb} } }
6755
end,
6856
apply = function(self)
69-
local aaa,bbb = cry_get_enchanced_deck_info()
57+
local aaa,bbb = cry_get_enchanced_deck_info(self)
7058
G.GAME.modifiers.cry_force_enhancement = bbb
7159
G.E_MANAGER:add_event(Event({
7260
func = function()
@@ -77,6 +65,10 @@ local et_deck = {
7765
end,
7866
}))
7967
end,
68+
draw = function(self, card)
69+
-- Ensure atlas is up to date
70+
71+
end
8072
}
8173
local sk_deck = {
8274
object_type = "Back",
@@ -87,19 +79,12 @@ local sk_deck = {
8779
edeck_type = "sticker",
8880
config = {},
8981
loc_vars = function(self, info_queue, center)
90-
local aaa,bbb,ccc
91-
if G.GAME.modifiers.cry_force_sticker and not G.GAME.viewed_back then
92-
ccc = G.GAME.modifiers.cry_force_sticker
93-
elseif self.config.cry_force_sticker then
94-
ccc = self.config.cry_force_sticker
95-
else
96-
aaa,bbb,ccc = cry_get_enchanced_deck_info()
97-
end
82+
local _, _, ccc = cry_get_enchanced_deck_info(self)
9883
if ccc == "pinned" then ccc = "pinned_left" end
9984
return { vars = { localize{type = "name_text", set = "Other", key = ccc} } }
10085
end,
10186
apply = function(self)
102-
local aaa,bbb,ccc = cry_get_enchanced_deck_info()
87+
local aaa,bbb,ccc = cry_get_enchanced_deck_info(self)
10388
G.GAME.modifiers.cry_force_sticker = ccc
10489
G.E_MANAGER:add_event(Event({
10590
func = function()
@@ -129,18 +114,11 @@ local st_deck = {
129114
pos = { x = 5, y = 2},
130115
edeck_type = "suit",
131116
loc_vars = function(self, info_queue, center)
132-
local aaa,bbb,ccc,ddd
133-
if G.GAME.modifiers.cry_force_suit and not G.GAME.viewed_back then
134-
ddd = G.GAME.modifiers.cry_force_suit
135-
elseif self.config.cry_force_suit then
136-
ddd = self.config.cry_force_suit
137-
else
138-
aaa,bbb,ccc,ddd = cry_get_enchanced_deck_info()
139-
end
117+
local _, _, _, ddd = cry_get_enchanced_deck_info(self)
140118
return { vars = { localize(ddd, 'suits_plural') } }
141119
end,
142120
apply = function(self)
143-
local aaa,bbb,ccc,ddd = cry_get_enchanced_deck_info()
121+
local aaa,bbb,ccc,ddd = cry_get_enchanced_deck_info(self)
144122
if ddd == "Spades" then
145123
G.GAME.bosses_used["bl_goad"] = 1e308
146124
elseif ddd == "Hearts" then
@@ -170,18 +148,11 @@ local sl_deck = {
170148
config = {},
171149
edeck_type = "seal",
172150
loc_vars = function(self, info_queue, center)
173-
local aaa,bbb,ccc,ddd,eee
174-
if G.GAME.modifiers.cry_force_seal and not G.GAME.viewed_back then
175-
eee = G.GAME.modifiers.cry_force_seal
176-
elseif self.config.cry_force_seal then
177-
eee = self.config.cry_force_seal
178-
else
179-
aaa,bbb,ccc,ddd,eee = cry_get_enchanced_deck_info()
180-
end
151+
local _, _, _, _, eee = cry_get_enchanced_deck_info(self)
181152
return { vars = { localize{type = "name_text", set = "Other", key = eee:lower().."_seal"} } }
182153
end,
183154
apply = function(self)
184-
local aaa,bbb,ccc,ddd,eee = cry_get_enchanced_deck_info()
155+
local aaa,bbb,ccc,ddd,eee = cry_get_enchanced_deck_info(self)
185156
G.GAME.modifiers.cry_force_seal = eee
186157
G.E_MANAGER:add_event(Event({
187158
func = function()

lib/misc.lua

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ function Blind:cry_calc_ante_gain()
515515
end
516516
return 1
517517
end
518-
function cry_get_enchanced_deck_info()
518+
function cry_get_enchanced_deck_info(deck)
519519
--only accounts for vanilla stuff at the moment (WIP)
520520
local edition, enhancement, sticker, suit, seal =
521521
("e_"..safe_get(G.PROFILES, G.SETTINGS.profile, "cry_edeck_edition")) or "e_foil",
@@ -529,7 +529,21 @@ function cry_get_enchanced_deck_info()
529529
sticker = safe_get(SMODS.Stickers,sticker) and sticker or "eternal"
530530
suit = safe_get(SMODS.Suits,suit) and suit or "Spades"
531531
seal = safe_get(G.P_SEALS,seal) and seal or "Gold"
532-
return edition, enhancement, sticker, suit, seal
532+
local ret = {
533+
edition = edition,
534+
enhancement = enhancement,
535+
sticker = sticker,
536+
suit = suit,
537+
seal = seal
538+
}
539+
for k, _ in pairs(ret) do
540+
if G.GAME.modifiers["cry_force_"..k] and not G.GAME.viewed_back then
541+
ret[k] = G.GAME.modifiers["cry_force_"..k]
542+
elseif safe_get(deck,"config","cry_force_"..k) then
543+
ret[k] = deck.config["cry_force_"..k]
544+
end
545+
end
546+
return ret.edition, ret.enhancement, ret.sticker, ret.suit, ret.seal
533547
end
534548
function Cryptid.post_process(center)
535549
if center.pools and center.pools.M then

lovely/enhanced.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ if currentBack.effect.config.cry_antimatter or currentBack.effect.config.cry_for
4141
end
4242
--todo override for current run
4343
if currentBack.effect.center.edeck_type then
44-
local edition, enhancement, sticker, suit, seal = cry_get_enchanced_deck_info()
44+
local edition, enhancement, sticker, suit, seal = cry_get_enchanced_deck_info(currentBack)
4545
if currentBack.effect.center.edeck_type == 'edition' then
4646
self.children.back:draw_shader(edition, nil, self.ARGS.send_to_shader, true)
4747
if edition == 'negative' then

0 commit comments

Comments
 (0)