mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-13 05:57:00 -04:00
enlgish language stuff for keywords
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@264 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+11
-21
@@ -156,7 +156,7 @@ init script:
|
|||||||
# step 2 : reminder text for keywords
|
# step 2 : reminder text for keywords
|
||||||
expand_keywords_rule(
|
expand_keywords_rule(
|
||||||
default_expand: { contains(match:mode, set.automatic_reminder_text, match:mode) },
|
default_expand: { contains(match:mode, set.automatic_reminder_text, match:mode) },
|
||||||
combine: { "{keyword}<atom-reminder><i> ({reminder})</i></atom-reminder>" }
|
combine: { "{keyword}<atom-reminder><i> ({process_english_hints(reminder)})</i></atom-reminder>" }
|
||||||
) +
|
) +
|
||||||
# step 3a : expand shortcut words ~ and CARDNAME
|
# step 3a : expand shortcut words ~ and CARDNAME
|
||||||
replace_rule(
|
replace_rule(
|
||||||
@@ -1035,8 +1035,7 @@ keyword:
|
|||||||
reminder: You may play this card for its madness cost at the time you discard it.
|
reminder: You may play this card for its madness cost at the time you discard it.
|
||||||
keyword:
|
keyword:
|
||||||
keyword: Threshold
|
keyword: Threshold
|
||||||
separator: dash [ - ]
|
match: Threshold - <atom-param>action</atom-param>
|
||||||
parameter: action
|
|
||||||
mode: expert
|
mode: expert
|
||||||
reminder: You have threshold as long as seven or more cards are in your graveyard.
|
reminder: You have threshold as long as seven or more cards are in your graveyard.
|
||||||
keyword:
|
keyword:
|
||||||
@@ -1053,10 +1052,9 @@ keyword:
|
|||||||
reminder: You may play this face down as a 2/2 creature for [3]. Turn it face up any time for its morph cost.
|
reminder: You may play this face down as a 2/2 creature for [3]. Turn it face up any time for its morph cost.
|
||||||
keyword:
|
keyword:
|
||||||
keyword: Amplify
|
keyword: Amplify
|
||||||
separator: whitespace [ ]
|
match: Amplify <atom-param>number</atom-param>
|
||||||
parameter: number (a, two, ...)
|
|
||||||
mode: expert
|
mode: expert
|
||||||
reminder: As this card comes into play, put {param1} +1/+1 counter(s) on it for each creature that shares a type with this that you reveal in your hand.
|
reminder: As this card comes into play, put {english_number(param1)} +1/+1 counter(s) on it for each creature that shares a type with this that you reveal in your hand.
|
||||||
keyword:
|
keyword:
|
||||||
keyword: Double strike
|
keyword: Double strike
|
||||||
mode: expert
|
mode: expert
|
||||||
@@ -1101,25 +1099,18 @@ keyword:
|
|||||||
reminder: This comes into play with {param1} +1/+1 counter(s) on it. When it’s put into a graveyard, you may put its +1/+1 counters on target artifact creature.
|
reminder: This comes into play with {param1} +1/+1 counter(s) on it. When it’s put into a graveyard, you may put its +1/+1 counters on target artifact creature.
|
||||||
keyword:
|
keyword:
|
||||||
keyword: Scry
|
keyword: Scry
|
||||||
separator: whitespace [ ]
|
match: Scry <atom-param>number</atom-param>
|
||||||
parameter: number (, two, ...)
|
|
||||||
mode: expert
|
mode: expert
|
||||||
reminder: Look at the top {param1} card(s) of your library. Put any number of them on the bottom of your library in any order and the rest on top of your library in any order.
|
reminder: Look at the top {english_number_multiple(param1)} card(s) of your library. Put any number of them on the bottom of your library in any order and the rest on top of your library in any order.
|
||||||
keyword:
|
keyword:
|
||||||
keyword: Sunburst
|
keyword: Sunburst
|
||||||
mode: expert
|
mode: expert
|
||||||
reminder: This comes into play with a +1/+1 counter on it for each color of mana used to pay its cost. If it is not a creature, use charge counters instead.
|
reminder: This comes into play with a +1/+1 counter on it for each color of mana used to pay its cost. If it is not a creature, use charge counters instead.
|
||||||
#keyword:
|
keyword:
|
||||||
keyword: Splice
|
keyword: Splice
|
||||||
match: Splice onto <atom-param>name</atom-param> <atom-param>cost</atom-param>
|
match: Splice onto <atom-param>name</atom-param> <atom-param>cost</atom-param>
|
||||||
mode: expert
|
mode: expert
|
||||||
reminder: As you play a {param1} spell, you may reveal this card from your hand and pay its splice cost. If you do, add this card’s effects to that spell.
|
reminder: As you play a {param1} spell, you may reveal this card from your hand and pay its splice cost. If you do, add this card’s effects to that spell.
|
||||||
keyword:
|
|
||||||
keyword: Splice onto Arcane
|
|
||||||
separator: whitespace [ ]
|
|
||||||
parameter: cost
|
|
||||||
mode: expert
|
|
||||||
reminder: As you play an Arcane spell, you may reveal this card from your hand and pay its splice cost. If you do, add this card’s effects to that spell.
|
|
||||||
keyword:
|
keyword:
|
||||||
keyword: Offering
|
keyword: Offering
|
||||||
separator: dash [ - ]
|
separator: dash [ - ]
|
||||||
@@ -1203,16 +1194,15 @@ keyword:
|
|||||||
reminder: This creature can’t be blocked, targeted, dealt damage, or enchanted by anything {param1}.
|
reminder: This creature can’t be blocked, targeted, dealt damage, or enchanted by anything {param1}.
|
||||||
keyword:
|
keyword:
|
||||||
keyword: Dredge
|
keyword: Dredge
|
||||||
separator: whitespace [ ]
|
match: Dredge <atom-param>number</atom-param>
|
||||||
parameter: number (one, two, ...)
|
|
||||||
mode: expert
|
mode: expert
|
||||||
reminder: As long as you have at least {param1} card(s) in your library, if you would draw a card, you may instead put exactly {param1} card(s) from the top of your library into your graveyard and return this card from your graveyard to your hand.
|
reminder: As long as you have at least {english_number(param1)} card(s) in your library, if you would draw a card, you may instead put exactly {param1} card(s) from the top of your library into your graveyard and return this card from your graveyard to your hand.
|
||||||
keyword:
|
keyword:
|
||||||
keyword: Graft
|
keyword: Graft
|
||||||
separator: whitespace [ ]
|
separator: whitespace [ ]
|
||||||
parameter: number (a, two, ...)
|
parameter: number
|
||||||
mode: expert
|
mode: expert
|
||||||
reminder: This creature comes into play with {param1} +1/+1 counter(s) on it. Whenever another creature comes into play, you may move a +1/+1 counter from this creature onto it.
|
reminder: This creature comes into play with {english_number(param1)} +1/+1 counter(s) on it. Whenever another creature comes into play, you may move a +1/+1 counter from this creature onto it.
|
||||||
keyword:
|
keyword:
|
||||||
keyword: Forecast
|
keyword: Forecast
|
||||||
separator: whitespace [ ]
|
separator: whitespace [ ]
|
||||||
|
|||||||
@@ -405,8 +405,12 @@ String KeywordDatabase::expand(const String& text,
|
|||||||
ctx.setVariable(_("input"), to_script(part));
|
ctx.setVariable(_("input"), to_script(part));
|
||||||
param = kwp.script.invoke(ctx)->toString();
|
param = kwp.script.invoke(ctx)->toString();
|
||||||
}
|
}
|
||||||
part = _("<param-") + kwp.name + _(">") + part + _("</param-") + kwp.name + _(">");
|
String param_type = replace_all(replace_all(replace_all(kwp.name,
|
||||||
param = _("<param-") + kwp.name + _(">") + param + _("</param-") + kwp.name + _(">");
|
_("("),_("-")),
|
||||||
|
_(")"),_("-")),
|
||||||
|
_(" "),_("-"));
|
||||||
|
part = _("<param-") + param_type + _(">") + part + _("</param-") + param_type + _(">");
|
||||||
|
param = _("<param-") + param_type + _(">") + param + _("</param-") + param_type + _(">");
|
||||||
ctx.setVariable(String(_("param")) << (int)(j/2), to_script(param));
|
ctx.setVariable(String(_("param")) << (int)(j/2), to_script(param));
|
||||||
}
|
}
|
||||||
total += part;
|
total += part;
|
||||||
|
|||||||
+12
-2
@@ -16,9 +16,18 @@
|
|||||||
DECLARE_POINTER_TYPE(KeywordParam);
|
DECLARE_POINTER_TYPE(KeywordParam);
|
||||||
DECLARE_POINTER_TYPE(KeywordMode);
|
DECLARE_POINTER_TYPE(KeywordMode);
|
||||||
DECLARE_POINTER_TYPE(Keyword);
|
DECLARE_POINTER_TYPE(Keyword);
|
||||||
|
DECLARE_POINTER_TYPE(ParamReferenceType);
|
||||||
class KeywordTrie;
|
class KeywordTrie;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Keyword components
|
// ----------------------------------------------------------------------------- : Keyword parameters
|
||||||
|
|
||||||
|
class ParamReferenceType {
|
||||||
|
String name; ///< Name of the parameter reference type
|
||||||
|
String description; ///< Description (for status bar)
|
||||||
|
StringScript code; ///< Code to insert into the reminder text script, input is the actual parameter name
|
||||||
|
|
||||||
|
DECLARE_REFLECTION();
|
||||||
|
};
|
||||||
|
|
||||||
/// Parameter type of keywords
|
/// Parameter type of keywords
|
||||||
class KeywordParam {
|
class KeywordParam {
|
||||||
@@ -30,7 +39,8 @@ class KeywordParam {
|
|||||||
bool optional; ///< Can this parameter be left out (a placeholder is then used)
|
bool optional; ///< Can this parameter be left out (a placeholder is then used)
|
||||||
String match; ///< Regular expression to match
|
String match; ///< Regular expression to match
|
||||||
OptionalScript script; ///< Transformation of the value for showing in the reminder text
|
OptionalScript script; ///< Transformation of the value for showing in the reminder text
|
||||||
String example; ///< Example for preview dialog
|
String example; ///< Example for the keyword editor
|
||||||
|
vector<ParamReferenceTypeP> refer_script;///< Way to refer to a parameter from the reminder text script
|
||||||
|
|
||||||
DECLARE_REFLECTION();
|
DECLARE_REFLECTION();
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -217,7 +217,7 @@ IndexMap<FieldP, ValueP>& Set::stylingDataFor(const StyleSheet& stylesheet) {
|
|||||||
if (!styling) {
|
if (!styling) {
|
||||||
styling = new_shared<Styling>();
|
styling = new_shared<Styling>();
|
||||||
styling->data.init(stylesheet.styling_fields);
|
styling->data.init(stylesheet.styling_fields);
|
||||||
} else if (!styling->unread_data.empty()) {
|
} else if (!styling->unread_data.empty() || (styling->data.empty()) && !stylesheet.styling_fields.empty()) {
|
||||||
// we delayed the reading of the data, read it now
|
// we delayed the reading of the data, read it now
|
||||||
styling->data.init(stylesheet.styling_fields);
|
styling->data.init(stylesheet.styling_fields);
|
||||||
Reader reader(new_shared1<wxStringInputStream>(styling->unread_data), _("styling data of ") + stylesheet.stylesheetName());
|
Reader reader(new_shared1<wxStringInputStream>(styling->unread_data), _("styling data of ") + stylesheet.stylesheetName());
|
||||||
|
|||||||
@@ -52,81 +52,145 @@ String english_number(int i) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// Write a number using words, use "a" for 1
|
||||||
|
String english_number_a(int i) {
|
||||||
|
if (i == 1) return _("a");
|
||||||
|
else return english_number(i);
|
||||||
|
}
|
||||||
|
/// Write a number using words, use "" for 1
|
||||||
|
String english_number_multiple(int i) {
|
||||||
|
if (i == 1) return _("");
|
||||||
|
else return english_number(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// script_english_number_*
|
||||||
|
String do_english_num(String input, String(*fun)(int)) {
|
||||||
|
if (is_substr(input, 0, _("<param-"))) {
|
||||||
|
// a keyword parameter, of the form "<param->123</param->"
|
||||||
|
size_t start = skip_tag(input, 0);
|
||||||
|
if (start != String::npos) {
|
||||||
|
size_t end = input.find_first_of(_('<'), start);
|
||||||
|
if (end != String::npos) {
|
||||||
|
String is = input.substr(start, end - start);
|
||||||
|
long i = 0;
|
||||||
|
if (is.ToLong(&i)) {
|
||||||
|
if (i == 1) {
|
||||||
|
return _("<hint-1>") + substr_replace(input, start, end, fun(i));
|
||||||
|
} else {
|
||||||
|
return _("<hint-2>") + substr_replace(input, start, end, fun(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
long i = 0;
|
||||||
|
if (input.ToLong(&i)) {
|
||||||
|
return fun(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(english_number) {
|
SCRIPT_FUNCTION(english_number) {
|
||||||
SCRIPT_PARAM(int, input);
|
SCRIPT_PARAM(String, input);
|
||||||
SCRIPT_RETURN(english_number(input));
|
SCRIPT_RETURN(do_english_num(input, english_number));
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(english_number_a) {
|
SCRIPT_FUNCTION(english_number_a) {
|
||||||
SCRIPT_PARAM(int, input);
|
SCRIPT_PARAM(String, input);
|
||||||
if (input == 1) {
|
SCRIPT_RETURN(do_english_num(input, english_number_a));
|
||||||
SCRIPT_RETURN(_("a"));
|
|
||||||
} else {
|
|
||||||
SCRIPT_RETURN(english_number(input));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
SCRIPT_FUNCTION(english_number_multiple) {
|
||||||
// ----------------------------------------------------------------------------- : A/an
|
SCRIPT_PARAM(String, input);
|
||||||
|
SCRIPT_RETURN(do_english_num(input, english_number_multiple));
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Singular/plural
|
|
||||||
|
|
||||||
SCRIPT_FUNCTION(english_singular) {
|
|
||||||
throw InternalError(_("TODO"));
|
|
||||||
}
|
|
||||||
|
|
||||||
SCRIPT_FUNCTION(english_plural) {
|
|
||||||
throw InternalError(_("TODO"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Hints
|
// ----------------------------------------------------------------------------- : Hints
|
||||||
|
|
||||||
// insert a hint, <hint-1> for singular, <hint-2> otherwise
|
bool is_vowel(Char c) {
|
||||||
SCRIPT_FUNCTION(plural_hint) {
|
return c == _('a') || c == _('e') || c == _('i') || c == _('o') || c == _('u')
|
||||||
SCRIPT_PARAM(int, input);
|
|| c == _('A') || c == _('E') || c == _('I') || c == _('O') || c == _('U');
|
||||||
SCRIPT_RETURN(input == 1 ? _("<hint-1>") : _("<hint-2>"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Process english hints in the input string
|
/// Process english hints in the input string
|
||||||
/** Hints have the following meaning:
|
/** A hint is formed by
|
||||||
* - "<hint-1>xxx(yyy)zzz" ---> "xxxzzz" (singular)
|
* 1. an insertion of a parameter, <param-..>...</param->.
|
||||||
* - "<hint-2>xxx(yyy)zzz" ---> "xxxyyyzzz" (plural)
|
* 2. a <hint-1> or <hint-2> tag
|
||||||
* - "[^., ]a <hint-v>[aeiou]" ---> "\1 an \2" (articla 'an', case insensitive)
|
*
|
||||||
* - "<hint-?>" ---> "" (remove <hint>s afterwards)
|
* Hints have the following meaning:
|
||||||
|
* - "<hint-1>xxx(yyy)zzz" ---> "xxxzzz" (singular)
|
||||||
|
* - "<hint-2>xxx(yyy)zzz" ---> "xxxyyyzzz" (plural)
|
||||||
|
* - "[^., ]a <param-..>[aeiou]" ---> "\1 an \2" (articla 'an', case insensitive)
|
||||||
|
* - "<hint-?>" ---> "" (remove <hint>s afterwards)
|
||||||
*
|
*
|
||||||
* Note: there is no close tags for hints
|
* Note: there is no close tags for hints
|
||||||
*/
|
*/
|
||||||
String process_english_hints(const String& str) {
|
String process_english_hints(const String& str) {
|
||||||
String ret; ret.reserve(str.size());
|
String ret; ret.reserve(str.size());
|
||||||
int singplur = 0; // 1 for singular, 2 for plural
|
// have we seen a <hint-1/2>?
|
||||||
|
// 1 for singular, 2 for plural
|
||||||
|
int singplur = 0;
|
||||||
for (size_t i = 0 ; i < str.size() ; ) {
|
for (size_t i = 0 ; i < str.size() ; ) {
|
||||||
Char c = str.GetChar(i);
|
Char c = str.GetChar(i);
|
||||||
if (i + 6 < str.size() && is_substr(str, i, _("<hint-"))) {
|
if (is_substr(str, i, _("<hint-"))) {
|
||||||
Char h = str.GetChar(i + 6); // hint code
|
Char h = str.GetChar(i + 6); // hint code
|
||||||
if (h == _('1')) {
|
if (h == _('1')) {
|
||||||
singplur = 1;
|
singplur = 1;
|
||||||
} else if (h == _('2')) {
|
} else if (h == _('2')) {
|
||||||
singplur = 2;
|
singplur = 2;
|
||||||
} else if (h == _('v')) {
|
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
i = skip_tag(str, i);
|
i = skip_tag(str, i);
|
||||||
|
} else if (is_substr(str, i, _("<param-"))) {
|
||||||
|
size_t after = skip_tag(str, i);
|
||||||
|
if (after != String::npos) {
|
||||||
|
Char c = str.GetChar(after);
|
||||||
|
if (is_vowel(c) && ret.size() >= 2) {
|
||||||
|
// a -> an?
|
||||||
|
// is there "a" before this?
|
||||||
|
String last = ret.substr(ret.size() - 2);
|
||||||
|
if ( (ret.size() == 2 || !isAlpha(ret.GetChar(ret.size() - 3))) &&
|
||||||
|
(last == _("a ") || last == _("A ")) ) {
|
||||||
|
ret.insert(ret.size() - 1, _('n'));
|
||||||
|
}
|
||||||
|
} else if (is_substr(str, after, _("</param-")) && ret.size() >= 1 &&
|
||||||
|
ret.GetChar(ret.size() - 1) == _(' ')) {
|
||||||
|
// empty param, drop space before it
|
||||||
|
ret.resize(ret.size() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret += c;
|
||||||
|
++i;
|
||||||
} else if (c == _('(') && singplur) {
|
} else if (c == _('(') && singplur) {
|
||||||
// singular -> drop (...), plural -> keep it
|
// singular -> drop (...), plural -> keep it
|
||||||
// TODO
|
size_t end = str.find_first_of(_(')'), i);
|
||||||
|
if (end != String::npos) {
|
||||||
|
if (singplur == 2) {
|
||||||
|
ret += str.substr(i + 1, end - i - 1);
|
||||||
|
}
|
||||||
|
i = end + 1;
|
||||||
|
} else { // handle like normal
|
||||||
|
ret += c;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
singplur = 0;
|
||||||
} else {
|
} else {
|
||||||
ret += c;
|
ret += c;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret; // TODO
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCRIPT_FUNCTION(process_english_hints) {
|
||||||
|
SCRIPT_PARAM(String, input);
|
||||||
|
SCRIPT_RETURN(process_english_hints(input));
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Init
|
// ----------------------------------------------------------------------------- : Init
|
||||||
|
|
||||||
void init_script_english_functions(Context& ctx) {
|
void init_script_english_functions(Context& ctx) {
|
||||||
ctx.setVariable(_("english number"), script_english_number);
|
ctx.setVariable(_("english number"), script_english_number);
|
||||||
ctx.setVariable(_("english number a"), script_english_number_a);
|
ctx.setVariable(_("english number a"), script_english_number_a);
|
||||||
|
ctx.setVariable(_("english number multiple"), script_english_number_multiple);
|
||||||
|
ctx.setVariable(_("process english hints"), script_process_english_hints);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user