Skip to content

Commit 0dd212f

Browse files
committed
fix multiuse class, exploit, and variable being infinitely usable
1 parent a06f3b7 commit 0dd212f

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

items/code.lua

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,15 +1036,19 @@ local exploit = {
10361036
return true
10371037
end,
10381038
use = function(self, card, area, copier)
1039+
-- Un-use the card (re-use code is in lib/misc.lua)
10391040
if not card.ability.cry_multiuse or to_big(card.ability.cry_multiuse) <= to_big(1) then
10401041
G.GAME.CODE_DESTROY_CARD = copy_card(card)
10411042
G.consumeables:emplace(G.GAME.CODE_DESTROY_CARD)
1042-
else
1043-
G.GAME.CODE_DESTROY_CARD = card
1043+
G.GAME.CODE_DESTROY_CARD.ability.cry_multiuse = nil
1044+
end
1045+
if card.ability.cry_multiuse then
10441046
card.ability.cry_multiuse = card.ability.cry_multiuse + 1
10451047
end
1048+
10461049
G.GAME.USING_CODE = true
10471050
G.GAME.USING_EXPLOIT = true
1051+
G.GAME.ACTIVE_CODE_CARD = G.GAME.CODE_DESTROY_CARD or card
10481052
G.FUNCS.overlay_menu({ definition = G.UIDEF.exploit_menu() })
10491053
end,
10501054
}
@@ -3121,14 +3125,18 @@ local class = {
31213125
return { vars = { Cryptid.safe_get(card, "ability", "max_highlighted") or self.config.max_highlighted } }
31223126
end,
31233127
use = function(self, card, area, copier)
3128+
-- Un-use the card
31243129
if not card.ability.cry_multiuse or to_big(card.ability.cry_multiuse) <= to_big(1) then
31253130
G.GAME.CODE_DESTROY_CARD = copy_card(card)
31263131
G.consumeables:emplace(G.GAME.CODE_DESTROY_CARD)
3127-
else
3132+
G.GAME.CODE_DESTROY_CARD.ability.cry_multiuse = nil
3133+
end
3134+
if card.ability.cry_multiuse then
31283135
card.ability.cry_multiuse = card.ability.cry_multiuse + 1
31293136
end
31303137
G.GAME.USING_CODE = true
31313138
G.GAME.USING_CLASS = card.ability.max_highlighted
3139+
G.GAME.ACTIVE_CODE_CARD = G.GAME.CODE_DESTROY_CARD or card
31323140
G.FUNCS.overlay_menu({ definition = create_UIBox_class() })
31333141
end,
31343142
init = function(self)
@@ -3152,10 +3160,15 @@ local class = {
31523160
end
31533161
G.hand:unhighlight_all()
31543162
ccl(self)
3155-
if G.GAME.CODE_DESTROY_CARD then
3156-
G.GAME.CODE_DESTROY_CARD:start_dissolve()
3157-
G.GAME.CODE_DESTROY_CARD = nil
3163+
-- Re-use the card
3164+
if G.GAME.ACTIVE_CODE_CARD then
3165+
if not G.GAME.ACTIVE_CODE_CARD.ability.cry_multiuse or to_big(G.GAME.ACTIVE_CODE_CARD.ability.cry_multiuse) <= to_big(1) then
3166+
G.GAME.ACTIVE_CODE_CARD:start_dissolve()
3167+
else
3168+
G.GAME.ACTIVE_CODE_CARD.ability.cry_multiuse = lenient_bignum(to_big(G.GAME.ACTIVE_CODE_CARD.ability.cry_multiuse) - to_big(1))
3169+
end
31583170
end
3171+
G.GAME.ACTIVE_CODE_CARD = nil
31593172
end
31603173
else
31613174
ccl(self)
@@ -3347,14 +3360,18 @@ local variable = {
33473360
return { vars = { Cryptid.safe_get(card, "ability", "max_highlighted") or self.config.max_highlighted } }
33483361
end,
33493362
use = function(self, card, area, copier)
3363+
-- Un-use the card
33503364
if not card.ability.cry_multiuse or to_big(card.ability.cry_multiuse) <= to_big(1) then
33513365
G.GAME.CODE_DESTROY_CARD = copy_card(card)
33523366
G.consumeables:emplace(G.GAME.CODE_DESTROY_CARD)
3353-
else
3367+
G.GAME.CODE_DESTROY_CARD.ability.cry_multiuse = nil
3368+
end
3369+
if card.ability.cry_multiuse then
33543370
card.ability.cry_multiuse = card.ability.cry_multiuse + 1
33553371
end
33563372
G.GAME.USING_CODE = true
33573373
G.GAME.USING_VARIABLE = card.ability.max_highlighted
3374+
G.GAME.ACTIVE_CODE_CARD = G.GAME.CODE_DESTROY_CARD or card
33583375
G.FUNCS.overlay_menu({ definition = create_UIBox_variable_code() })
33593376
end,
33603377
init = function(self)
@@ -3378,10 +3395,15 @@ local variable = {
33783395
end
33793396
G.hand:unhighlight_all()
33803397
ccl(self)
3381-
if G.GAME.CODE_DESTROY_CARD then
3382-
G.GAME.CODE_DESTROY_CARD:start_dissolve()
3383-
G.GAME.CODE_DESTROY_CARD = nil
3398+
-- Re-use the card
3399+
if G.GAME.ACTIVE_CODE_CARD then
3400+
if not G.GAME.ACTIVE_CODE_CARD.ability.cry_multiuse or to_big(G.GAME.ACTIVE_CODE_CARD.ability.cry_multiuse) <= to_big(1) then
3401+
G.GAME.ACTIVE_CODE_CARD:start_dissolve()
3402+
else
3403+
G.GAME.ACTIVE_CODE_CARD.ability.cry_multiuse = lenient_bignum(to_big(G.GAME.ACTIVE_CODE_CARD.ability.cry_multiuse) - to_big(1))
3404+
end
33843405
end
3406+
G.GAME.ACTIVE_CODE_CARD = nil
33853407
end
33863408
else
33873409
ccl(self)

lib/misc.lua

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,8 +1165,8 @@ G.FUNCS.exit_overlay_menu_code = function(e)
11651165
and G.GAME.CODE_DESTROY_CARD.ability.cry_multiuse
11661166
then
11671167
G.GAME.CODE_DESTROY_CARD.ability.cry_multiuse = G.GAME.CODE_DESTROY_CARD.ability.cry_multiuse - 1
1168-
G.GAME.CODE_DESTROY_CARD = nil
11691168
end
1169+
G.GAME.CODE_DESTROY_CARD = nil
11701170
end
11711171

11721172
function G.UIDEF.exploit_menu()
@@ -1215,10 +1215,15 @@ function Controller:L_cursor_press(x, y)
12151215
and G.CONTROLLER.cursor_hover.target.config.on_demand_tooltip.filler.args
12161216
and G.GAME.hands[G.CONTROLLER.cursor_hover.target.config.on_demand_tooltip.filler.args]
12171217
then
1218-
if G.GAME.CODE_DESTROY_CARD then
1219-
G.GAME.CODE_DESTROY_CARD:start_dissolve()
1220-
G.GAME.CODE_DESTROY_CARD = nil
1218+
-- Re-use the Exploit card
1219+
if G.GAME.ACTIVE_CODE_CARD then
1220+
if not G.GAME.ACTIVE_CODE_CARD.ability.cry_multiuse or to_big(G.GAME.ACTIVE_CODE_CARD.ability.cry_multiuse) <= to_big(1) then
1221+
G.GAME.ACTIVE_CODE_CARD:start_dissolve()
1222+
else
1223+
G.GAME.ACTIVE_CODE_CARD.ability.cry_multiuse = lenient_bignum(to_big(G.GAME.ACTIVE_CODE_CARD.ability.cry_multiuse) - to_big(1))
1224+
end
12211225
end
1226+
G.GAME.ACTIVE_CODE_CARD = nil
12221227
G.GAME.cry_exploit_override = G.GAME.USING_EXPLOIT_HAND
12231228
G.FUNCS.exit_overlay_menu_code()
12241229
end

0 commit comments

Comments
 (0)