Skip to content

Commit a7f94aa

Browse files
author
lord-ruby
committed
fix card button stuff and add useable jokers
1 parent a4f62bd commit a7f94aa

File tree

1 file changed

+278
-1
lines changed

1 file changed

+278
-1
lines changed

Entropy/card_buttons.lua

Lines changed: 278 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,281 @@ function G.UIDEF.use_and_sell_buttons(card)
301301
}
302302
end
303303
return abc
304-
end
304+
end
305+
306+
G.FUNCS.can_reserve_joker = function(e)
307+
local c1 = e.config.ref_table
308+
if
309+
#G.jokers.cards
310+
< G.jokers.config.card_limit + (Cryptid.safe_get(c1, "edition", "negative") and 1 or 0)
311+
then
312+
e.config.colour = G.C.GREEN
313+
e.config.button = "reserve_joker"
314+
else
315+
e.config.colour = G.C.UI.BACKGROUND_INACTIVE
316+
e.config.button = nil
317+
end
318+
end
319+
G.FUNCS.reserve_joker = function(e)
320+
local c1 = e.config.ref_table
321+
G.E_MANAGER:add_event(Event({
322+
trigger = "after",
323+
delay = 0.1,
324+
func = function()
325+
local c2 = copy_card(c1, nil, nil, true, false)
326+
c1:remove()
327+
c2:add_to_deck()
328+
G.jokers:emplace(c2)
329+
SMODS.calculate_context({ pull_card = true, card = c1 })
330+
return true
331+
end,
332+
}))
333+
end
334+
335+
G.FUNCS.can_open_booster = function(e)
336+
if
337+
G.STATE == G.STATES.SELECTING_HAND or G.STATE == G.STATES.SHOP
338+
then
339+
e.config.colour = G.C.GREEN
340+
e.config.button = "open_booster"
341+
else
342+
e.config.colour = G.C.UI.BACKGROUND_INACTIVE
343+
e.config.button = nil
344+
end
345+
end
346+
G.FUNCS.open_booster = function(e)
347+
local c1 = e.config.ref_table
348+
G.GAME.DefineBoosterState = G.STATE
349+
delay(0.1)
350+
local area = c1.area
351+
if area == G.shop_vouchers then
352+
G.GAME.current_round.voucher.spawn[c1.config.center_key] = nil
353+
end
354+
if c1.ability.booster_pos then G.GAME.current_round.used_packs[c1.ability.booster_pos] = 'USED' end
355+
--draw_card(G.hand, G.play, 1, 'up', true, card, nil, true)
356+
if not c1.from_tag then
357+
G.GAME.round_scores.cards_purchased.amt = G.GAME.round_scores.cards_purchased.amt + 1
358+
end
359+
if c1.RPerkeoPack then
360+
G.RPerkeoPack = true
361+
end
362+
if G.blind_select then
363+
G.blind_select:remove()
364+
G.blind_prompt_box:remove()
365+
end
366+
e.config.ref_table.cost = 0
367+
e.config.ref_table:open()
368+
if c1.ability.cry_multiuse and to_big(c1.ability.cry_multiuse) > to_big(1) then
369+
local card = c1
370+
card.ability.cry_multiuse = card.ability.cry_multiuse - 1
371+
card.ability.extra_value = -1 * math.max(1, math.floor(card.cost/2))
372+
card:set_cost()
373+
delay(0.4)
374+
375+
-- i make my own card eval status text :D
376+
377+
card:juice_up()
378+
play_sound('generic1')
379+
attention_text({
380+
text = format_ui_value(card.ability.cry_multiuse),
381+
scale = 1.1,
382+
hold = 0.6,
383+
major = card,
384+
backdrop_colour = G.C.SET[card.config.center.set],
385+
align = 'bm',
386+
offset = {x = 0, y = 0.2}
387+
})
388+
local c2 = copy_card(c1)
389+
c2:add_to_deck()
390+
area:emplace(c2)
391+
392+
end
393+
--c1:remove()
394+
end
395+
396+
G.FUNCS.can_open_voucher = function(e)
397+
local c1 = e.config.ref_table
398+
e.config.colour = G.C.GREEN
399+
e.config.button = "open_voucher"
400+
end
401+
G.FUNCS.open_voucher = function(e)
402+
local state = G.STATE
403+
local c1 = e.config.ref_table
404+
c1.cost = 0
405+
local area = c1.area
406+
c1:redeem()
407+
c1:start_dissolve()
408+
c1:remove()
409+
if c1.ability.cry_multiuse and to_big(c1.ability.cry_multiuse) > to_big(1) then
410+
local card = c1
411+
card.ability.cry_multiuse = card.ability.cry_multiuse - 1
412+
card.ability.extra_value = -1 * math.max(1, math.floor(card.cost/2))
413+
card:set_cost()
414+
delay(0.4)
415+
416+
-- i make my own card eval status text :D
417+
418+
card:juice_up()
419+
play_sound('generic1')
420+
attention_text({
421+
text = format_ui_value(card.ability.cry_multiuse),
422+
scale = 1.1,
423+
hold = 0.6,
424+
major = card,
425+
backdrop_colour = G.C.SET[card.config.center.set],
426+
align = 'bm',
427+
offset = {x = 0, y = 0.2}
428+
})
429+
local c2 = copy_card(c1)
430+
c2:add_to_deck()
431+
area:emplace(c2)
432+
433+
end
434+
G.STATE = state
435+
end
436+
437+
G.FUNCS.can_reserve_booster = function(e)
438+
local c1 = e.config.ref_table
439+
if
440+
G.consumeables.config.card_count
441+
< G.consumeables.config.card_limit + (Cryptid.safe_get(c1, "edition", "negative") and 1 or 0)
442+
then
443+
e.config.colour = G.C.GREEN
444+
e.config.button = "reserve_booster"
445+
else
446+
e.config.colour = G.C.UI.BACKGROUND_INACTIVE
447+
e.config.button = nil
448+
end
449+
end
450+
G.FUNCS.reserve_booster = function(e)
451+
local c1 = e.config.ref_table
452+
--G.GAME.DefineBoosterState = G.STATE
453+
--c1:open()
454+
G.pack_cards:remove_card(c1)
455+
G.consumeables.cards[#G.consumeables.cards + 1] = c1
456+
c1.area = G.consumeables
457+
c1.parent = G.consumeables
458+
c1.layered_parallax = G.consumeables.layered_parallax
459+
G.consumeables:set_ranks()
460+
G.consumeables:align_cards()
461+
462+
SMODS.calculate_context({ pull_card = true, card = c1 })
463+
G.GAME.pack_choices = G.GAME.pack_choices - 1
464+
if G.GAME.pack_choices <= 0 then
465+
G.FUNCS.end_consumeable(nil, delay_fac)
466+
end
467+
if c1.ability.glitched_crown then
468+
local center = G.P_CENTERS[c1.ability.glitched_crown[c1.glitched_index]]
469+
c1:set_ability(center)
470+
c1.ability.glitched_crown = nil
471+
end
472+
--c1:remove()
473+
end
474+
475+
G.FUNCS.can_buy_deckorsleeve = function(e)
476+
local c1 = e.config.ref_table
477+
e.config.colour = G.C.GREEN
478+
e.config.button = "buy_deckorsleeve_2"
479+
end
480+
G.FUNCS.can_buy_deckorsleeve_from_shop = function(e)
481+
local c1 = e.config.ref_table
482+
if to_big(G.GAME.dollars+G.GAME.bankrupt_at) >= to_big(c1.cost) or Entropy.has_rune("rune_entr_naudiz") then
483+
e.config.colour = G.C.GREEN
484+
e.config.button = "buy_deckorsleeve_from_shop"
485+
else
486+
e.config.colour = G.C.UI.BACKGROUND_INACTIVE
487+
e.config.button = nil
488+
end
489+
end
490+
G.FUNCS.buy_deckorsleeve_from_shop = function(e)
491+
local c1 = e.config.ref_table
492+
--G.GAME.DefineBoosterState = G.STATE
493+
--c1:open()
494+
ease_dollars(-c1.cost)
495+
G.FUNCS.redeem_deckorsleeve(e)
496+
end
497+
498+
G.FUNCS.buy_deckorsleeve_2 = function(e)
499+
local c1 = e.config.ref_table
500+
--G.GAME.DefineBoosterState = G.STATE
501+
--c1:open()
502+
G.FUNCS.redeem_deckorsleeve(e)
503+
end
504+
505+
G.FUNCS.redeem_deckorsleeve = function(e)
506+
G.E_MANAGER:add_event(Event{
507+
trigger = "after",
508+
func = function()
509+
510+
local area
511+
if G.STATE == G.STATES.HAND_PLAYED then
512+
if not G.redeemed_vouchers_during_hand then
513+
G.redeemed_vouchers_during_hand =
514+
CardArea(G.play.T.x, G.play.T.y, G.play.T.w, G.play.T.h, { type = "play", card_limit = 5 })
515+
end
516+
area = G.redeemed_vouchers_during_hand
517+
else
518+
area = G.play
519+
end
520+
521+
local card = e.config.ref_table
522+
if card.config.center.key == "j_joker" then
523+
card:set_ability(G.P_CENTERS.b_red)
524+
end
525+
card.area:remove_card(card)
526+
card:add_to_deck()
527+
area:emplace(card)
528+
card.cost = 0
529+
card:redeem_deck()
530+
return true
531+
end
532+
})
533+
end
534+
535+
G.FUNCS.can_reserve_card_to_deck = function(e)
536+
local c1 = e.config.ref_table
537+
e.config.colour = G.C.GREEN
538+
e.config.button = "reserve_card_to_deck"
539+
end
540+
G.FUNCS.reserve_card_to_deck = function(e)
541+
local c1 = e.config.ref_table
542+
G.E_MANAGER:add_event(Event({
543+
trigger = "after",
544+
delay = 0.1,
545+
func = function()
546+
local c2 = copy_card(c1, nil, nil, true, false)
547+
c1:remove()
548+
c2:add_to_deck()
549+
table.insert(G.playing_cards, c2)
550+
G.deck:emplace(c2)
551+
playing_card_joker_effects({ c2 })
552+
SMODS.calculate_context({ pull_card = true, card = c1 })
553+
return true
554+
end,
555+
}))
556+
end
557+
558+
G.FUNCS.can_use_joker = function(e)
559+
local center = e.config.ref_table.config.center
560+
if
561+
center.can_use and center:can_use(e.config.ref_table) and not e.config.ref_table.debuff
562+
and G.STATE ~= G.STATES.HAND_PLAYED and G.STATE ~= G.STATES.DRAW_TO_HAND and G.STATE ~= G.STATES.PLAY_TAROT
563+
and not (((G.play and #G.play.cards > 0) or (G.CONTROLLER.locked) or (G.GAME.STOP_USE and G.GAME.STOP_USE > 0)))
564+
then
565+
e.config.colour = G.C.RED
566+
e.config.button = "use_joker"
567+
else
568+
e.config.colour = G.C.UI.BACKGROUND_INACTIVE
569+
e.config.button = nil
570+
end
571+
end
572+
G.FUNCS.use_joker = function(e)
573+
local int = G.TAROT_INTERRUPT
574+
G.TAROT_INTERRUPT = true
575+
local center = e.config.ref_table.config.center
576+
if center.use then
577+
center:use(e.config.ref_table)
578+
end
579+
e.config.ref_table:juice_up()
580+
G.TAROT_INTERRUPT = int
581+
end

0 commit comments

Comments
 (0)