Skip to content

Commit 4d8bdb9

Browse files
set_cost fixes
- Fixed Clone Tag not updating costs on obtain - Fixed Coupon Tag not making Big cube Free - Fixed incorrect sell values of cards in certain situations
1 parent 4875d24 commit 4d8bdb9

File tree

3 files changed

+60
-58
lines changed

3 files changed

+60
-58
lines changed

items/spooky.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,14 +1238,18 @@ local rotten_egg = {
12381238
no_dbl = true,
12391239
add_to_deck = function(self, card, from_debuff)
12401240
G.GAME.cry_rotten_amount = card.ability.extra.starting_money
1241-
for i, v in pairs(G.jokers.cards) do
1242-
v:set_cost()
1241+
for k, v in pairs(G.I.CARD) do
1242+
if v.set_cost then
1243+
v:set_cost()
1244+
end
12431245
end
12441246
end,
12451247
remove_from_deck = function()
12461248
G.GAME.cry_rotten_amount = nil
1247-
for i, v in pairs(G.jokers.cards) do
1248-
v:set_cost()
1249+
for k, v in pairs(G.I.CARD) do
1250+
if v.set_cost then
1251+
v:set_cost()
1252+
end
12491253
end
12501254
end,
12511255
calculate = function(self, card, context)

items/tag.lua

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,20 +1477,6 @@ local clone = {
14771477
end
14781478
return r
14791479
end
1480-
local set_costref = Card.set_cost
1481-
function Card:set_cost(...)
1482-
local c = set_costref(self, ...)
1483-
local has
1484-
for i = 1, #G.GAME.tags do
1485-
if G.GAME.tags[i].key == "tag_cry_clone" then
1486-
has = true
1487-
break
1488-
end
1489-
end
1490-
if has then
1491-
self.cost = self.cost * 1.5
1492-
end
1493-
end
14941480
end,
14951481
}
14961482

lib/overrides.lua

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,10 @@ function Card:set_cost()
572572
self.cost = 27
573573
end
574574
--Make Tarots free if Tarot Acclimator is redeemed
575+
--Make Planets free if Planet Acclimator is redeemed
575576
if self.ability.set == "Tarot" and G.GAME.used_vouchers.v_cry_tacclimator then
576577
self.cost = 0
577578
end
578-
--Make Planets free if Planet Acclimator is redeemed
579579
if self.ability.set == "Planet" and G.GAME.used_vouchers.v_cry_pacclimator then
580580
self.cost = 0
581581
end
@@ -584,23 +584,33 @@ function Card:set_cost()
584584
--Used by bronze stake to make vouchers %50 more expensive
585585
if self.ability.set == "Voucher" and G.GAME.modifiers.cry_voucher_price_hike then
586586
self.cost = math.floor(self.cost * G.GAME.modifiers.cry_voucher_price_hike)
587-
--Update related costs
588-
self.sell_cost = math.max(1, math.floor(self.cost / 2)) + (self.ability.extra_value or 0)
589-
if self.area and self.ability.couponed and (self.area == G.shop_jokers or self.area == G.shop_booster) then
590-
self.cost = 0
587+
end
588+
--Clone Tag
589+
for i = 1, #G.GAME.tags do
590+
if G.GAME.tags[i].key == "tag_cry_clone" then
591+
self.cost = self.cost * 1.5
592+
break
591593
end
592-
self.sell_cost_label = self.facing == "back" and "?" or self.sell_cost
593594
end
594595

596+
--Update related costs
597+
self.sell_cost = math.max(1, math.floor(self.cost / 2)) + (self.ability.extra_value or 0)
598+
if
599+
self.area
600+
and self.ability.couponed
601+
and (self.area == G.shop_jokers or self.area == G.shop_booster)
602+
and self.ability.name ~= "cry-Cube"
603+
then
604+
self.cost = 0
605+
end
595606
--Makes Cursed Jokers always sell for $0
596607
if self.config and self.config.center and self.config.center.rarity == "cry_cursed" then
597608
self.sell_cost = 0
598-
self.sell_cost_label = 0
599609
--Rotten Egg
600610
elseif G.GAME.cry_rotten_amount then
601611
self.sell_cost = G.GAME.cry_rotten_amount
602-
self.sell_cost_label = self.facing == "back" and "?" or number_format(self.sell_cost)
603612
end
613+
self.sell_cost_label = self.facing == "back" and "?" or self.sell_cost
604614
end
605615

606616
local sell_card_stuff = Card.sell_card
@@ -632,7 +642,6 @@ function Card:sell_card()
632642
end
633643
end
634644
end
635-
--G.P_CENTERS.j_jolly
636645
sell_card_stuff(self)
637646
end
638647

@@ -1139,11 +1148,41 @@ function create_card(_type, area, legendary, _rarity, skip_materialize, soulable
11391148
return card
11401149
end
11411150

1142-
-- Make tags fit if there's more than 13 of them
1143-
-- These two overrides modify the offset to squeeze in more tags when needed
11441151
local at = add_tag
1145-
function add_tag(tag)
1146-
at(tag)
1152+
function add_tag(tag, from_skip, no_copy)
1153+
--add calculation context and callback to tag function
1154+
--used for Energia, etc.
1155+
if no_copy then
1156+
at(tag)
1157+
else
1158+
local added_tags = 1
1159+
local ret = {}
1160+
SMODS.calculate_context({ cry_add_tag = true }, ret)
1161+
for i = 1, #ret do
1162+
if ret[i].jokers then
1163+
added_tags = added_tags + (ret[i].jokers.tags or 0)
1164+
end
1165+
end
1166+
if added_tags >= 1 then
1167+
at(tag)
1168+
end
1169+
for i = 2, added_tags do
1170+
local ab = copy_table(G.GAME.tags[#G.GAME.tags].ability)
1171+
local new_tag = Tag(tag.key)
1172+
at(new_tag)
1173+
new_tag.ability = ab
1174+
end
1175+
end
1176+
-- Update Costs for Clone Tag
1177+
if tag.name == "cry-Clone Tag" then
1178+
for k, v in pairs(G.I.CARD) do
1179+
if v.set_cost then
1180+
v:set_cost()
1181+
end
1182+
end
1183+
end
1184+
-- Make tags fit if there's more than 13 of them
1185+
-- This + Tag.remove Hook modify the offset to squeeze in more tags when needed
11471186
if #G.HUD_tags > 13 then
11481187
for i = 2, #G.HUD_tags do
11491188
G.HUD_tags[i].config.offset.y = 0.9 - 0.9 * 13 / #G.HUD_tags
@@ -1161,33 +1200,6 @@ function Tag:remove()
11611200
end
11621201
end
11631202

1164-
--add calculation context and callback to tag function
1165-
--used for Energia, etc.
1166-
local at2 = add_tag
1167-
function add_tag(tag, from_skip, no_copy)
1168-
if no_copy then
1169-
at2(tag)
1170-
return
1171-
end
1172-
local added_tags = 1
1173-
local ret = {}
1174-
SMODS.calculate_context({ cry_add_tag = true }, ret)
1175-
for i = 1, #ret do
1176-
if ret[i].jokers then
1177-
added_tags = added_tags + (ret[i].jokers.tags or 0)
1178-
end
1179-
end
1180-
if added_tags >= 1 then
1181-
at2(tag)
1182-
end
1183-
for i = 2, added_tags do
1184-
local ab = copy_table(G.GAME.tags[#G.GAME.tags].ability)
1185-
local new_tag = Tag(tag.key)
1186-
at2(new_tag)
1187-
new_tag.ability = ab
1188-
end
1189-
end
1190-
11911203
local nr = new_round
11921204
function new_round()
11931205
-- I don't remember exactly what this patch was for, perhaps issues with syncing hand size with jokers like Effarcire?

0 commit comments

Comments
 (0)