Merge pull request #10 from G-e-n-e-v-e-n-s-i-S/get-card-styling

add get_card_styling function for export scripts
This commit is contained in:
GenevensiS
2024-09-17 07:38:14 +02:00
committed by GitHub
4 changed files with 34 additions and 3 deletions
+13 -1
View File
@@ -662,6 +662,17 @@ SCRIPT_FUNCTION(random_select_many) {
return ret;
}
SCRIPT_FUNCTION(get_card_styling) {
SCRIPT_PARAM_C(ScriptValueP, input);
SCRIPT_PARAM_C(ScriptValueP, set);
ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(input.get());
ScriptObject<Set*>* s = dynamic_cast<ScriptObject<Set*>*>(set.get());
if (s && c) {
return to_script(&s->getValue()->stylingDataFor(c->getValue()));
}
throw ScriptError(_("invalid set or card argument"));
}
// ----------------------------------------------------------------------------- : Keywords
@@ -747,7 +758,8 @@ void init_script_basic_functions(Context& ctx) {
ctx.setVariable(_("to_color"), script_to_color);
ctx.setVariable(_("to_date"), script_to_date);
ctx.setVariable(_("to_code"), script_to_code);
ctx.setVariable(_("type_name"), script_type_name);
ctx.setVariable(_("type_name"), script_type_name);
ctx.setVariable(_("get_card_styling"), script_get_card_styling);
// math
ctx.setVariable(_("abs"), script_abs);
ctx.setVariable(_("random_real"), script_random_real);