Skip to content

Commit 22ef3e2

Browse files
authored
Fix Orbital Tag missing poker hand, expand add_tag function (#1007)
* `SMODS.smart_add_tag` * Initialize `G.GAME.orbital_choices` I should've tested it earlier. * Add assertion * Revise LSP def * Move util function to patch/override `add_tag` now accepts a table input. * Remove default `blind_type`
1 parent f4f29d9 commit 22ef3e2

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

lovely/tag.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,30 @@ payload = '''
3939
end
4040
'''
4141

42+
# Orbital Tag's set_ability
43+
# Initialize fallback Poker Hand
44+
[[patches]]
45+
[patches.pattern]
46+
target = "tag.lua"
47+
pattern = '''
48+
elseif self.ability.blind_type then
49+
if G.GAME.orbital_choices and G.GAME.orbital_choices[G.GAME.round_resets.ante][self.ability.blind_type] then
50+
self.ability.orbital_hand = G.GAME.orbital_choices[G.GAME.round_resets.ante][self.ability.blind_type]
51+
end
52+
end
53+
'''
54+
position = 'after'
55+
match_indent = true
56+
payload = '''
57+
if self.ability.orbital_hand == '['..localize('k_poker_hand')..']' then
58+
local _poker_hands = {}
59+
for k, v in pairs(G.GAME.hands) do
60+
if SMODS.is_poker_hand_visible(k) then _poker_hands[#_poker_hands+1] = k end
61+
end
62+
self.ability.orbital_hand = pseudorandom_element(_poker_hands, pseudoseed('orbital'))
63+
end
64+
'''
65+
4266
# create_UIBox_your_collection_tags()
4367
[[patches]]
4468
[patches.regex]

src/overrides.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,4 +2410,15 @@ function Card:set_ability(center, initial, delay_sprites)
24102410
if not initial and G.STATE ~= G.STATES.SMODS_BOOSTER_OPENED and G.STATE ~= G.STATES.SHOP and not G.SETTINGS.paused or G.TAROT_INTERRUPT then
24112411
SMODS.calculate_context({setting_ability = true, old = old_center.key, new = self.config.center_key, other_card = self, unchanged = old_center.key == self.config.center.key})
24122412
end
2413+
end
2414+
2415+
local add_tag_ref = add_tag
2416+
function add_tag(_tag)
2417+
_tag = _tag or {}
2418+
_tag.key = _tag.key or 'unknown'
2419+
assert(G.P_TAGS[_tag.key], ("Could not find tag \"%s\"."):format(_tag.key))
2420+
if not (_tag.is and _tag:is(Tag)) then
2421+
_tag = Tag(_tag.key, nil, _tag.blind_type)
2422+
end
2423+
add_tag_ref(_tag)
24132424
end

0 commit comments

Comments
 (0)