Skip to content

Commit 18054fc

Browse files
Convert Energia to smods api (WIP)
Still buggy, Works properly but creates "ghost" tags that don't go away until game is reloaded todo fix
1 parent 0b57c69 commit 18054fc

File tree

3 files changed

+19
-40
lines changed

3 files changed

+19
-40
lines changed

items/exotic.lua

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,9 +1299,21 @@ local energia = {
12991299
cost = 50,
13001300
atlas = "atlasexotic",
13011301
calculate = function(self, card, context)
1302-
if context.cry_add_tag then
1303-
local value = #G.GAME.tags or 0
1304-
local t = to_number(math.min(card.ability.immutable.max_tags - value, card.ability.extra.tags))
1302+
if context.tag_added and not context.tag_added.from_energia then
1303+
-- Don't add tags if there are more then 40 (lag)
1304+
local added_tags =
1305+
math.max(math.min(card.ability.immutable.max_tags - #G.GAME.tags, card.ability.extra.tags), 0)
1306+
print(added_tags)
1307+
if added_tags > 0 then
1308+
for i = 1, added_tags do
1309+
local ab = copy_table(context.tag_added.ability)
1310+
local new_tag = Tag(context.tag_added.key)
1311+
new_tag.from_energia = true
1312+
add_tag(new_tag)
1313+
new_tag.from_energia = nil
1314+
new_tag.ability = ab
1315+
end
1316+
end
13051317
SMODS.scale_card(card, {
13061318
ref_table = card.ability.extra,
13071319
ref_value = "tags",
@@ -1310,14 +1322,12 @@ local energia = {
13101322
message = localize({
13111323
type = "variable",
13121324
key = card.ability.extra.tags == 1 and "a_tag" or "a_tags",
1313-
vars = { t },
1325+
vars = { added_tags },
13141326
})[1],
13151327
colour = G.C.DARK_EDITION,
13161328
},
13171329
})
1318-
return { tags = math.max(t, 0) }
1319-
end
1320-
if context.forcetrigger then
1330+
elseif context.forcetrigger then
13211331
SMODS.scale_card(card, {
13221332
ref_table = card.ability.extra,
13231333
ref_value = "tags",

lib/overrides.lua

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,30 +1157,8 @@ function create_card(_type, area, legendary, _rarity, skip_materialize, soulable
11571157
end
11581158

11591159
local at = add_tag
1160-
function add_tag(tag, from_skip, no_copy)
1161-
--add calculation context and callback to tag function
1162-
--used for Energia, etc.
1163-
if no_copy then
1164-
at(tag)
1165-
else
1166-
local added_tags = 1
1167-
local ret = {}
1168-
SMODS.calculate_context({ cry_add_tag = true }, ret)
1169-
for i = 1, #ret do
1170-
if ret[i].jokers then
1171-
added_tags = added_tags + (ret[i].jokers.tags or 0)
1172-
end
1173-
end
1174-
if added_tags >= 1 then
1175-
at(tag)
1176-
end
1177-
for i = 2, added_tags do
1178-
local ab = copy_table(G.GAME.tags[#G.GAME.tags].ability)
1179-
local new_tag = Tag(tag.key)
1180-
at(new_tag)
1181-
new_tag.ability = ab
1182-
end
1183-
end
1160+
function add_tag(tag)
1161+
at(tag)
11841162
-- Update Costs for Clone Tag
11851163
if tag.name == "cry-Clone Tag" then
11861164
for k, v in pairs(G.I.CARD) do

lovely/misc.toml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,6 @@ add_tag(tag_key and Tag(tag_key) or _tag.config.ref_table, true)
251251
'''
252252
match_indent = true
253253

254-
# Energia - don't add tags from save load
255-
[[patches]]
256-
[patches.pattern]
257-
target = "game.lua"
258-
pattern = '''add_tag(_tag)'''
259-
position = "at"
260-
payload = '''add_tag(_tag, nil, true)'''
261-
match_indent = true
262-
263254
# Beta Deck - merge slots
264255
[[patches]]
265256
[patches.pattern]

0 commit comments

Comments
 (0)