diff --git a/content/rank/apostle.lua b/content/rank/apostle.lua index 3361d39f..c8f65b2a 100644 --- a/content/rank/apostle.lua +++ b/content/rank/apostle.lua @@ -7,7 +7,6 @@ SMODS.Rank { hc_atlas = 'ranks_hc', pos = { x = 0 }, - straight_edge = true, next = { 'Ace' }, nominal = 12, face = true, @@ -43,6 +42,5 @@ SMODS.Rank { SMODS.Rank:take_ownership('Ace', { next = { '2', 'paperback_Apostle' }, - straight_edge = false } ) diff --git a/lovely/ace_apostle_straights.toml b/lovely/ace_apostle_straights.toml deleted file mode 100644 index f4421047..00000000 --- a/lovely/ace_apostle_straights.toml +++ /dev/null @@ -1,74 +0,0 @@ -[manifest] -version = "1.0.0" -priority = 0 - -# Apostles ignore `wrap` in get_straight -[[patches]] -[patches.regex] -target = '=[SMODS _ "src/overrides.lua"]' -pattern = '(?wrap).*rank\.straight_edge.*then' -position = "at" -root_capture = "$wrap" -payload = '''(wrap and key ~= 'paperback_Apostle')''' -[[patches]] -[patches.regex] -target = '=[SMODS _ "src/overrides.lua"]' -pattern = '(?wrap).*SMODS\.Ranks\[v\]\.straight_edge.*then' -position = "at" -root_capture = "$wrap" -payload = '''(wrap and v ~= 'paperback_Apostle')''' - -# next_ranks() doesn't allow K-A-2 or Apostle-A-Apostle -# Paperback makes Ace have straight_edge = false, this fixes the side effects. -## Define helper to check -[[patches]] -[patches.pattern] -target = '=[SMODS _ "src/overrides.lua"]' -pattern = "function get_straight(*" -position = "after" -match_indent = true -payload = """ -local pb_prev_key -local function pb_is_illegal_seq(p_key, key, n_key, wrap) - return not wrap and key == 'Ace' and ( - (p_key == 'King' or p_key == 'Queen') and (n_key == '2' or n_key == '3') - or (p_key == 'paperback_Apostle') and (n_key == 'paperback_Apostle') - ) -end""" -## In next_ranks(), illegal next ranks are skipped -[[patches]] -[patches.pattern] -target = '=[SMODS _ "src/overrides.lua"]' -pattern = "ret[#ret+1] = v" -position = "before" -match_indent = true -payload = """ -if pb_is_illegal_seq(pb_prev_key, key, v, wrap) then - goto pb_continue_rank_next -end""" -[[patches]] -[patches.pattern] -target = '=[SMODS _ "src/overrides.lua"]' -pattern = """ - ret[#ret+1] = w - end -end""" -position = "at" -match_indent = false -payload = """ - if pb_is_illegal_seq(key, v, w, wrap) then - goto pb_continue_rank_next - end - ret[#ret+1] = w - end - end - ::pb_continue_rank_next::""" - -# Actually set pb_prev_key variable -[[patches]] -[patches.pattern] -target = '=[SMODS _ "src/overrides.lua"]' -pattern = "for _,l in ipairs(next_ranks(tuple[i-1], i == 2)) do" -position = "before" -match_indent = true -payload = "pb_prev_key = tuple[i-2]" diff --git a/lovely/apostle_fixes.toml b/lovely/apostle_fixes.toml new file mode 100644 index 00000000..9522041b --- /dev/null +++ b/lovely/apostle_fixes.toml @@ -0,0 +1,52 @@ +[manifest] +version = "1.0.0" +dump_lua = true +priority = 0 + +[[patches]] +[patches.pattern] +target = '=[SMODS _ "src/overrides.lua"]' +pattern = "local function next_ranks(key, start)" +position = "at" +match_indent = true +payload = ''' +local function next_ranks(key, start, from_apostle) +''' + +[[patches]] +[patches.pattern] +target = '=[SMODS _ "src/overrides.lua"]' +pattern = "if not start and not wrap and rank.straight_edge then return ret end" +position = "at" +match_indent = true +payload = ''' +if not start and not wrap and rank.straight_edge and not from_apostle then + for _, v in ipairs(rank.next) do + if v == 'paperback_Apostle' then + ret[#ret + 1] = v + end + end + return ret +end +if not start and not wrap and key == 'paperback_Apostle' then return ret end +''' + +[[patches]] +[patches.pattern] +target = '=[SMODS _ "src/overrides.lua"]' +pattern = "if skip and (wrap or not SMODS.Ranks[v].straight_edge) then" +position = "at" +match_indent = true +payload = ''' +if skip and (wrap or (not from_apostle and not SMODS.Ranks[v].straight_edge) or v ~= 'paperback_Apostle') then +''' + +[[patches]] +[patches.pattern] +target = '=[SMODS _ "src/overrides.lua"]' +pattern = "for _,l in ipairs(next_ranks(tuple[i-1], i == 2)) do" +position = "at" +match_indent = true +payload = ''' +for _,l in ipairs(next_ranks(tuple[i-1], i == 2, tuple[1] == 'paperback_Apostle')) do +'''