From 3ed192982530a6f7febff973f2dd52506ccebd70 Mon Sep 17 00:00:00 2001 From: Emik Date: Mon, 17 Mar 2025 13:46:29 +0100 Subject: [PATCH] Allow joker merging --- localization/en-us.lua | 11 ++++---- manifest.json | 2 +- src/joker.lua | 60 +++++++++++++++++++++++++++++++++--------- 3 files changed, 55 insertions(+), 18 deletions(-) diff --git a/localization/en-us.lua b/localization/en-us.lua index 6e30ff1..408f987 100644 --- a/localization/en-us.lua +++ b/localization/en-us.lua @@ -10,15 +10,16 @@ return { "for each destroyed object", "{C:inactive}(Currently #2#)", " ", - "{C:inactive,s:0.75,E:1}#3#{C:red,s:1.5,E:1}#4#", - "{C:inactive,s:0.75,E:1}#5#{C:red,s:1.5,E:1}#6#", + "#3#{C:inactive,s:0.75,E:1}#4#{C:red,s:1.5,E:1}#5#", + "#6#{C:blue,E:1}#7#{}#8#{C:inactive,s:0.75,E:1}#9#{C:red,s:1.5,E:1}#10#", }, + merge = {"Since no objects apply, merge", "with other ", " jokers"}, quotes = { marble = {{"there is no escape..."}}, normal = { - {"I can't wait to work with you!"}, - {"Did you need something from me?"}, - {"Oh! I'm just so happy to see you!"}, + {"I can't wait to", "work with you!"}, + {"Did you need something", "from me?"}, + {"Oh! I'm just so", "happy to see you!"}, {"Can I talk about something irrelevant?", "I promise it won't be long."}, {"Can you introduce me to your friends?", "Assuming you have friends of course!"}, }, diff --git a/manifest.json b/manifest.json index ac0aad3..bb13b5a 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "Roland", "prefix": "Roland", "author": ["Emik"], - "version": "0.0.1", + "version": "0.1.0", "badge_colour": "8BE9FD", "main_file": "src/main.lua", "badge_text_colour": "44475A", diff --git a/src/joker.lua b/src/joker.lua index 3a9566d..687c1eb 100644 --- a/src/joker.lua +++ b/src/joker.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: missing-parameter local function common_hand() return (G.GAME or {}).current_round and F.reduce( G.GAME.hands, @@ -14,6 +15,14 @@ local function destructible(card) return not card.highlighted and not (card.ability or {}).eternal end +local function is_mergeable_with(it) + return function (card) + return it.rank ~= card.rank and + card.label == 'j_Roland_Escapey' and not + (card.ability or {}).eternal + end +end + SMODS.Atlas { key = "Escapey", path = "Escapey.png", @@ -35,25 +44,55 @@ SMODS.Joker { eternal_compat = true, perishable_compat = true, blueprint_compat = false, - loc_vars = function(_, _, center) - local quotes = G.localization.descriptions.Joker.j_Roland_Escapey.quotes - local normal = (Jen or {}).sinister and {} or quotes.normal[math.random(#quotes.normal)] - local scared = (Jen or {}).sinister and quotes.scared[math.random(#quotes.scared)] or {} + loc_vars = function(_, _, card) + local loc_self = G.localization.descriptions.Joker.j_Roland_Escapey + local quotes = loc_self.quotes + local merge = G.jokers and F.count(F.filter(G.jokers.cards, is_mergeable_with(card))) > 1 and loc_self.merge or {} + local normal = (merge[1] or (Jen or Jane or {}).sinister) and {} or quotes.normal[math.random(#quotes.normal)] + local scared = (merge[1] or not (Jen or Jane or {}).sinister) and {} or quotes.normal[math.random(#quotes.normal)] return {vars = { - center.ability.extra.level_up_by, + card.ability.extra.level_up_by, localize(common_hand(), "poker_hands"), + merge[1] or "", normal[1] or "", scared[1] or "", + merge[2] or "", + merge[3] and loc_self.name or "", + merge[3] or "", normal[2] or "", - scared[2] or "" + scared[2] or "", }} end, Bakery_can_use = function(_, card) - return not card.debuff and (#G.GAME.tags ~= 0 or F.any(G.consumeables.cards, destructible)) + return not card.debuff and ( + #G.GAME.tags ~= 0 or + F.any(G.consumeables.cards, destructible) or + F.any(F.filter(G.jokers.cards, is_mergeable_with(card))) + ) + end, + Bakery_use_button_text = function(_, card) + return card.debuff and "DEBUFFED" or + ((#G.GAME.tags == 0 and not + F.any(G.consumeables.cards, destructible) and + F.any(F.filter(G.jokers.cards, is_mergeable_with(card)))) and "MERGE" or "ESCAPE") end, Bakery_use_joker = function(_, card) - local hand, destroyed = common_hand(), 0 + local hand, object_count = common_hand(), F.count(F.filter(G.consumeables.cards, destructible)) + #G.GAME.tags + + if object_count == 0 then + local sum = 0 + + F.foreach( + F.filter(G.jokers.cards, is_mergeable_with(card)), + function (v) + sum = sum + v.ability.extra.level_up_by + v:start_dissolve({HEX("57ecab")}, nil, 1.6) + end + ) + + card.ability.extra.level_up_by = card.ability.extra.level_up_by + sum + end local function update(name, chip, mul, lv, notif, snd, vol, pit, de) update_hand_text({ @@ -105,7 +144,6 @@ SMODS.Joker { F.filter(G.consumeables.cards, destructible), function (v) v:start_dissolve({HEX("57ecab")}, nil, 1.6) - destroyed = destroyed + 1 end ) @@ -113,18 +151,16 @@ SMODS.Joker { G.GAME.tags, function (v) G.E_MANAGER:add_event(Event({trigger = "immediate", func = fast_nope(v)})) - destroyed = destroyed + 1 end ) - level_up_hand(card, hand, nil, destroyed * card.ability.extra.level_up_by) + level_up_hand(card, hand, nil, object_count * card.ability.extra.level_up_by) update_hand_text( {sound = "button", volume = 0.7, pitch = 1.1, delay = 0}, {mult = 0, chips = 0, handname = "", level = ""} ) end, - Bakery_use_button_text = function(_, _) return "ESCAPE" end } Bakery_API.usable_jokers.j_Roland_Escapey = true