From e8877d0ceb0e9098227c1383d70ded32575ff391 Mon Sep 17 00:00:00 2001
From: cajun <12363371+CajunAvenger@users.noreply.github.com>
Date: Sun, 12 Oct 2025 00:41:38 -0500
Subject: [PATCH] improve autorem
fix bug where Class reminder text was used on creatures with class types
move Room priority above hybrid
energy fallback now overrules auto_reminder()'s input
added similar hybrid fallback
New hierarchy is as follows:
1. The first hybrid symbol in a paragraph where it's at the end of the line
2. A string of energy symbols immediately preceding it
3. Saga, Class, or Room reminder text for relevant types, in that order
4. The first hybrid symbol in the relevant casting cost field.
---
data/magic.mse-game/script | 81 +++++++++++++++++++++++---------------
1 file changed, 50 insertions(+), 31 deletions(-)
diff --git a/data/magic.mse-game/script b/data/magic.mse-game/script
index 83dfdcf85..a769fbda4 100644
--- a/data/magic.mse-game/script
+++ b/data/magic.mse-game/script
@@ -1536,18 +1536,18 @@ auto_reminder := {
level := filter_text(input, match:"[0-9]+")
if level == "" then level := "1"
tag := name_tag_for_level(to_number(level))
- type_field := card["type"+tag]
+ type_field := remove_tags(card["type"+tag])
cost_field := card["casting_cost"+tag]
if custom_auto_reminder()
- then custom_auto_reminder()
+ then custom_auto_reminder(input)
else if lang_setting("is_saga")(type_field)
then saga_reminder_script(tag:tag)
else if lang_setting("is_class")(type_field)
then "(Gain the next level as a sorcery to add its ability.)"
- else if contains(cost_field, match:"/")
- then hybrid_reminder(cost_field)
else if lang_setting("is_room")(type_field)
then "(You may cast either half. That door unlocks on the battlefield. As a sorcery, you may pay the mana cost of a locked door to unlock it.)"
+ else if contains(cost_field, match:"/")
+ then hybrid_reminder(cost_field)
else ""
}
saga_map := [
@@ -1590,23 +1590,28 @@ hybrid_reminder := {
input,
match:"(([^ ])/([^ ])(?:/([^ ]))?).*", ## _1 hybrid, _2 sym1, _3 sym2, _4 sym3
replace: {
- if _4 != "" then (
- if _2 == "2" then
- "({_1} can be paid with any two mana, {_3}, or {_4}. This card's mana value is {english_number(cmc(input))}.)"
- else if _2 == "H" then
- "({_1} can be paid with {_3}, {_4}, or 2 life.)"
- else "({_1} can be paid with either {_2}, {3}, or {3}.)"
- )
- else (
- if _2 == "2" then
- "({_1} can be paid with any two mana or with {_3}. This card's mana value is {english_number(cmc(input))}.)"
- else if _2 == "H" then
- "({_1} can be paid with either {_3} or 2 life.)"
- else "({_1} can be paid with either {_2} or {_3}.)"
- )
+ hybrid_reminder_delooper(symbol:_1, hyb1:_2, hyb2:_3, hyb3:_4)
}
)
}
+## split into its own function to avoid replace() loops with autoreminder
+## hybrid_reminder_delooper(symbol:"H/R/W", hyb1:"H", hyb2:"R", hyb3:"W")
+hybrid_reminder_delooper := {
+ if hyb3 != "" then (
+ if hyb1 == "2" then
+ "({symbol} can be paid with any two mana, {hyb2}, or {hyb3}. This card's mana value is {english_number(cmc(input))}.)"
+ else if hyb1 == "H" then
+ "({symbol} can be paid with {hyb2}, {hyb3}, or 2 life.)"
+ else "({symbol} can be paid with either {hyb1}, {3}, or {3}.)"
+ )
+ else (
+ if hyb1 == "2" then
+ "({symbol} can be paid with any two mana or with {hyb2}. This card's mana value is {english_number(cmc(input))}.)"
+ else if hyb1 == "H" then
+ "({symbol} can be paid with either {hyb2} or 2 life.)"
+ else "({symbol} can be paid with either {hyb1} or {hyb2}.)"
+ )
+}
#### these are considered a correct 'word' for spellchecking in the text box:
additional_text_words := match@(match:
"(?ix)^(?: #### match whole word
@@ -1848,18 +1853,6 @@ text_filter :=
tag: "",
contents: { "" + (if card_name=="" then "LEGENDNAME" else legend_filter(strip_card_codes(card_name, atom:true))) + "" }
) +
- tag_contents@(
- tag: ""
- contents: { auto_reminder(margin_code) }
- ) +
- replace@(
- match:"(E+)()? ",
- replace: {
- num := english_number(length(_1))
- str := if num == "one" then "an energy counter" else num + " energy counters"
- _1 + _2 + " ({str})"
- }
- ) +
replace@(
match: "INS([1-9])",
in_context: "(^|[[:space:]]|\\(|,|\\.|:|“|\"|'|‘|/|)",
@@ -1910,7 +1903,33 @@ text_filter :=
match: "\\[[-+=]?[VHSCEKPLOTQ\\?XYZIWUBRG0-9/|]+\\]",
replace: {"" + mana_filter_t() + ""}
) +
- #### step 6 : curly quotes
+ #### step 6a : auto reminder
+ #### default to subtype or mana cost rt
+ tag_contents@(
+ tag: ""
+ contents: { auto_reminder(margin_code) }
+ ) +
+ #### overrule if immediately after a string of energy symbols
+ replace@(
+ match:"(E+)()? [^\n]*?",
+ replace: {
+ num := english_number(length(_1))
+ str := if num == "one" then "an energy counter" else num + " energy counters"
+ _1 + _2 + " ({str})"
+ }
+ ) +
+ #### overrule if at the end of a paragraph with a hybrid mana symbol
+ replace@(
+ match:"()([^]*(([^ ])/([^ ])(?:/?([^ ])?))[^<]*)([^\n]+) ([^\n]*?)$",
+ replace: {
+ # _1 remaining string, _8 eaten autorem
+ # eaten autorem may have legitimate strings, R/W: You get EE **. ** -> R/W: You get EE (R/W can be paid with either R or W.)
+ # (two energy counters).
+ extra := if contains(_8, match:"atom-autorem") then "" + substring(_8, end:length(_8)-length("")) else ""
+ _1 + _2 + _7 + extra + " {hybrid_reminder_delooper(symbol:_3, hyb1:_4, hyb2:_5, hyb3:_6)}"
+ }
+ ) +
+ #### step 6b : curly quotes
{
if set.curly_quotes then curly_quotes(input) else input
} +