Files
magic-set-editor-fork/data/magic.mse-game/script
2024-05-26 04:14:58 -05:00

4653 lines
206 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#### Localization
#### Common files
#### Versioning
#### Common filters
#### Utility scripts
#### Card characteristics
#### Sorting mana symbols
#### Mainframe mana
#### Determine card color
#### Card number
#### Statistics utilities
#### Keyword utilities
#### The text box
#### Face code
#### Level margins
#### Saga witchery
#### Typelines
#### Modal DFC flag hints
#### Flavor bar
#### Watermarks
#### Other scripted fields
#### Custom corner symbols
#### Custom fonts
#### Custom rarity symbol
#### Card column sorting
#### Custom index
#### Skeleton generator
############################################################## Localization
include file: language
############################################################## Common files
include file: statistics_script
include file: /magic-blends.mse-include/new-blends
############################################################## Versioning
version_date := {"2024-05-24 Mainframe 1.3.d Showcase Catchup: Alchemy Compatibility"}
version := version_date
############################################################## Common filters
############################################################## Utility
comma_count := filter_text@(match:",")
semicolon_count := filter_text@(match:";")
split_comma := split_text@(match: " *, *")
line_count := split_text@(match:"\n+",include_empty:false) + length
word_count := break_text@(match:"[^[:space:]]+") + length
has_png := contains@(match:".png")
has_none := contains@(match: "none")
remove_comma := replace@(match: ",", replace: "")
long_dash := replace@(match:"-", replace:"—")
softline_ripper := replace@(match:"</?soft-line>", replace:"")
un_png := replace@(match:".png", replace: "")
to_title := replace@(match:"(^| )([A-z])([^ ]*)", replace:{_1+ to_upper(_2) + to_lower(_3)})
to_sentence := replace@(match:"(^|\n)([A-z])([^\n]*)", replace:{_1+ to_upper(_2) + to_lower(_3)})
remove_zwsp := replace@(match:"", replace:"")
#### Replace spaces by a spacer
separate_words := remove_tags + trim + replace@(match:" ", replace: {spacer})
zwsp := "" # this is a zero-width space not blank
############################################################## Type
is_creature := match@(match: "(?i)Creature")
is_creaturish := match@(match: "(?i)(Creature|Vehicle)")
is_tribal := match@(match: "(?i)Tribal")
is_artifact := match@(match: "(?i)Artifact")
is_land := match@(match: "(?i)Land")
is_enchantment := match@(match: "(?i)Enchantment")
is_aura := match@(match: "(?i)Aura")
is_spell := match@(match: "(?i)Instant|Sorcery")
is_sorcery := match@(match: "(?i)Sorcery")
is_instant := match@(match: "(?i)Instant")
is_planeswalker := match@(match: "(?i)Planeswalker")
is_legendary := match@(match: "(?i)Legendary")
match_vehicle := contains@(match:"Vehicle")
match_snow := contains@(match:"Snow")
############################################################## Text
is_modal := contains@(match:"<li>")
############################################################## Utility scripts
reverse_elements := {for element from 1 to length(input) do input[length(input) - element] + " "}
clamp := {
number := to_number(input)
if number < minimum then minimum
else if number > maximum then maximum
else number
}
round_up := {to_int(0.99999999999998+input)} #### 0.99999999999999 == 1, leave the 8
round_near := {to_int(0.5+input)}
#### reads from a comma separated list like an array
pull_comma_array := {
array := split_text(input, match:divider)
length := length(comma_count(input))
ending := to_number(end)
if (cell >= (length + (1-ending)))
then default
else if array[cell] == "" or array[cell] == nil or array[cell] == "-"
then default
else array[cell]
}@(default:0, end: 1, divider:",", cell:0)
#### standard is pull_comma_array("X,Y,Z,", cell: 0)
#### returns "X"
#### ending true for coordinates (requires a final divider to ensure element is complete)
#### ending false for moving (doesn't require divider, moving 1 then 11 is fine)
#### divider is "," by default, can change
#### can also add default to return in case of errors
#### a workaround for the crop offset function that doesn't appear to work
#### slice_crop(input:image, height:(final height), width:(final width), distance:(length from bottom to top of final image))
slice_crop := {
img := flip_vertical(input)
img := crop(img, height:distance, width:width, offset_x:0, offset_y:0)
img := flip_vertical(img)
img
if(height != 0 and height != distance) then
img := crop(img, height:height, width:width, offset_x:0, offset_y:0)
img
}@(height:0)
#### a crop function that checks bounds first to avoid a crash
crop_safe :=
{
if offset_x < 0
or offset_y < 0
or width < 1
or height < 1
or offset_x + width > max_x
or offset_y + height > max_y
then ""
else crop(input, offset_x: offset_x, offset_y: offset_y, width: width, height: height)
}
#### pad a string from the front or back or both idk i'm not your dad
fill_len := {
output := to_string(input)
if output == "" then output := "0"
fill := max(0,fill_to - length(output))
for x from 1 to fill do output := lead + output + follow;
output
}@(fill_to:2, lead:"", follow:"")
#### simple array join function
join := {
if i >= length(input) then ""
else if i == length(input)-1 then input[i]
else input[i]+sep+join(input, i: i+1, sep: sep)
}@(i: 0, sep:"")
#### join array into list format
join_list := {
string := ""
if length(input) == 2 then spacer := " "
if length(input) == 1 then closing := ""
for x from 0 to length(input)-1 do
string := string + (if x == length(input)-1 then closing else "") + input[x] + (if x == length(input)-1 then "" else spacer)
string
}@(spacer:", ", closing:"and ")
#### workarounds cause position() is broken for text arrays
#### where reasonable, you can use position(of:["str"], in:[["list"], ["of"], ["str"]]) instead
contains_element := {
if input == [] then false else length(filter_list(input, filter:{input == element})) > 0
}
ar_position := {
pos := -1
for x from 0 to length(in)-1 do (
if in[x] == of then pos := x;
)
pos
}
includes := {ar_position(of:input in:array) != -1}
unique_elements := {
e1 := []
e2 := []
e1 := e1 + for x from 0 to length(of)-1 do if ar_position(of:of[x], in:from) == -1 then [of[x]]
}
#### This blends a map of images together
#### i dont remember why
#### i think i tested it for dungeons
#### example img_map := ["up":"test/up.png" "down":"test/down.png" "left":"test/left.png" "right":"test/right.png"]
multi_choice_image := {
#### input = option string
#### img_map = map of image links
coll := split_text(input, match:", ?")
imgs := for each x in coll do if img_map[x] or else false != false then [img_map[x]]
len := length(imgs)
if len == 0 then
""
else if len == 1 then
imgs[0]
else if len == 2 then
combine_blend(image1:imgs[0] image2:imgs[1], combine:combine)
else mass_combine(imgs:imgs, combine:combine)
}@(combine:"and")
mass_combine := {
base := combine_blend(image1:imgs[0] image2:imgs[1], combine:combine)
for x from 2 to length(imgs)-1 do (
base := combine_blend(image1:base image2:imgs[x] combine:combine)
"" #### this is junk output so it doesn't try to add the images as strings
)
base
}@(combine:"and")
get_alpha_percentage :=
{
alpha_value := if input == "" then default
else to_number(input) or else default
if alpha_value < 0 then 0.0
else if alpha_value <= 100 then alpha_value/100.0
else 1.0
}
############################################################## For the user
#### Remove card codes
cc_filter := replace@(match:"^[CURMSL][WUBRGMZACL][0-9]+ ?[-—]? ?", replace:"")
has_alchemy := contains@(match:"alchemy")
strip_card_codes := {
save := input
input := cc_filter(input)
input := if input == "" or input == " " then save else input
if atom and has_alchemy(card.card_symbol)
then "<sym>A-</sym>" + input
else input
}@(atom:false)
name_default := { "" }
name_checker := {if not set.remove_card_codes then input else strip_card_codes(input)}
#### Print fix
rare_width := {
cw := card_style.rarity.content_width
cw := if cw > 44 then (if set.print_fix != "" then set.print_fix else 22) else if cw < 22 then 22 else cw
if card_style.rarity.width == 0 then 0 else cw
}
############################################################## Card characteristics
############################################################## Name
has_two_names := {
contains(card.shape, match:"adventure")
or contains(card.shape, match:"aftermath")
or contains(card.shape, match:"double faced")
or contains(card.shape, match:"flip")
or contains(card.shape, match:"split")
}
card_full_name := { if has_two_names() then card.name + " // " + card.name_2 else card.name }
#### exportname
exporter_name_filter := filter_text@(match:"!exporte?r?name [^\n!]+")
exporter_name_grabber := replace@(match:"!exporte?r?name ", replace:"")
export_name := { exporter_name_grabber(exporter_name_filter(card.notes)) }
clean_name := remove_tags +
replace@(match:"(\n| +$|^ +)", replace:"") +
replace@(match:"", replace:"'")
card_name := {
test_name := export_name()
if test_name == "" then test_name := card.name
clean_name(test_name)
}
dfc_splitter_name := {
back_name := card.name_2
full_name := card_name()
if back_name != "" then full_name := full_name + "_" + clean_name(back_name)
full_name
}
############################################################## Special text
special_text := { "" }
special_text2 := { "" }
transfer_levels := {true}
transfer_levels_2 := {true}
a_saga := {false}
saga_reminder := { "As this Saga enters and after your draw step, add a lore counter. Sacrifice after III." }
b_saga := {false}
saga_reminderb := { "As this Saga enters and after your draw step, add a lore counter. Sacrifice after III." }
is_mainframe := { false }
mainframe_walker := {false}
mainframe_walker_text_script := {combined_editor(field1: card.level_1_text, separator1: "<line>\n</line>", field2: card.level_2_text, separator2: "<line>\n</line>", field3: card.level_3_text)}
mainframe_walkerb := {false}
mainframe_walker_text_scriptb := {combined_editor(field1: card.level_5_text, separator1: "<line>\n</line>", field2: card.level_6_text, separator2: "<line>\n</line>", field3: card.level_7_text)}
mainframe_walkerc := {false}
mainframe_walker_text_scriptc := {combined_editor(field1: card.level_9_text, separator1: "<line>\n</line>", field2: card.level_10_text, separator2: "<line>\n</line>", field3: card.level_11_text)}
mainframe_walkerd := {false}
mainframe_walker_text_scriptd := {combined_editor(field1: card.level_13_text, separator1: "<line>\n</line>", field2: card.level_14_text, separator2: "<line>\n</line>", field3: card.level_15_text)}
alt_text := {false}
alt_text_script := {false}
alt_textb := {false}
alt_text_scriptb := {false}
alt_textc := {false}
alt_text_scriptc := {false}
alt_textd := {false}
alt_text_scriptd := {false}
############################################################## Shape
#### Shape of cards, can be changed in style files
card_shape := { "normal" }
token_shape := {
case input of
"token": true,
"emblem": true,
"counter": true,
"rulestip": true,
"checklist": true,
else: false;
}
#### used by pack scripts
is_token_card := { token_shape(card.shape) }
is_shifted_card := { contains(card.shape, match:"shifted") }
is_masterpiece := { card.rarity == "masterpiece" }
is_promo := { false }
rarity_field := { if input <= 1 then card.rarity else card["rarity_" + input] }
is_rare :=
{
rarity := rarity_field(field)
rarity == "rare" or rarity == "mythic rare" or rarity == "masterpiece"
}@(field: 1)
is_walker := { contains(card.super_type, match:"Planeswalker") }
is_legend := { true } #### TODO ???
############################################################## Identity
#### Indicators never appear if the indicator would be colorless, colorless land, or colorless artifact.
#### Indicators do appear if the chosen frame doesn't match the default.
#### Indicators do appear if the chosen color for the indicator doesn't match the default.
blank_indentity := {
case input of
"colorless": true,
"land": true,
"artifact": true,
else: false;
}
has_identity := {
default := card_color(casting_cost: card.casting_cost, rules_text: card.rule_text, type: card.super_type, watermark: card.watermark, card_name: card.name, default: "colorless")
if blank_indentity(card.indicator)
then false
else if card.indicator != default
then true
else if card.card_color != default
then true
else false
}
has_identity_2 := {
default := card_color(casting_cost: card.casting_cost_2, rules_text: card.rule_text_2, type: card.super_type_2, watermark: card.watermark_2, card_name: card.name_2, default: "colorless")
if blank_indentity(card.indicator)
then false
else if card.indicator_2 != default
then true
else if card.card_color_2 != default
then true
else false
}
has_identity_3 := {
default := card_color(casting_cost: card.casting_cost_3, rules_text: card.rule_text_3, type: card.super_type_3, watermark: card.watermark_3, card_name: card.name_3, default: "colorless")
if blank_indentity(card.indicator)
then false
else if card.indicator_3 != default
then true
else if card.card_color_3 != default
then true
else false
}
############################################################## Exporter utility
exporter_num_filter := filter_text@(match:"!num [^\n!]+")
exporter_num_grabber := replace@(match:"!num ", replace:"")
trim_zeroes := replace@(match: "^00?", replace: "")+
replace@(match: "a?/[0-9b]+", replace: "")
corrected_card_number := { if exporter_num_grabber(exporter_num_filter(card.notes)) != "" then exporter_num_grabber(exporter_num_filter(card.notes)) else if card.custom_card_number != "" then trim_zeroes(card.custom_card_number) else card_number() }
############################################################## Sorting mana symbols
#### correctly sort a mana symbol (no guild mana)
mana_sort := sort_text@(order: "\\?XYZI[0123456789]VLHSFCAIE(WUBRG)")
#### correctly sort wedge mana
mana_sort_wedge := sort_text@(order: "\\?XYZI[0123456789]VLHSFCAIE(WBGUR)")
#### sort nothing
mana_unsort := sort_text@(order:"[/\\?XYZI0123456789VLHSCAIEWUBRG]")
#### correctly sort guild mana
mana_sort_guild := sort_text@(order: "[\\?XYZI01234567890VLHSFCAIEWUBRG/|]") +
replace@(
#### No lookbehind :(
#match: "(?<!/)(./.|././.|./././.|.[|])(?!/)",
match: "./.|././.|./././.|.[|]",
in_context: "(^|[^/])<match>($|[^/])",
replace: {sort_text(order:"in_place((WUBRG))")}
)
#### mana filter helpers
mana_has_guild := match@(match: "[/|]") #### Is there guild or half mana in the input?
mana_is_wedge := { chosen(set.mana_cost_sorting, choice: "tarkir wedge sorting") and ( number_of_items(in: sort_text(order:"<WUBRG>", input), filter: "<WUBRG>") == 3 ) }
mana_has_wedge := {
wedge_check := sort_text(order:"<WUBRG>", input)
mana_is_wedge() and (wedge_check == "WUR" or wedge_check == "WBR" or wedge_check == "WBG" or wedge_check == "UBG" or wedge_check == "URG")
}
#### A mana cost can contain both normal and guild mana
mana_filter := to_upper + {
if chosen(set.mana_cost_sorting, choice: "unsorted") then mana_unsort()
else if mana_has_guild() then mana_sort_guild()
else if mana_has_wedge(input) then mana_sort_wedge(input)
else mana_sort()
}
#### prevent infinite tap symbol glitch
tap_reduction :=
replace@(match:"T+", replace:"T")+
replace@(match:"Q+", replace:"Q")
#### only allow tickets
ticket_isolate := filter_text@(match:"(TK)+")
#### remove ticket Ts from tap filter
tap_filter := replace@(match:"(TK)+", replace:"")+
sort_text@(order: "<TQ>")
#### Like mana filter, only also allow tap symbols:
mana_filter_t := replace@( #### Remove [] used for forcing mana symbols
match: "[\\[\\]]",
replace: ""
) + { tap_reduction(tap_filter()) + mana_filter() }
card_is_wedge := {
color_string := card_color_to_letters(input)
if color_string == "WUR" or color_string == "WBR" or color_string == "WBG" or color_string == "UBG" or color_string == "URG" then true else false
}
############################################################## Symbol font defaults
mana_t :=
{
field := styling.tap_symbol or else "new"
if field == "diagonal T" then "older"
else if field == "old" then "old"
else "new"
}
guild_mana :=
{
styling.use_guild_mana_symbols or else false
}
ancestral_mana :=
{
field := styling.other_options or else nil
if field == nil then (styling.use_ancestral_mana_symbols or else false)
else contains(field, match:"ancestral generic")
}
white_text := { false }
#### Script to make magic-mana-future compatible w/ other templates
colorless_color := {
if contains(card.card_color, match:"hybrid") or contains(card.card_color, match:"multicolor") then "c"
else if card.card_color=="white" then "w"
else if card.card_color=="blue" then "u"
else if card.card_color=="black" then "b"
else if card.card_color=="red" then "r"
else if card.card_color=="green" then "g"
else "c"
}
############################################################## Mainframe mana
use_v_mana := {contains(set.custom_mana_symbol_name, match:".png")}
use_large_v_mana := { use_v_mana() and chosen(set.mana_symbol_options, choice:"enable in casting costs")}
use_small_v_mana := { use_v_mana() and chosen(set.mana_symbol_options, choice:"enable in text boxes")}
use_color_v_mana := { use_v_mana() and chosen(set.mana_symbol_options, choice:"colored mana symbols") and not use_hybrid_v_mana()}
use_hybrid_v_mana := { use_v_mana() and chosen(set.mana_symbol_options, choice:"hybrid with colors")}
v_mana_name := {if not use_v_mana() then "" else replace(set.custom_mana_symbol_name, match:"(.+/|\\.png)", replace:"")}
v_mana_loc := {if not use_v_mana() then "" else replace(set.custom_mana_symbol_name, match:"{v_mana_name()}\\.png", replace:"")}
v_mana_num := {max(to_number(set.number_hybrid_variants),0) or else -1}
############################################################## Determine card color
#### Names of colors
color_name := {
if input == "W" then "white"
else if input == "U" then "blue"
else if input == "B" then "black"
else if input == "R" then "red"
else if input == "G" then "green"
else ""
}
mana_name := {
if input == "white" then "W"
else if input == "blue" then "U"
else if input == "black" then "B"
else if input == "red" then "R"
else if input == "green" then "G"
else "C"
}
color_names_1 := { color_name(colors.0) }
color_names_2 := { color_name(colors.0) + ", " + color_name(colors.1) }
color_names_3 := { color_name(colors.0) + ", " + color_name(colors.1) + ", " + color_name(colors.2) }
color_names_4 := { color_name(colors.0) + ", " + color_name(colors.1) + ", " + color_name(colors.2) + ", " + color_name(colors.3) }
color_names_5 := { color_name(colors.0) + ", " + color_name(colors.1) + ", " + color_name(colors.2) + ", " + color_name(colors.3) + ", " + color_name(colors.4) }
#### color based on mana cost, input == a mana cost
color_filter := sort_text@(order: "<WUBRG>")
color_filterH := sort_text@(order: "</>")
mana_to_color := {
count := number_of_items(in: colors)
if hybrid == "" and contains(type, match:"Artifact") then
#### not a hybrid, but artifact
if count == 0 then "artifact"
else if count == 1 then color_names_1() + ", artifact"
else if set.set_info.use_gradient_multicolor == "no" then "artifact, multicolor" #### stop here
else if count == 2 then color_names_2() + ", artifact, multicolor"
else if set.set_info.use_gradient_multicolor != "yes" then "artifact, multicolor" #### stop here
else if count == 3 then color_names_3() + ", artifact, multicolor"
else if count == 4 then color_names_4() + ", artifact, multicolor"
else if count == 5 then color_names_5() + ", artifact, multicolor"
else "artifact, multicolor"
else if hybrid == "" then
#### not a hybrid, not artifact
if count == 0 then "colorless"
else if count == 1 then color_names_1()
else if set.set_info.use_gradient_multicolor == "no" then "multicolor" #### stop here
else if count == 2 then color_names_2() + ", multicolor"
else if set.set_info.use_gradient_multicolor != "yes" then "multicolor" #### stop here
else if count == 3 then color_names_3() + ", multicolor"
else if count == 4 then color_names_4() + ", multicolor"
else if count == 5 then color_names_5() + ", multicolor"
else "multicolor"
else if contains(type, match:"Artifact") then
#### hybrid, but artifact
if count == 0 then "artifact"
else if count == 1 then color_names_1() + ", artifact"
else if count == 2 then color_names_2() + ", artifact"
else "artifact, multicolor"
else
#### hybrid, not artifact
if count == 0 then "colorless"
else if count == 1 then color_names_1()
else if count == 2 then color_names_2() + ", hybrid"
else "multicolor"
}
#### color based on land text box, input == textbox contents
color_text_filter :=
#### remove activation costs
replace@(
match: "<sym[^>]*>[^<]+</sym[^>]*>"
in_context: "(?ix) (\\n|^)[^:]*<match>(,|:) | (pays?|additional|costs?)[ ]<match>",
replace: ""
) +
#### keep only mana
filter_text@(match: "<sym[^>]*>([^<]+)") + color_filter;
#### get the land frame for a "WUBRG"-style input.
land_multicolor := {
count := number_of_items(in: colors)
if count == 0 then "land"
else if count == 1 then color_names_1() + ", land"
else if count == 2 then color_names_2() + ", land"
else "land, multicolor"
}
land_to_color := {
#### Based on watermark
if watermark == "mana symbol white" then "white, land"
else if watermark == "mana symbol blue" then "blue, land"
else if watermark == "mana symbol black" then "black, land"
else if watermark == "mana symbol red" then "red, land"
else if watermark == "mana symbol green" then "green, land"
else land_multicolor(colors:color_text_filter(input: rules))
}@(rules:card.rule_text)
#### Look for a CDA that defines colors
text_to_color := {
#### Note: running filter_text is quite slow, do a quick 'contains' check first
if contains(match: card_name + " is") then (
text := filter_text(match: "is (colorless|all colors|((blue|white|green|red|black)((,|,? and) (blue|white|green|red|black))*))", in_context: regex_escape(card_name)+"(</[-a-z]+>)* <match>\\.")
if text != "" then (
if contains(text, match: "all colors") then (
colors := "WUBRG"
if land == true then land_multicolor()
else mana_to_color(hybrid: "")
) else (
colors := ""
if contains(text, match: "white") then colors := colors + "W"
if contains(text, match: "blue") then colors := colors + "U"
if contains(text, match: "black") then colors := colors + "B"
if contains(text, match: "red") then colors := colors + "R"
if contains(text, match: "green") then colors := colors + "G"
if land == true then land_multicolor()
else mana_to_color(hybrid: "")
)
)
else ""
)
else ""
}
#### The color of a card
card_color := {
#### usually the color of mana
text_color := text_to_color(rules_text, land: is_land(type));
if text_color == "" then (
mana_color := mana_to_color(colors: color_filter(casting_cost), hybrid: color_filterH(casting_cost))
if mana_color == "colorless" and is_land (type) then land_to_color(watermark, rules:rules_text)
else if mana_color == "colorless" and is_artifact(type) then "artifact"
else if mana_color == "colorless" and contains(card.shape, match:"flip") then default
else mana_color
)
else text_color
};
#### Number of colors in a card_color
card_color_color_count := count_chosen@(choices: "white,blue,black,red,green,artifact")
#### Clean up color field
card_color_filter := {
colors := card_color_color_count()
if colors > 2 then
input := remove_choice(choice: "overlay")
if colors > 1 then (
input := require_choice(choices: "multicolor, hybrid, land, artifact")
input := exclusive_choice(choices: "multicolor, hybrid")
input := require_exclusive_choice(choices: "horizontal, vertical, radial, overlay")
) else
input := remove_choice(choices: "radial, horizontal, vertical, overlay, hybrid, reversed")
if chosen(choice:"overlay") then
input := remove_choice(choice: "reversed")
input
}
#### convert card color to "white, blue, and black" etc for reminder text
list_colors := {
list := trim_colors(input)
cc := length(comma_count(list))
if cc == 1 then
list := replace(list, match:", ", replace:" and ")
if cc > 1 then
list := replace(list, match:", ", replace:", and ", in_context:"<match>[^ ]+$")
list
}
#### convert card_color to WUBRG
card_color_to_letters := {
color_string := trim_colors(input)
(if contains(color_string, match:"white") then "W" else "")
+(if contains(color_string, match:"blue") then "U" else "")
+(if contains(color_string, match:"black") then "B" else "")
+(if contains(color_string, match:"red") then "R" else "")
+(if contains(color_string, match:"green") then "G" else "")
}
card_color_field := { if input <= 1 then card.card_color else card["card_color_" + input] }
############################################################## Card number
#### The code consists of 4 parts:
#### partition, rarity tier, color, card name
#### remove filler text from partition select
partition_filter := replace@(match:"(before normal|after normal, main set|after main set|help.*) ?", replace:"")
partition_index := {
ind := partition_filter(card.partition_select)
if ind == "" then ind := "A"
ind
}
default_partition := {"A"}
#### determine if a card is "over-partition", ie should be excluded from the main set count
over_partition := {
mn_pos := if set.last_main_partition == "" then "M" else to_upper(substring(set.last_main_partition, end:1))
(partition_scores[partition_index()] or else 10) > (partition_scores[mn_pos] or else 22)
}
partition_scores := [
0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9,
A:10, B:11, C:12, D:13, E:14, F:15, G:16, H:17, I:18,
J:19, K:20, L:21, M:22, N:23, O:24, P:25, Q:26, R:27,
S:28, T:29, U:30, V:31, W:32, X:33, Y:34, Z:35
]
#### MSE doesn't do "A" > "B" like some languages do
#### Originally this put partition_index() and mn_pos in an array and sorted that
#### but that crashed mse on startup once it was added to sort the card number column
#### but you also couldn't use position() because it inherits order_by and filter from card_number()
#### and MSE yells at you if you do that and you're not sorting a set
#### and replacing them with nil doesn't work, it still complains if they're nil???
#### so instead hard-coded map of indices
#### you'll never catch me i'm behind seven workarounds
#### Index for sorting, white cards are first, so white->A, blue->B, .. ,
sort_index := {
color_of_card() +
(if contains(card.shape, match:"shifted") then "S" else " ") + #### planeshifted cards come after normal ones
(if contains(card.shape, match:"split") then "S" else " ") + #### split cards come after normal ones
":"
}
#### A code for the color of the card
color_of_card := {
card_color := card.card_color
casting_cost := card.casting_cost
type := card.super_type
if contains(card.shape, match: "split") and
card_color != card.card_color_2 then "I" #### Diff Color Splits
else if chosen(choice: "land", card_color) then ( #### Lands
if card.rarity != "basic land" then "L" #### Nonbasic Land
else basic_land_sort() #### Basic Land
) else if is_null_cost(casting_cost) then ( #### Non-Land Cards with no or zero costs.
if chosen(choice: "colorless", card_color) then "A" #### Clear Colorless
else if chosen(choice: "hybrid", card_color) then "HK" #### Hybrids
else if is_multicolor(card_color) then "GK" #### Multicolor
else if chosen(choice:"white", card_color) then "B" #### White
else if chosen(choice:"blue", card_color) then "C" #### Blue
else if chosen(choice:"black", card_color) then "D" #### Black
else if chosen(choice:"red", card_color) then "E" #### Red
else if chosen(choice:"green", card_color) then "F" #### Green
else "J" #### Artifact
) else (
#### Cards with costs.
colors := sort_text(casting_cost, order: "<WUBRG>")
if colors == "" and contains(type, match:"Artifact") then "J" #### Artifact
else if colors == "" then "A" #### Clear Colorless
else if colors == "W" then "B" #### White
else if colors == "U" then "C" #### Blue
else if colors == "B" then "D" #### Black
else if colors == "R" then "E" #### Red
else if colors == "G" then "F" #### Green
else if is_hybrid_cost() then hybrid_color_pair_sort() #### Hybrid (by pairs)
else if contains(casting_cost, match:"/") and contains(type, match:"Artifact") then "I" #### Hybrid Artifacts
else multi_color_pair_sort() #### Multicolor (by pairs)
)
}
is_null_cost := { input == "" or input == "0" }
is_multicolor := { chosen(choice: "multicolor") and input != "artifact, multicolor" }
is_hybrid_cost := { contains(card.casting_cost, match: "W/") or contains(card.casting_cost, match: "U/") or contains(card.casting_cost, match: "B/") or contains(card.casting_cost, match: "R/") or contains(card.casting_cost, match: "G/") }
basic_land_sort := {
if contains(card.name, match:"Plains") then "MB" #### Plains
else if contains(card.name, match:"Island") then "MC" #### Islands
else if contains(card.name, match:"Swamp") then "MD" #### Swamps
else if contains(card.name, match:"Mountain") then "ME" #### Mountains
else if contains(card.name, match:"Forest") then "MF" #### Forests
else "MA" #### other basic lands
}
hybrid_color_pair_sort := {
colors := sort_text(casting_cost, order: "<WUBRG>")
if not set.sort_hybrid_in_pairs then "HK"
else if colors == "WU" then "HA"
else if colors == "UB" then "HB"
else if colors == "BR" then "HC"
else if colors == "RG" then "HD"
else if colors == "WG" then "HE"
else if colors == "WB" then "HF"
else if colors == "UR" then "HG"
else if colors == "BG" then "HH"
else if colors == "WR" then "HI"
else if colors == "UG" then "HJ"
else "HK"
}
multi_color_pair_sort := {
colors := sort_text(casting_cost, order: "<WUBRG>")
if not set.sort_multicolor_in_pairs then "GK"
else if colors == "WU" then "GA"
else if colors == "UB" then "GB"
else if colors == "BR" then "GC"
else if colors == "RG" then "GD"
else if colors == "WG" then "GE"
else if colors == "WB" then "GF"
else if colors == "UR" then "GG"
else if colors == "BG" then "GH"
else if colors == "WR" then "GI"
else if colors == "UG" then "GJ"
else if contains(card.casting_cost, match:"/") then "GL"
else "GK"
}
#### Sort the card into its rarity tier
#### unsorted, regular cards, "after other cards" specials
#### "separate numbering" specials, masterpieces
#### tokens, emblems, rulestips, counters checklists
rarity_sort := {
if is_unsorted() then "R0"
else if card.shape == "token" then "T1"
else if card.shape == "emblem" then "T2"
else if card.shape == "rulestip" then "T3"
else if card.shape == "counter" then "T4"
else if card.shape == "checklist" then "T5"
else if is_masterpiece() then "S2"
else if set.sort_special_rarity == "separate numbering" and card.rarity == "special" then "S1"
else if set.sort_special_rarity == "with the rest" or card.rarity != "special" then "R1"
else "R2"
}
#### do this to accurate represent partition sorting for the card number sorting column
rarity_partition_sort := {
main := rarity_sort()
main.0 + partition_index() + main.1
}
#### Process the name for sorting rules
sort_name :=
#### Remove "The", "A", and "An" at the beginning
replace@(match: "^(The|An?) ", replace: "") +
#### Remove commas and apostrophes
replace@(match: "(,|'|)", replace: "") +
#### Remove bold and italic tags
replace@(match: "(<b>|<i>|</b>|</i>)", replace: "") +
#### Make lowercase
to_lower
#### given a card, return the function that returns all other cards that impact its card number
set_filter := {
if is_unsorted() then
{ is_unsorted() }
else if card.shape == "token" or card.shape == "emblem" then
{ card.shape == "token" or card.shape == "emblem" }
else if card.shape == "rulestip" then
{ card.shape == "rulestip" }
else if card.shape == "counter" then
{ card.shape == "counter" }
else if card.shape == "checklist" then
{ card.shape == "checklist" }
else if is_masterpiece() and not token_shape(card.shape) then
{ is_masterpiece() and not token_shape(card.shape) }
else if set.sort_special_rarity != "separate numbering" then
{ not is_unsorted() and not token_shape(card.shape) }
else if card.rarity == "special" then
{ not is_unsorted() and not token_shape(card.shape) and card.rarity == "special" }
else
{ not is_unsorted() and not token_shape(card.shape) and card.rarity != "special" }
}
#### over-partition cards need to be counted during the card number count
#### but need to be skipped during the card count count
#### so this is a copy of set_filter but it skips over-partition cards
set_filter_under_partition := {
if is_unsorted() then
{ is_unsorted() }
else if card.shape == "token" or card.shape == "emblem" then
{ card.shape == "token" or card.shape == "emblem" and not over_partition() }
else if card.shape == "rulestip" then
{ card.shape == "rulestip" and not over_partition() }
else if card.shape == "counter" then
{ card.shape == "counter" and not over_partition() }
else if card.shape == "checklist" then
{ card.shape == "checklist" and not over_partition() }
else if is_masterpiece() and not token_shape(card.shape) then
{ is_masterpiece() and not token_shape(card.shape) and not over_partition() }
else if set.sort_special_rarity != "separate numbering" then
{ not is_unsorted() and not token_shape(card.shape) and not over_partition() }
else if card.rarity == "special" then
{ not is_unsorted() and not token_shape(card.shape) and card.rarity == "special" and not over_partition() }
else
{ not is_unsorted() and not token_shape(card.shape) and card.rarity != "special" and not over_partition() }
}
#### user configurable additions to the set totals
card_number_offset := {pull_comma_array(set.card_number_offsets, cell:0, end:false, default:0)}
set_number_offset := {pull_comma_array(set.card_number_offsets, cell:1, end:false, default:0)}
#### the raw numbers, these aren't typically used directly
card_number := {
position (
of: card
in: set
order_by: { partition_index() + rarity_sort() + sort_index() + sort_name(card.name) + sort_name(export_name())}
filter: set_filter()
) + 1 + to_number(card_number_offset())
}
card_count := {
number_of_items(in: set, filter: set_filter_under_partition()) + to_number(set_number_offset())
}
#### Starting with M15, pad the collector number to three digits
card_number_m15 := { (if card_number() < 100 then "0" else "") + (if card_number() < 10 then "0" else "") + card_number() }
card_count_m15 := { (if card_count() < 100 then "0" else "") + (if card_count() < 10 then "0" else "") + card_count() }
#### Starting with MOM, pad the collector number to four digits
card_number_mom := { (if card_number() < 1000 then "0" else "") + (if card_number() < 100 then "0" else "") + (if card_number() < 10 then "0" else "") + card_number() }
card_count_mom := { (if card_count() < 1000 then "0" else "") + (if card_count() < 100 then "0" else "") + (if card_count() < 10 then "0" else "") + card_count() }
use_auto_numbers := {set.automatic_card_numbers and not is_unsorted()}
#### Use this in templates so we don't have to update 700 templates the next time they change the ordering
card_number_script_core := {
if not use_auto_numbers() then
combined_editor(field1: card.custom_card_number, separator: " " + rarity_code() + " ", field2: card.card_code_text)
else if set.card_number_style == "0001/0099" then
forward_editor(prefix: rarity_code() + " " + card_number_mom() + (if over_partition() and set.over_partition_display == "100" then "" else "/" + card_count_mom()) + " ", field: card.card_code_text)
else if set.card_number_style == "0001" then
forward_editor(prefix: rarity_code() + " " + card_number_mom() + " ", field: card.card_code_text)
else if set.card_number_style == "001/099" then
forward_editor(prefix: card_number_m15() + (if over_partition() and set.over_partition_display == "100" then "" else "/" + card_count_m15()) + " " + rarity_code() + " ", field: card.card_code_text)
else if set.card_number_style == "001" then
forward_editor(prefix: card_number_m15() + " " + rarity_code() + " ", field: card.card_code_text)
else if set.card_number_style == "1/99" then
forward_editor(prefix: card_number() + (if over_partition() and set.over_partition_display == "100" then "" else "/" + card_count()) + " " + rarity_code() + " ", field: card.card_code_text)
else
forward_editor(prefix: card_number() + " " + rarity_code() + " ", field: card.card_code_text)
}
#### Determine a rarity code for M15 styles.
rarity_code := {
if not set.rarity_codes then ""
else if is_promo() then "P"
else if is_masterpiece() then "S"
else if contains(card.shape, match:"token") then "T"
else if contains(card.shape, match:"emblem") then "E"
else if card.rarity == "common" then "C"
else if card.rarity == "uncommon" then "U"
else if card.rarity == "rare" then "R"
else if card.rarity == "mythic rare" then "M"
else if card.rarity == "special" then "S"
else if card.rarity == "basic land" then "L"
else ""
}
is_unsorted := { false }
############################################################## Statistics utilities
#### Converted mana cost
is_half_mana := match@(match: "1/2|[|][WUBRGS]")
is_half_generic := match@(match: "1/2")
is_colored_mana := match@(match: "[WUBRG]")
only_numbers := filter_text@(match: "^[0123456789]+")
cmc_split := break_text@(match: "(?ix) 1/2 | [|][WUBRGC] | TK | [0-9](/[WUBRGCVLHSCETQ2]) | [0-9]+(?!/[WUBRGCVLHSCETQ2]) | [WUBRGCVLHS0-9](/[WUBRGCVLHS])\{0,4} ")
cmc := {to_number(
for each sym in cmc_split(to_text()) do (
numbers := only_numbers(sym)
if is_half_mana(sym) then 0.5
else if numbers != "" then to_int(numbers)
else 1 #### all other symbols are 1
))
}
mana_value := cmc
#### Remove supertypes or types to look at parts of the super_type field by themselves.
remove_supertype := replace@(match: "(Legendary|Basic|Snow|World|Tribal|Token)", replace: "")+
replace@(match: "[ ]+", in_context: "^<match>", replace: "")+
replace@(match: "[ ]+", in_context: "<match>$", replace: "")
remove_type := replace@(match: "(Artifact|Creature|Enchantment|Instant|Land|Planeswalker|Sorcery)", replace: "")+
replace@(match: "[ ]+", in_context: "^<match>", replace: "")+
replace@(match: "[ ]+", in_context: "<match>$", replace: "")
write_wubrg := {
(if match(input, match:"white") then "W" else "")+
(if match(input, match:"blue") then "U" else "")+
(if match(input, match:"black") then "B" else "")+
(if match(input, match:"red") then "R" else "")+
(if match(input, match:"green") then "G" else "")
}
colored_mana := {to_number(
for each sym in cmc_split(to_text()) do (
numbers := only_numbers(sym)
if is_colored_mana(sym) then
if is_half_mana(sym) then 0.5 else 1
else 0
))
}
generic_mana := {to_number(
for each sym in cmc_split(to_text()) do (
numbers := only_numbers(sym)
if is_half_generic(sym) then 0.5
else if numbers != "" then to_int(numbers)
else 0 #### all other symbols are 1
))
}
primary_card_color := {
artifact := chosen(choice:"artifact") and not (chosen(choice:"white") or chosen(choice:"blue") or chosen(choice:"black") or chosen(choice:"red") or chosen(choice:"green"))
land := chosen(choice:"land")
multi := chosen(choice:"multicolor")
hybrid := chosen(choice:"hybrid")
white := chosen(choice:"white")
blue := chosen(choice:"blue")
black := chosen(choice:"black")
red := chosen(choice:"red")
green := chosen(choice:"green")
multi_color := count_chosen(choices:"white, blue, black, red, green")
if land then "land"
else if multi then "multicolor"
else if multi_color == 2 and chosen(choice:"artifact") then "hybrid" #### hybrid artifacts would show as their first color
else if hybrid then "hybrid"
else if artifact then "artifact"
else if white then "white"
else if blue then "blue"
else if black then "black"
else if red then "red"
else if green then "green"
else input
}
sparker_card_color := {
artifact := chosen(choice:"artifact") and not (chosen(choice:"white") or chosen(choice:"blue") or chosen(choice:"black") or chosen(choice:"red") or chosen(choice:"green"))
land := chosen(choice:"land")
multi := chosen(choice:"multicolor")
hybrid := chosen(choice:"hybrid")
white := chosen(choice:"white")
blue := chosen(choice:"blue")
black := chosen(choice:"black")
red := chosen(choice:"red")
green := chosen(choice:"green")
multi_color := count_chosen(choices:"white, blue, black, red, green")
if land then "colorless"
else if multi then "multicolor"
else if multi_color >= 2 then "multicolor"
else if hybrid then "multicolor"
else if artifact then "artifact"
else if white then "white"
else if blue then "blue"
else if black then "black"
else if red then "red"
else if green then "green"
else "colorless"
}
############################################################## Keyword utilities
trim_reminder_x := replace@(match: ". X cant be 0.", replace: "")
has_cc := { card.casting_cost != "" }
has_pt := { card.power != "" or card.toughness != "" }
is_spell := { contains(card.type, match:"Instant") or contains(card.type, match:"Sorcery") }
contains_target := match@(match:"(?i)([^a-z]|^)targets?([^a-z]|$)")
is_targeted := { contains_target(card.rule_text) }
#### convert color word to mana symbol
color_to_mana := replace@(match: "white", replace: "[W]")+
replace@(match: "blue", replace: "[U]")+
replace@(match: "black", replace: "[B]")+
replace@(match: "red", replace: "[R]")+
replace@(match: "green", replace: "[G]")
#### convert number word to digit
digital_number := {
input := replace(input, match:"up to ", replace:"")
result := input
two_part := filter_text(input, match:"(twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety)")
one_part := filter_text(input, match:"(zero|a|an|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen)\\b")
if two_part != "" and one_part != "" then
result := (digital_map[two_part] + digital_map[one_part]) or else input
else if two_part != "" then
result := digital_map[two_part] or else input
else if one_part != "" then
result := digital_map[input] or else input
result
}
#### convert once, twice, "[number] times" to digit
iterate_digits := {
trimmed := iterate_fix(input)
if trimmed == "" then 1 else digital_map[trimmed] or else trimmed
}
iterate_fix := remove_tags
+replace@(match: "^\\.", replace:"")
+replace@(match: "^,", replace:"")
+replace@(match: "^[ ]", replace:"")
+replace@(match:" times", replace:"")
digital_map := [
"zero": 0,
"one": 1,
"once": 1,
"a": 1,
"an": 1,
"two": 2,
"twice": 2,
"three": 3,
"thrice": 3,
"four": 4,
"five": 5,
"six": 6,
"seven": 7,
"eight": 8,
"nine": 9,
"ten": 10,
"eleven": 11,
"twelve": 12,
"thirteen": 13,
"fourteen": 14,
"fifteen": 15,
"sixteen": 16,
"seventeen": 17,
"eighteen": 18,
"nineteen": 19,
"twenty": 20,
"thirty": 30,
"forty": 40,
"fifty": 50,
"sixty": 60,
"seventy": 70,
"eighty": 80,
"ninety": 90
]
#### If the 'input' parameter is a mana costs, then adds 'add'
for_mana_costs := {
if input.separator_before == "—" and contains(input.param, match: " ") then ( #### multi word
if comma_count(input.param) == "," then ( #### two part
if match(match: "^[VLHSCAIETKQ\\?XYZIWUBRG0-9/|]+,", input.param) then #### starts with mana
"{add}<param-cost>{alternative_cost(input.param, trim:combined_cost, s:action)}</param-cost>" #### "add" mana
else "<param-cost>{alternative_cost(input.param, trim:combined_cost, s:action)}</param-cost>{non}" #### else cost "non"
) else if contains(input.param, match: ",") then ( #### three+ parts
if match(match: "^[VLHSCAIETKQ\\?XYZIWUBRG0-9/|]+,", input.param) then #### starts with mana
"{add}<param-cost>{alternative_cost(input.param, trim:long_cost, s:action)}</param-cost>" #### "add" mana with long formatting
else "<param-cost>{alternative_cost(input.param, trim:long_nomana_cost, s:action)}</param-cost>{non}" #### else cost "non" with long formatting
) else
"<param-cost>{alternative_cost(input.param, s:action, trim:lower_first)}{non}</param-cost>" #### one, nonmana, part
) else if match(match: "^[VLHSCAIETKQ\\?XYZIWUBRG0-9/|]+$", input.param) then #### one word
"{add}<param-mana>{input.param}</param-mana>" #### mana
else
"<param-cost>{alternative_cost(input.param, trim:combined_cost, s:action)}</param-cost>{non}" #### nonmana
}@(non:" in addition to any other costs", action:false, add:"")
#### Convert extra costs
long_cost := replace@(match:", [A-Z]", replace: { to_lower() } )
long_nomana_cost := replace@(match:"[A-Z]", replace: { to_lower() })
#### Convert first character to lower case
lower_first := replace@(match:"^[A-Z]", replace: { to_lower() })
combined_cost := replace@(match:", [A-Z]", replace: { to_lower() })+
replace@(match:",", replace:" and")+
replace@(match:"^[VLHSCETKQ\\?XYZIWUBRG0-9/|]+", in_context: "(^|[[:space:]])<match>(?![a-z])", replace: "<sym-auto>&</sym-auto>")+
replace@(match:"^[A-Z]", replace: { to_lower() })
alternative_cost := {
input := trim(input)
if s then
input := actionize(input)
input
}@(trim: lower_first, s:false, trim:{input})
actionize := replace@(match:"(activate|ante|cast|choose|create|destroy|discard|double|draw|exchange|exile|fight|mill|play|put|regenerate|return|reveal|sacrifice|shuffle|tap|untap|transform|vote|exert|pay)(?=($| |,|\\.))", replace:"\\1s")
+replace@(match:"(attach)", replace:"\\1es")
+replace@(match:"scry", replace:"scries")
+replace@(match:"your", replace:"their")
#### determine if a reminder text should refer to this card or that card
this_or_that := {
this := if upper then "This" else "this"
that := if upper then "That" else "that"
#### inherit type, creature override, or given type
type := if input == "type"
then to_lower(main_type(card.type))
else if input != "card" and is_creaturish(card.type)
then "creature"
else input;
this_that := if input == "creature" and not is_creaturish(card.type)
then that #### ex. "Equipped creature has wither."
else if is_spell(card.type) and not is_spell(type)
then that #### ex. "Target creature gains wither."
else this;
#### sanitize
type := if type == ""
then "permanent"
else if this_that == this and type == "artifact" and not is_artifact(card.type)
then "permanent" #### ex. an enchantment with crew
else if this_that == this and type == "land" and not is_land(card.type)
then "permanent" #### ex. an enchantment with hideaway before they changed it
else type;
this_that + " " + type
}@(upper:false)
############################################################## Complex reminder texts
self_pro_check := match@(match:"You ha(ve|s) <kw-A><nospellcheck>protection")
protection_code := {
output := if match(input, match:"(artifacts|battles|creatures|enchantments|instants|kindreds|lands|planeswalkers|sorceries|planes|schemes|emblems|conspiracies|^[A-Z]|^[^ ]* named)") then replace(input, match:"and from", replace:"or", in_context:" <match> ")
else if match(input, match:"^(converted|mana|power|toughness)") then "anything with " + replace(input, match:"and from", replace:"or", in_context:" <match> ")
else if contains(input, match:"the chosen player") then "anything " + replace(input, match:"the chosen", replace:"controlled by that")
else if contains(input, match:"the chosen") then "anything with " + replace(input, match:"the chosen", replace:"that")
else if contains(input, match:"all colors") then "anything " + replace(input, match:"all colors", replace:"that's white, blue, black, red, or green")
else if match(input, match:"^you$") then "anything you control"
else if match(input, match:"^its owner$") then "anything its owner controls"
else if match(input, match:"^(each of )?your opponents$") then "anything " + replace(input, match:"(each of )?your opponents", replace:"controlled by those players")
else if match(input, match:"(the|a) [^\n]* of your choice") then "anything " + replace(input, match:"(the|a) ([^\n]*) of your choice", replace:"of that \\2")
else if input == "colorless" then "anything colorless"
else "anything " + replace(english_singular(input), match:"and from", replace:"or", in_context:" <match> ")
output := " targeted, dealt damage, enchanted, equipped by " + output
if match(output, match:"(artifacts|creatures|instants|lands|planeswalkers|sorceries|tribals|planes|schemes|emblems|conspiracies|by [A-Z])") and not match(output, match:"(enchantmentsAura|Curse)") then
output := replace(output, match:", enchanted", replace:"")
else output := output
if match(output, match:"(enchantments|creatures|instants|lands|planeswalkers|sorceries|tribals|planes|schemes|emblems|conspiracies|by [A-Z])") and not match(output, match:"(artifacts|Equipment)") then
output := replace(output, match:" equipped", replace:"")
else output := output
if match(output, match:"equipped by") then output := replace(output, match:"equipped by", replace:"or equipped by")
else if match(output, match:"enchanted, by") then output := replace(output, match:"enchanted, by", replace:"or enchanted by")
else if match(output, match:"dealt damage, by") then output := replace(output, match:"dealt damage, by", replace:"or dealt damage by")
else ""
if match(output, match:"^ targeted, or dealt damage by") then output := replace(output, match:"^ targeted, or dealt damage by", replace:" targeted or dealt damage by")
if match(output, match:"anything [A-Z]") then output := replace(output, match:"anything ", replace:"")
if match(output, match:"or les") then output := replace(output, match:"or les$", replace:"or less")
if match(output, match:"(anything )?everything") then output := replace(output, match:"(anything )?everything", replace:"anything")
output := (if self_pro_check(card.text) then "You can't be" else if is_spell(card.type) then "It can't be blocked," else if is_creaturish(card.type) then "This creature can't be blocked," else "This permanent can't be") + output
output
}
phy_reminder := {
phy_match := filter_text(input, match:"(/[WUBRG])+", in_context:"H<match>")
letters := split_text(phy_match, match:"/")
reminder_text := ""
if length(letters) == 2 then
reminder_text := "[H/" + letters[1] + "] can be paid with [" + letters[1] + "] or 2 life."
else if length(letters) > 2 then
reminder_text := "[H/" + letters[1] + "/" + letters[2] + "] can be paid with [" + letters[1] + "], " + "[" + letters[2] + "], or 2 life."
else
reminder_text := ""
reminder_text
}
#### includes localization ability
craft_code := {
[
"en": {
#### beginning
rem := param2.value + ", Exile this artifact, Exile ";
#### check if a number is given
count := filter_text(param1.value, match:"^(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety|[0-9]+)(-(one|two|three|four|five|six|seven|eight|nine))? (or more)?");
#### replace trailing space
count := trim(count)
#### check how many commas are given
commas := filter_text(param1.value, match:",");
#### check if this starts with a vowel
vowel := match(param1.value, match:"^[aeiouAEIOU]");
#### if we have a comma separated list, use the number of elements as the count
#### this doesn't support like, Craft with two Islands and two Mountains
#### you've done that to yourself
if commas != "" then count := english_number(length(commas)+1);
#### unused style (craft with three)
#### param1 == "three" count == "three"
#### counting style (craft with one or more); (craft with six artifacts)
#### param1 == "one or more" count == "one"; param1 == "six artifacts" count == "six"
#### singular style (craft with creature)
#### param1 == "creature" count == ""
if count == param1.value then
(
#### Exile three other...
rem := rem
+ param1.value
+ " other permanents you control and/or cards from your graveyard: "
)
else if count != "" then
(
#### Exile one or more from among...
#### Exile the six from among...
rem := rem
+ (if count == "one or more" then param1.value else "the " + count)
+ " from among other permanents you control and/or cards in your graveyard: "
)
else
(
#### Exile another creature you control or...
rem := rem
+ "another " + param1.value + " you control or "
+ (if vowel then "an " else "a ") + param1.value + " card from your graveyard: "
)
#### ending and return
rem := rem + "Return this card transformed under its owner's control. Craft only as a sorcery."
rem
},
"de": {
#### beginning
rem := param2.value + ", schnicke dieses Artefakt ins Exil, schicke ";
#### check if a number is given
count := filter_text(param1.value, match:"^(zwanzig|dreiβig|vierzig|fünfzig|sechzig|siebzig|achtzig|neunzig|eine[mr]|eins?|zwei|drei|vier|fünf|sechs?|sieben|sieb|acht|neun|zehn|elf|zwölf|[0-9]+)(und)?(zehn|zwanzig|dreiβig|vierzig|fünfzig|sechzig|siebzig|achtzig|neunzig)?( oder mehr(eren)?)? ?");
#### save the thing we're exiling
target := trim(replace(param1.value, match:count, replace:""))
alt_target := if length(target) > 15 then "Permanente" else target
#### format count
count := replace(count, match:"eine[mr]", replace:"eins")
count := trim(count)
#### check how many commas are given
commas := filter_text(param1.value, match:",");
#### check if this starts with a vowel
vowel := match(target, match:"^[aäeiouüAÄEIOUÜ]");
#### if we have a comma separated list, use the number of elements as the count
#### this doesn't support eg Craft with two Islands and two Mountains
#### you've done that to yourself
if commas != "" then (
count := german_number(length(commas)+2);
alt_target := "Permanente"
)
#### unused style (craft with three)
#### param1 == "three" count == "three"
#### counting style (craft with one or more); (craft with six artifacts)
#### param1 == "one or more" count == "one"; param1 == "six artifacts" count == "six"
#### singular style (craft with creature)
#### param1 == "creature" count == ""
if count == param1.value then
(
#### Exile three other...
rem := rem
+ param1.value
+ " weiteren Permanente, die du kontrollierst und/oder Karten aus deinem Friedhof ins Exil: "
)
else if count != "eins" then
(
#### with one or more...
#### with four or more
#### with two+...
rem := rem
+ (
if count == "eins oder mehreren" then "ein oder mehrere weitere "
else if contains(count, match:"oder") then "die " + count + " weireren "
else "die " + count + " oder mehr weiteren "
#### todo this should list the denumbered param1.value instead
)
+ alt_target
+ (if vowel then ", das du" else ", die du")
+ " kontrollierst und/oder Karten aus deinem Friedhof ins Exil: "
)
else
(
#### with einem Artefakt
#### with einem Kreatur
rem := rem
+ (if target == "Artefakt" then "ein weiteres " else "ein ")
+ target
+ ", "
+ (if vowel then "das du" else "die du")
+ " kontrollierst, oder "
+ (if vowel then "eines " else "eine ") + target
+ (if target == "Kreatur" then "en-karte" else "-karte")
+" aus deinem Friedhof ins Exile: "
)
#### ending and return
rem := rem + "Bringe diese Karte transformiert unter der Kontrolle ihres Besitzers ins Spiel zurück. Spiele Anfertigung wie eine Herexi."
rem
}
][lang_setting("code") or else "en"]()
}
############################################################## The text box
#### Filters for the text box
#### context in which mana symbols are found
mana_context :=
"(?ix) #### case insensitive, ignore whitespace
(^|[[:space:]\"(“']) #### start of a word
(
<match>: #### G: something
| <match>, #### G, tap: something
| [+][ ]?<match>[ ]?— #### Spree
| or[ ]<match> #### Add X, Y, or Z.
| <match>[ ]to[ ]your #### Add X, Y, or Z to your mana pool.
| you[ ]get[ ]<match> #### You get E, you get TK
| <match>[ ]was[ ]spent #### if G was spent to cast
| <match>[ ]can[ ]be[ ]paid
| (pays?|additional|costs?|the|adds?|pay(ed)?[ ](with|using)) #### pay X. creatures cost 1 less. pay an additional G.
([ ]either)? #### pay either X or Y
([ ](<sym[^>]*>)?[-+=]?[VLHSCETKQ\\?XYZIEWUBRG0-9/|]+(</sym[^>]*>)?,)* #### pay X, Y or Z
([ ](<sym[^>]*>)?[-+=]?[VLHSCETKQ\\?XYZIEWUBRG0-9/|]+(</sym[^>]*>)?[ ](and|or|and/or))* #### pay X or Y
[ ]<match>
(
[,.)\"”]|$ #### (end of word)
| [ ][^ .,]*$ #### still typing...
| [ ]( or | and | in | less | more | to ) #### or next word is ...
)
)
| <param-mana><match></param-mana> #### keyword argument that is declared as mana
| <param-cost>[ ]*<match></param-cost> #### keyword argument that is declared as cost
| <param-cost><match>, #### keyword argument that is declared as cost
";
#### remove false positives
mana_un_context := "(mana values? <match>|converted mana costs? <match>|<match> life)"
#### atoms
#### truncates the name of legends
legend_filter := replace@(match:"(, | of | the | \"| “).*", replace: "" )
#### does this frame support Alchemy Rebalanced mana symbol in names?
#### set tab insert atoms
inserts_values := { split_text(set.inserts+";;;;;;;;;", match:";") }
inserts_count := { clamp(length(semicolon_count(set.inserts)), minimum:1, maximum:9) }
#### these are considered a correct 'word' for spellchecking in the text box:
additional_text_words := match@(match:
"(?ix)^(?: #### match whole word
<atom-[^>]*>.*?</atom-[^>]*> #### cardnames and stuff
| [+-]?[0-9X]+ / [+-]?[0-9X]+ #### '3/3', '+X/+X'
)$")
#### Automatically correct errant syntax
auto_correct :=
replace@(match:" its (controller|owner|power|toughness|converted|other)", replace:" its \\1")
+replace@(match:"Then, if" replace:"Then if")
+replace@(match:"([Ff]irst|[Dd]ouble) Strike" replace:"\\1 strike")
+replace@(match:"Splice (Ont|unt|int)" replace:"Splice ont")
+replace@(match:"(ecomes?) the Monarch" replace:"\\1 the monarch")
+replace@(match:"does (combat|[X0-9]+) damage" replace:"deals \\1 damage")
+replace@(
match: "(gains |gain |have |has )" #### preceded by this
+ "(<kw-[^<]><nospellcheck>)" #### inside a kw
+ "([A-Z])" #### match this
replace: { _1 + _2 + to_lower(_3)})
+replace@(
match: "([ ]*: |—| — )" #### preceded by this
+ "([[:lower:]])" #### match this
+ "(?![)])", #### not followed by this
replace: { _1 + to_upper(_2) })
#### Automatically apply errata
auto_errata :=
replace@(match:"converted mana cost", replace:"mana value")
+replace@(match:"(?i)(Totem armor|Totembeistand|Armadura tótem|totémique|Armatura totem|Armadura de totem|族霊鎧|替身甲)", replace:{errata_map[_1] or else _1})
+replace@(match:"hen shuffle your library", replace:"hen shuffle")
+replace@(match:"this (?:ability )?(?:only )?(?:any ?time you could cast|as) a", in_context: "(Activate|Play) <match>n? (instant|sorcery)", replace:"only as a")
#### can be localized via errata_map
errata_map := [
"Totem armor": "Umbra armor",
"Totem Armor": "Umbra armor",
"totem armor": "umbra armor",
"Totembeistand": "Schattenbeistand",
"totembeistand": "schattenbeistand",
"Armadura tótem": "Armadura umbra",
"armadura tótem": "armadura umbra",
"Armure totémique": "Armure dombre",
"armure totémique": "armure dombre",
"Armatura totem": "Armatura essenza",
"armatura totem": "armatura essenza",
"族霊鎧": "陰影鎧",
"替身甲": "本影甲",
"Armadura de totem": "Armadura de sombra",
"armadura de totem": "armadura de sombra"
]
#### the rule text filter
#### - adds reminder text
#### - fills in CARDNAME and INSERT
#### - adds mana symbols
#### - makes text in parentheses italic
#### - indents modals
#### - runs auto correct/errata
#### - spellchecks
#### - margins aren't applied here; they're patched onto this by templates that use them
text_filter :=
#### step 1 : remove all automatic tags
remove_tag@(tag: "<sym-auto>") +
remove_tag@(tag: "<i-auto>") +
remove_tag@(tag: "<b-auto>") +
remove_tag@(tag: "<error-spelling") +
remove_tag@(tag: "<nospellcheck") +
remove_tag@(tag: "<li>") +
remove_tag@(tag: "<bullet>") +
remove_tag@(tag: "<align") +
remove_tag@(tag: "<margin") +
#### step 1b : remove zero-width space used for level spacers
replace@(match:"", replace:"") +
#### step 2a : temp fix for formatting buttons
replace@(
match:"<b></b>",
replace:"BOLDAROUND"
) +
replace@(
match:"<i></i>",
replace:"ITALAROUND"
) +
replace@(
match:"<sym></sym>",
replace:"SYMAROUND"
) +
#### step 2a : reminder text for keywords
expand_keywords@(
condition: {
correct_case or (mode != "pseudo" and not used_placeholders)
}
default_expand: {
chosen(choice:if correct_case or mode == "action" then mode else "lower case", set.automatic_reminder_text) and chosen(choice:mode, set.automatic_reminder_text)
},
combine: {
keyword := "<nospellcheck>{keyword}</nospellcheck>"
reminder := process_english_hints(reminder)
if mode == "pseudo" then "<i-auto>{keyword}</i-auto>"
else keyword + if expand then "<atom-reminder-{mode}> ({reminder})</atom-reminder-{mode}>" else ""
}
) +
#### step 2b : apply face_code
replace@(
match: "face_(.*?)_end",
replace: {face_code(_1)}
) +
#### step 2c : move action keywords' reminder text to the end of the line
replace@(
match: "(<atom-reminder-[^>]+> (?:(?!</kw).*?)</atom-reminder-[^>]+></kw[^>]*>)([^\n]*)", #### removed "| ?<kw-" from lookahead
replace: "\\2\\1"
) +
#### step 2d : when there's an action keyword and another one, then move that to the end of the line
replace@(
match: "(<atom-reminder-[^>]+> (?:(?!</kw)[^\n]*?)</atom-reminder-[^>]+></kw[^>]*>)([^\n]*?)(<atom-reminder-[^>]+> (?:(?!</kw).*?)</atom-reminder-[^>]+></kw[^>]*>)([^\n]*)",
replace: "\\2\\4\\3\\1"
) +
#### step 2e : allow a sentence after lowercase reminder text for equips etc.
#replace@(
# match: "(<kw[^>]+><nospellcheck>[a-z][^<]+</nospellcheck>)(<atom-reminder-(?:expert|custom|old|core)>(?:(?!<kw-).)*</atom-reminder-(?:expert|custom|old|core)></kw[^>]*>)([^\n]+)$",
# replace: "\\1\\3\\2"
# ) +
#### step 2f : remove duplicate reminder text
replace@(
match: "(<atom-reminder-[^>]*>[^)]+[)]</atom-reminder-[^>]*>)([^\n]+)\\1"
replace: "\\2\\1"
) +
#### step 2g : combine reminder texts
replace@(
match: "[)](</atom-reminder-[^>]+></kw-[^>]><atom-reminder-[^>]+> )[(]"
replace: "\\1"
) +
#### step 2h : temp fix for formatting buttons
replace@(
match:"BOLDAROUND",
replace:"<b></b>"
) +
replace@(
match:"ITALAROUND",
replace:"<i></i>"
) +
replace@(
match:"SYMAROUND",
replace:"<sym></sym>"
) +
replace@(
match:"-\n-"
replace:"<soft-line>\n</soft-line>"
) +
#### step 3a : expand shortcut word CARDNAME
replace@(
match: "CARDNAME>?", #### >? is here so after replacement, the mouse snaps to the end of </atom>
in_context: "(^|[[:space:]]|\\(|,|\\.|:|“|\"|'||-|—|/|)<match>", #### TODO: Allow any punctuation before
replace: "<atom-cardname></atom-cardname>"
) +
#### step 3b : expand shortcut word LEGENDNAME
replace@(
match: "LEGENDNAME>?",
in_context: "(^|[[:space:]]|\\(|,|\\.|:|“|\"|'||/|)<match>", #### TODO: Allow any punctuation before
replace: "<atom-legname></atom-legname>"
) +
#### step 3c : fill in atom fields
tag_contents@(
tag: "<atom-cardname>",
contents: { "<nospellcheck>" + (if card_name=="" then "CARDNAME" else strip_card_codes(card_name, atom:true)) + "</nospellcheck>" }
) +
tag_contents@(
tag: "<atom-legname>",
contents: { "<nospellcheck>" + (if card_name=="" then "LEGENDNAME" else legend_filter(strip_card_codes(card_name, atom:true))) + "</nospellcheck>" }
) +
replace@(
match: "INS([1-9])",
in_context: "(^|[[:space:]]|\\(|,|\\.|:|“|\"|'||/|)<match>",
replace: "<atom-insert\\1></atom-insert\\1>"
) +
{
out := input
for x from 1 to inserts_count() do
out := tag_contents(out,
tag: "<atom-insert"+x+">",
contents: { "<nospellcheck>" + (if inserts_values()[x-1] == "" then "INS"+x else inserts_values()[x-1]) + "</nospellcheck>" }
)
out
} +
#### step 4 : explict non mana symbols
replace@(
match: "\\][-+=]?[VLHSCETQ\\?XYZIWUBRG0-9/|]+\\[",
replace: {"<nosym>" + mana_filter_t() + "</nosym>"}
) +
#### step 5 : add mana & tap symbols
replace@(
match: "(?<!\\/)([+=-][XYZ0-9|]+)(?!\\/)",
in_context: mana_context,
replace: {"<sym-auto>" + _1 + "</sym-auto>"}
) +
replace@(
match: "\\b((TK)+)(T)?\\b",
in_context: mana_context,
replace: {"<sym-auto>" + _1 + "</sym-auto>" + _3}
) +
replace@(
match: "\\b[VLHSCETQ\\?XYZIWUBRG0-9/|]+\\b",
in_context: mana_context,
replace: {"<sym-auto>" + mana_filter_t() + "</sym-auto>"}
) +
#### step 5b : remove false positive mana & tap symbols
replace@(
match: "<sym-auto>([VLHSCETQ\\?XYZIWUBRG0-9/|]+)</sym-auto>",
in_context: mana_un_context,
replace: "\\1"
) +
#### step 5c : add explicit mana symbols
replace@(
match: "\\[[-+=]?[VLHSCETQE\\?XYZIWUBRG0-9/|]+\\]",
replace: {"<sym>" + mana_filter_t() + "</sym>"}
) +
#### step 6 : curly quotes
{
if set.curly_quotes then curly_quotes(input) else input
} +
#### step 7 : italicize text in parenthesis
replace@(
match: "[(]([^)\n]|[(][^)\n]*[)])*[)]?",
in_context: "(^|[[:space:]])<match>|<atom-keyword><match></",
replace: "<i-auto>&</i-auto>"
) +
#### step 7b : indent bullets
replace@(
match: "^(• |[+] ?)([^\n]+\n?)",
replace: {"<li><bullet>" + _1 + "</bullet>" + _2 + "</li>"}
) +
#### step 7c : clean up modals
{
if is_modal(input)
then bump_text(softline_ripper(input))
else input
} +
#### step 8 : automatic capitalization, but not after "("
#replace@(
# match: "([ ]*: |—| — )" #### preceded by this
# + "([[:lower:]])" #### match this
# + "(?![)])", #### not followed by this
# replace: { _1 + to_upper(_2) }) +
#### step 9 : spellcheck
{
if set.auto_correct then
auto_correct(input)
else input
} +
{
if set.auto_errata then
auto_errata(input)
else input
} +
{
if language().code == "ja" or language().code == "zht" or language().code == "zhs" then input
else if set.mark_errors then
check_spelling(
language: language().spellcheck_code,
extra_dictionary: "/magic.mse-game/dictionary/magic-words",
extra_match: additional_text_words
)
else input
}
#### the flavor text filter
#### - makes all text italic
flavor_text_filter_default := { "<i-flavor></i-flavor>" }
flavor_text_filter :=
#### step 1 : remove italic tags
remove_tag@(tag: "<i-flavor>") +
#### step 2 : surround by <i> tags
{ "<i-flavor>" + input + "</i-flavor>" } +
#### curly quotes
{ if set.curly_quotes then curly_quotes(input) else input } +
#### spellcheck
{
if set.mark_errors
then check_spelling(language:language().spellcheck_code)
else input
}
############################################################## Face code
#### this is a workaround to let reminder code access the proper face of a card
card_face := {
front := card[input]
back := if card[input+"_2"] or else "" != "" then card[input+"_2"] else card[input]
if match(margin_code, match:"(text[2456]|lv[5678])") then back else front
}
face_code := {
face := ""
if margin_code == "text2" or margin_code == "lv5" or margin_code == "lv6" or margin_code == "lv7" or margin_code == "lv8" then face := "_2"
output := face_scripts[input](face) or else if_parse(input, face:face) or else input
output
}
flip_face := {
if input == "_2" then "" else "_2"
}
face_scripts := [
iscreature: {is_creature(card["type"+face])},
iscreaturish: {is_creaturish(card["type"+face])},
isenchantment: {is_enchantment(card["type"+face])},
isartifact: {is_artifact(card["type"+face])},
island: {is_land(card["type"+face])},
isspell: {is_spell(card["type"+face])},
istarget: {is_targeted(card["text"+face])},
subtypes: {separate_words(card["sub_type"+face], spacer: " ")}
contains: {
contains(card[field+face], match:query)
},
notcontains: {not contains(card[field+face], match:query)},
name: {card["name"+face]},
cost: {card["casting_cost"+face]},
altname: {card["name"+flip_face(face)]},
altcost: {card["casting_cost"+flip_face(face)]},
]
expand_facecodes := [
subtype: "sub_type",
castingcost: "casting_cost",
manacost: "casting_cost"
]
if_parse := replace@(
match: "if_(.*)_then_(.*)_else_(.*)",
replace: {if_scripts(_1, t:_2, f:_3)}
)
if_scripts := {
contCheck := split_text(input, match:"_")
func := contCheck[0]
field := ""
query := "^$"
if length(contCheck) == 3 then (
field := contCheck[0]
func := contCheck[1]
query := contCheck[2]
)
field := expand_facecodes[field] or else field
if face_scripts[func](face, field:field, query:query) or else false then t else f
}
############################################################## Level Margins
#### these will be determined by the style affecting the margins and otherwise be 0
margin_left := {0}
margin_right := {0}
margin_top := {0}
remove_margins := replace@(
match: "</?margin:[0-9]+(:+[0-9]+)?(:+[0-9]+)?>",
replace:""
)
#### remove 0 margins and margins with no text
cull_margins := replace@(match:"</?margin:0(:+0)?(:+0)?>", replace:"")+
replace@(match:"<margin:[0-9]+:?[0-9]*:?[0-9]*></margin:[0-9]+:?[0-9]*:?[0-9]*>", replace:"")
#### this gives a big array so we can grab_margins()["lv1"] etc anywhere
grab_margins :=
{[
lv1: [margin_left("lv1"), margin_right("lv1"), margin_top("lv1")],
lv2: [margin_left("lv2"), margin_right("lv2"), margin_top("lv2")],
lv3: [margin_left("lv3"), margin_right("lv3"), margin_top("lv3")],
lv4: [margin_left("lv4"), margin_right("lv4"), margin_top("lv4")],
lv5: [margin_left("lv5"), margin_right("lv5"), margin_top("lv5")],
lv6: [margin_left("lv6"), margin_right("lv6"), margin_top("lv6")],
lv7: [margin_left("lv7"), margin_right("lv7"), margin_top("lv7")],
lv8: [margin_left("lv8"), margin_right("lv8"), margin_top("lv8")],
lv9: [margin_left("lv9"), margin_right("lv9"), margin_top("lv9")],
lv10: [margin_left("lv10"), margin_right("lv10"), margin_top("lv10")],
lv11: [margin_left("lv11"), margin_right("lv11"), margin_top("lv11")],
lv12: [margin_left("lv12"), margin_right("lv12"), margin_top("lv12")],
lv13: [margin_left("lv13"), margin_right("lv13"), margin_top("lv13")],
lv14: [margin_left("lv14"), margin_right("lv14"), margin_top("lv14")],
lv15: [margin_left("lv15"), margin_right("lv15"), margin_top("lv15")],
lv16: [margin_left("lv16"), margin_right("lv16"), margin_top("lv16")],
lv17: [margin_left("lv17"), margin_right("lv17"), margin_top("lv17")],
lv18: [margin_left("lv18"), margin_right("lv18"), margin_top("lv18")],
lv19: [margin_left("lv19"), margin_right("lv19"), margin_top("lv19")],
lv20: [margin_left("lv20"), margin_right("lv20"), margin_top("lv20")],
lv21: [margin_left("lv21"), margin_right("lv21"), margin_top("lv21")],
lv22: [margin_left("lv22"), margin_right("lv22"), margin_top("lv22")],
text: [margin_left("text"), margin_right("text"), margin_top("text")],
text2: [margin_left("text2"), margin_right("text2"), margin_top("text2")],
text3: [margin_left("text3"), margin_right("text3"), margin_top("text3")],
text4: [margin_left("text4"), margin_right("text4"), margin_top("text4")],
text5: [margin_left("text5"), margin_right("text5"), margin_top("text5")],
text6: [margin_left("text6"), margin_right("text6"), margin_top("text6")],
flavor_text: [margin_left("flavor_text"), margin_right("flavor_text"), margin_top("flavor_text")],
flavor_text2: [margin_left("flavor_text2"), margin_right("flavor_text2"), margin_top("flavor_text2")],
flavor_text3: [margin_left("flavor_text3"), margin_right("flavor_text3"), margin_top("flavor_text3")],
flavor_text4: [margin_left("flavor_text4"), margin_right("flavor_text4"), margin_top("flavor_text4")],
combined_text: [margin_left("combined_text"), margin_right("combined_text"), margin_top("combined_text")],
combined_text2: [margin_left("combined_text2"), margin_right("combined_text2"), margin_top("combined_text2")],
combined_text3: [margin_left("combined_text3"), margin_right("combined_text3"), margin_top("combined_text3")],
combined_text4: [margin_left("combined_text4"), margin_right("combined_text4"), margin_top("combined_text4")],
chapter_text: [margin_left("chapter_text"), margin_right("chapter_text"), margin_top("chapter_text")],
chapter_text2: [margin_left("chapter_text2"), margin_right("chapter_text2"), margin_top("chapter_text2")],
unknown: [0,0,0]
]}
#### then with apply_margins(field, name:fieldname), add the margins into the text
apply_margins := {
margin_data := grab_margins()[name] or else [0,0,0]
cull_margins("<margin:" + margin_data[0] + ":" + margin_data[1] + ":" + margin_data[2] + ">" + remove_margins(input) + "</margin:" + margin_data[0] + ":" + margin_data[1] + ":" + margin_data[2] + ">")
}
bump_text := {
blocks := split_text(input, match:"\n");
new_text := blocks[0];
for x from 1 to length(blocks)-1 do new_text := new_text + "\n" + bumper(blocks[x])
new_text
}
bumper := {
#### if this text isn't modal, add a 5 px margin
if is_modal(input) then input else
cull_margins("<margin:0:0:5>" + remove_margins(input) + "</margin:0:0:5>")
}
############################################################## Saga witchery
#### number of chapter symbols each chapter textbox has
#### example, symbols on abilities 2,2,3 returns [0,2,1]
saga_lore_count := {
one := 0
two := 0
three := 0
four := 0
five := 0
six := 0
seven := 0
eight := 0
for x from 0 to length(input)-1 do
if input[x] == "1" then one := one +1
else if input[x] == "2" then two := two +1
else if input[x] == "3" then three := three +1
else if input[x] == "4" then four := four +1
else if input[x] == "5" then five := five +1
else if input[x] == "6" then six := six +1
else if input[x] == "7" then seven := seven +1
else eight := eight +1
[one, two, three, four, five, six, seven]
}
#### index of given chapter number in above array
#### example, 2,2,3, returns 1,2,1
#### i tried to make this shorter but this is the only one that deigned to function
saga_ch_placement := {
box1 := 0
box2 := 0
box3 := 0
box4 := 0
one := 0
two := 0
three := 0
four := 0
five := 0
six := 0
seven := 0
len := length(input)
if len >= 1 then (
if input[0] == "1" then (
box1 := box1 +1
one := box1+0
)else if input[0] == "2" then (
box2 := box2 +1
one := box2+0
)else if input[0] == "3" then (
box3 := box3 +1
one := box3+0
)else if input[0] == "4" then (
box4 := box4 +1
one := box4+0
)else (one := one)
)else (one := one)
if len >= 2 then (
if input[1] == "1" then (
box1 := box1 +1
two := box1+0
)else if input[1] == "2" then (
box2 := box2 +1
two := box2+0
)else if input[1] == "3" then (
box3 := box3 +1
two := box3+0
)else if input[1] == "4" then (
box4 := box4 +1
two := box4+0
)else (two := two)
)else (two := two)
if len >= 3 then (
if input[2] == "1" then (
box1 := box1 +1
three := box1+0
)else if input[2] == "2" then (
box2 := box2 +1
three := box2+0
)else if input[2] == "3" then (
box3 := box3 +1
three := box3+0
)else if input[2] == "4" then (
box4 := box4 +1
three := box4+0
)else (three := three)
)else (three := three)
if len >= 4 then (
if input[3] == "1" then (
box1 := box1 +1
four := box1+0
)else if input[3] == "2" then (
box2 := box2 +1
four := box2+0
)else if input[3] == "3" then (
box3 := box3 +1
four := box3+0
)else if input[3] == "4" then (
box4 := box4 +1
four := box4+0
)else (four := four)
)else (four := four)
if len >= 5 then (
if input[4] == "1" then (
box1 := box1 +1
five := box1+0
)else if input[4] == "2" then (
box2 := box2 +1
five := box2+0
)else if input[4] == "3" then (
box3 := box3 +1
five := box3+0
)else if input[4] == "4" then (
box4 := box4 +1
five := box4+0
)else (five := five)
)else (five := five)
if len >= 6 then (
if input[5] == "1" then (
box1 := box1 +1
six := box1+0
)else if input[5] == "2" then (
box2 := box2 +1
six := box2+0
)else if input[5] == "3" then (
box3 := box3 +1
six := box3+0
)else if input[5] == "4" then (
box4 := box4 +1
six := box4+0
)else (six := six)
)else (six := six)
if len >= 7 then (
if input[6] == "1" then (
box1 := box1 +1
seven := box1+0
)else if input[6] == "2" then (
box2 := box2 +1
seven := box2+0
)else if input[6] == "3" then (
box3 := box3 +1
seven := box3+0
)else if input[6] == "4" then (
box4 := box4 +1
seven := box4+0
)else (seven := seven)
)else (seven := seven)
[one, two, three, four, five, six, seven]
}
############################################################## Typelines
#### Move the cursor past the separator in the p/t and type boxes
type_over_pt := replace@(match:"/$", replace:"")
type_over_type := replace@(match:" ?[-:]$", replace:"")
super_type_filter_default := { "" }
super_type_filter := {
input := remove_tag(tag: "<word-list-")
input := type_over_type()
tag := "word-list-type-" + lang_setting("code")
"<{tag}>{input}</{tag}>"
}
sub_type_filter_default := { "" }
split_at_spaces := split_text@(match: " +")
remove_leading_spaces := replace@(match: "^ +", replace: "")
remove_trailing_soft_tags := replace@(match: "<soft>.*?</soft>$", replace: "")
replace_soft_tags := replace@(match: "<soft>.*?</soft>", replace: " ")
sub_type_filter :=
{
subtype_separator := lang_setting("subtype_separator")
code := lang_setting("code")
input := remove_tag(input, tag: "<word-list")
input := remove_trailing_soft_tags(input)
input := replace_soft_tags(input)
#### What word list to use?
list_type_rest := if lang_setting("is_creature")(type) or lang_setting("is_kindred")(type) then "class-"+code
else if lang_setting("is_land")(type) then "land"
else if lang_setting("is_artifact")(type) then "artifact"
else if lang_setting("is_enchantment")(type) then "enchantment"
else if lang_setting("is_spell")(type) then "spell"
else if lang_setting("is_planeswalker")(type) or lang_setting("is_emblem")(type) then "planeswalker"
else if lang_setting("is_plane")(type) then "plane-"+code
else if lang_setting("is_battle")(type) then "battle"
else if lang_setting("is_dungeon")(type) then "dungeon"
else nil
if list_type_rest != nil then
(
#### Transform subtype_separators into spaces, we'll transform them back later
input := replace(input, match: subtype_separator, replace: " ")
input := replace(input, match: remove_tag(subtype_separator, tag: "<atom-sep"), replace: " ")
input := remove_leading_spaces(input)
#### Use race list for first sub type of creatures
list_type_first := if lang_setting("is_creature")(type) or lang_setting("is_kindred")(type)
then "race-"+code
else list_type_rest
#### Wrap wordlist tag around each part
replace_spaced_sub_type := replace_spaced_sub_type_map[code]
max_count := 2*length(split_at_spaces(input))-1 #### We iterate on the words and the spaces
sub_types := for i from 0 to max_count do
(
if input == "" then "" else (
#### Check for leading spaces
new_input := remove_leading_spaces(input)
if new_input != input then
(
spaces := replace(input, match: regex_escape(new_input) + "$", replace: "")
input := new_input
spaces
) else (
#### Check for space separated sub types
new_input := replace_spaced_sub_type(input)
if new_input != input then
(
sub_type := replace(input, match: regex_escape(new_input) + "$", replace: "")
input := new_input
if i == 0 then "<word-list-{list_type_first}>" + sub_type + "</word-list-{list_type_first}>"
else "<word-list-{list_type_rest}>" + sub_type + "</word-list-{list_type_rest}>"
) else (
#### Check for single word sub types
split := split_at_spaces(input)
input := if length(split) > 1 then replace(input, match: "^" + regex_escape(split.0), replace: "") else ""
if i == 0 then "<word-list-{list_type_first}>" + split.0 + "</word-list-{list_type_first}>"
else "<word-list-{list_type_rest}>" + split.0 + "</word-list-{list_type_rest}>")))
)
#### Add separators between types, keep additional spaces if there are more than one
sub_types := replace(sub_types, match: "(</word-list[^>]*>)( *)(<word-list)" replace: { substring(_2, begin: 1) + _1 + subtype_separator + _3})
#### Add a new wordlist box at the end
if sub_types == "" then "<word-list-{list_type_first}></word-list-{list_type_first}>"
else sub_types + "<soft>" + subtype_separator + "</soft><word-list-{list_type_rest}></word-list-{list_type_rest}>"
) else input #### Do nothing if we don't know the type
}
#### all sub types, for word list
space_to_comma := replace@(match:" ", replace:",")
only_first := replace@(match:" .*", replace:"")
only_next := replace@(match:"^[^ ]* ?", replace:"")
all_sub_types := {
for each card in set do
if lang_setting(setting)(card.super_type) then "," + space_to_comma(to_text(card.sub_type)) else ""
}
all_races := {
for each card in set do
if lang_setting("is_creature")(card.super_type) or lang_setting("is_kindred")(card.super_type) then
"," + only_first(to_text(card.sub_type))
else ""
}
all_classes := {
for each card in set do
if lang_setting("is_creature")(card.super_type) then
"," + space_to_comma(only_next(to_text(card.sub_type)))
else ""
}
############################################################## Modal DFC flag hints
auto_flags := {true}
front_modal_hint := {
if not auto_flags() then ["", ""]
else if remove_tags(card.sub_type_2) != "" then [card.sub_type_2, "<sym>"+card.casting_cost_2+"</sym>"]
else if card.casting_cost_2 != "" then [main_type(card.super_type_2), "<sym>"+card.casting_cost_2+"</sym>"]
else [main_type(card.super_type_2), mana_ability(card.rule_text_2)]
}
back_modal_hint := {
if not auto_flags() then ["", ""]
else if remove_tags(card.sub_type) != "" then [card.sub_type, "<sym>"+card.casting_cost+"</sym>"]
else if card.casting_cost != "" then [main_type(card.super_type), "<sym>"+card.casting_cost+"</sym>"]
else [main_type(card.super_type), mana_ability(card.rule_text)]
}
mana_ability := {
abils := break_text(input, match:"(</?sym(-auto)?>)?T(</?sym(-auto)?>)?: Add (</?sym(-auto)?>)?(W|U|B|R|G|C)(</?sym(-auto)?>)?(, | or )?(</?sym(-auto)?>)?(W|U|B|R|G|C)?(</?sym(-auto)?>)?(, or )?(</?sym(-auto)?>)?(W|U|B|R|G|C)?(</?sym(-auto)?>)?.")
abils[0] or else ""
}
main_type := {
types := main_types(input)
if length(types) == 0 then ""
else if includes("Creature", array:types)
then "Creature"
else if includes("Land", array:types)
then "Land"
else types[0]
}
main_types := {
types := break_text(input, match:"(Land|Instant|Sorcery|Artifact|Enchantment|Creature|Planeswalker)")
types or else [""]
}
#### TODO we'll be able to remove this once transform corners are a card field
node_script := { if card.shape == "double faced" then "transform day" else "none" }
############################################################## Flavor bar
bar_equation := {if card_style.text.layout.blocks[1].bottom or else 0 > 0 then card_style.text.top + 0.5*(card_style.text.layout.blocks[0].bottom+card_style.text.layout.blocks[1].top) else old_bar_equation()}
bar_equation2 := {if card_style.text_2.layout.blocks[0].bottom or else 0 > 0 then card_style.text_2.top + 0.5*(card_style.text_2.layout.blocks[0].bottom+card_style.text_2.layout.blocks[1].top) else old_bar_equation2()}
bar_equation3 := {if card_style.text_3.layout.blocks[0].bottom or else 0 > 0 then card_style.text_3.top + 0.5*(card_style.text_3.layout.blocks[0].bottom+card_style.text_3.layout.blocks[1].top) else old_bar_equation3()}
#### As of MSE 2.1.2 ^that is all we need to do
#### Previous versions needed the noise down below
#### Which is kept for backwards compatibility
#### And a record of the before times
chop_top := {0}
chop_bot := {0}
bar_offset := {0}
offset_lines := {0}
chop_top2 := {0}
chop_bot2 := {0}
bar_offset2 := {0}
offset_lines2 := {0}
chop_top3 := {0}
chop_bot3 := {0}
bar_offset3 := {0}
offset_lines3 := {0}
#### Set chop_top(), chop_bot(), bar_offset(), and offset_lines to 0 to reduce replacements in chopping frames
#### Full equations to use in chopping templates below
## chop_top := {if styling.chop_top == "" then 0 else if comma_count(styling.chop_top) == "," or comma_count(styling.chop_top) == ",," then split_text(match:",", styling.chop_top).0 else styling.chop_top}
## chop_bot := {if comma_count(styling.chop_top) == ",," then split_text(match:",", styling.chop_top).1 else if styling.chop_bottom == "" then 0 else styling.chop_bottom}
## bar_offset := {if styling.flavor_bar_offset == "-" or styling.flavor_bar_offset == "+" then 0 else to_number(styling.flavor_bar_offset)}
## offset_lines := {offset_counter(styling.flavor_bar_offset)}
top_of_textbox := {card_style.text.top }
bottom_of_textbox := {card_style.text.bottom }
top_of_textbox2 := {card_style.text_2.top }
bottom_of_textbox2 := {card_style.text_2.bottom }
top_of_textbox3 := {card_style.text_3.top }
bottom_of_textbox3 := {card_style.text_3.bottom }
offset_counter := {length(filter_text(input, match:"u")) - length(filter_text(input, match:"d"))}
paragraph_count := filter_text@(match:"\n")
hard_paragraph_count :=
replace@(match:"<soft-line>\n", replace:"")+ #### count hard breaks for their extra space
filter_text@(match:"\n")
soft_break_filter :=
filter_text @(match:"<", in_context: "<match>soft-line>") #### count soft breaks for quotes
word_split := split_text@(match:" ") #### split words to better calculate line lengths
small_filter := filter_text@(match:"[\\.,\\?!il]") #### grab the tiny characters
fb_length := {length(input) - 0.3 * length(small_filter(input))}#### reduce the effect of tiny characters
calc_lines := { sum := 0 #### estimate lines by character limit
lines := 1 #### minimum of 1
for e from 0 to length(input)-1 do (
sum := sum + fb_length(input[e]);
if sum > char then ( #### if new word is over the limit
lines := lines + 1; #### add new line
sum := fb_length(input[e])) #### reset the sum
else
sum := sum + 1; #### else add it and a space to the sum
)
lines #### return number of lines
}
lines_of_text := { #### estimate lines in break blocks
lines := 0 #### further improves the previous eq
for x from 0 to length(input)-1 do
if input[x] or else "" != "" then #### if the break isn't empty, check it
lines := lines + calc_lines(word_split(input[x]), char:char)
lines
}
flavor_text := {split_text(match:"\n", remove_tags(card.flavor_text+"\n"))} #### remove tags, add \n so .1 doesn't explode
hard_flavor_break := { if not contains(card.flavor_text, match:"\n") then 0 else if contains(card.flavor_text, match:"<soft-line>\n") then 0 else if lines_of_rules() >= 3 then -3 else -2}
font_size := {min(14,round_near(card_style.text.content_height / card_style.text.content_lines) - 8)} #### approximate font size
adj_char_width := {7.35 * min(14, font_size()+0.95) / 14} #### average char width, adjusted for font size
char_per_line := {min(52,round_up(card_style.text.content_width / adj_char_width())+1.5)} #### approximate character limit. very rarely over 52 but standard eq can reach 60+
lines_of_flavor := {lines_of_text(flavor_text(), char:char_per_line())}
lines_of_rules := { card_style.text.content_lines - lines_of_flavor() } #### rules of lines for ratio weirdness
line_height := {(card_style.text.content_height / card_style.text.content_lines)}
padding_height := { 0.5*(bottom_of_textbox() - top_of_textbox() - card_style.text.content_height) } #### space between top of textbox and text
linebreak_height := { 2*length(hard_paragraph_count(card.rule_text)) }
#### correction for ratio of rules/flavor causing weirdness
uneven_correction := { if lines_of_flavor() == 1 then max(4, (card_style.text.content_lines - (2*lines_of_flavor()))) else (card_style.text.content_lines - (2*lines_of_flavor())) }
#### add it all up
#### old_bar_equation is compatibilty for 2.0.0
old_bar_equation := { top_of_textbox() + padding_height() + card_style.text.content_height - line_height()*(lines_of_flavor() + offset_lines()) + linebreak_height() - uneven_correction() + front_corr() + bar_offset() + hard_flavor_break() +1 }
flavor_text2 := {split_text(match:"\n", remove_tags(card.flavor_text_2+"\n"))} #### remove tags, add \n so .1 doesn't explode
hard_flavor_break2 := { if not contains(card.flavor_text_2, match:"\n") then 0 else if contains(card.flavor_text_2, match:"<soft-line>\n") then 0 else if lines_of_rules2() >= 3 then -3 else -2}
font_size2 := {min(14,round_near(card_style.text_2.content_height / card_style.text_2.content_lines) - 8)} #### approximate font size
adj_char_width2 := {7.35 * min(14, font_size2()+0.95) / 14} #### average char width, adjusted for font size
char_per_line2 := {min(52,round_up(card_style.text_2.content_width / adj_char_width2())+1.5)} #### approximate character limit. very rarely over 52 but standard eq can reach 60+
lines_of_flavor2 := {lines_of_text(flavor_text2(), char:char_per_line2())}
lines_of_rules2 := { card_style.text_2.content_lines - lines_of_flavor2() } #### rules of lines for ratio weirdness
line_height2 := {(card_style.text_2.content_height / card_style.text_2.content_lines)}
padding_height2 := { 0.5*(bottom_of_textbox2() - top_of_textbox2() - card_style.text_2.content_height) } #### space between top of textbox and text
linebreak_height2 := { 2*length(hard_paragraph_count(card.rule_text_2)) }
#### correction for ratio of rules/flavor causing weirdness
uneven_correction2 := { if lines_of_flavor2() == 1 then max(4, (card_style.text_2.content_lines - (2*lines_of_flavor2()))) else (card_style.text_2.content_lines - (2*lines_of_flavor2())) }
#### add it all up
old_bar_equation2 := { top_of_textbox2() + padding_height2() + card_style.text_2.content_height - line_height2()*(lines_of_flavor2() + offset_lines2()) + linebreak_height2() - uneven_correction2() + back_corr() + bar_offset2() + hard_flavor_break2() +1 }
flavor_text3 := {split_text(match:"\n", remove_tags(card.flavor_text_3+"\n"))} #### remove tags, add \n so .1 doesn't explode
hard_flavor_break3 := { if not contains(card.flavor_text_3, match:"\n") then 0 else if contains(card.flavor_text_3, match:"<soft-line>\n") then 0 else if lines_of_rules3() >= 3 then -3 else -2}
font_size3 := {min(14,round_near(card_style.text_3.content_height / card_style.text_3.content_lines) - 8)} #### approximate font size
adj_char_width3 := {7.35 * min(14, font_size3()+0.95) / 14} #### average char width, adjusted for font size
char_per_line3 := {min(52,round_up(card_style.text_3.content_width / adj_char_width3())+1.5)} #### approximate character limit. very rarely over 52 but standard eq can reach 60+
lines_of_flavor3 := {lines_of_text(flavor_text3(), char:char_per_line3())}
lines_of_rules3 := { card_style.text_3.content_lines - lines_of_flavor3() } #### rules of lines for ratio weirdness
line_height3 := {(card_style.text_3.content_height / card_style.text_3.content_lines)}
padding_height3 := { 0.5*(bottom_of_textbox3() - top_of_textbox3() - card_style.text_3.content_height) } #### space between top of textbox and text
linebreak_height3 := { 2*length(hard_paragraph_count(card.rule_text_3)) }
#### correction for ratio of rules/flavor causing weirdness
uneven_correction3 := { if lines_of_flavor3() == 1 then max(4, (card_style.text_3.content_lines - (2*lines_of_flavor3()))) else (card_style.text_3.content_lines - (2*lines_of_flavor3())) }
#### add it all up
old_bar_equation3 := { top_of_textbox3() + padding_height3() + card_style.text_3.content_height - line_height3()*(lines_of_flavor3() + offset_lines3()) + linebreak_height3() - uneven_correction3() + third_corr() + bar_offset3() + hard_flavor_break3() +1 }
#### long correction coefficient based off several sets of data
front_corr := {correction_coeff(lof:lines_of_flavor(), lor:lines_of_rules(), lbh:linebreak_height())}
back_corr := {correction_coeff(lof:lines_of_flavor2(), lor:lines_of_rules2(), lbh:linebreak_height2())}
third_corr := {correction_coeff(lof:lines_of_flavor3(), lor:lines_of_rules3(), lbh:linebreak_height3())}
correction_coeff := {
(if lor == 1 then
(if lof == 1 then 3
else if lof == 2 then 1
else if lof == 3 then 1.5
else if lof == 4 then 0
else 5 - lof)
else if lor == 2 and lbh == 2 then
(if lof == 1 then 1
else if lof == 2 then 1
else if lof == 3 then 2
else if lof == 4 then 2
else 3)
else if lor == 2 then
(if lof == 1 then 1
else if lof == 2 then 0
else if lof == 3 then 0
else if lof == 4 then 0
else -1)
else if lor == 3 and lbh == 2 then
(if lof == 1 then 0
else if lof == 2 then 0
else if lof == 3 then 1
else if lof == 4 then 1
else 2)
else if lor == 3 then
(if lof == 1 then 0
else if lof == 2 then -1
else if lof == 3 then -0.5
else if lof == 4 then -1
else 0)
else if lor == 4 and lbh == 2 then
(-2 + lof)
else if lor == 4 then
(if lof == 1 then -1
else if lof == 2 then 0
else if lof == 3 then -0.5
else -1)
else if lor == 5 and lbh == 4 then
(-5 + lof)
else if lor == 5 and lbh == 2 then
(-2 + lof)
else if lor == 5 then
(2 - lof)
else if lor == 6 and lbh == 2 then
(-1 - lof)
else if lor == 6 then
(2 - lof)
else 0) + (if lbh >= 4 then 0.5*lbh-1)
}
############################################################## Watermarks
card_spotlight := { "/magic-mainframe-watermarks.mse-include/spotlight/" + card_new_color() + "spotlight.png" }
custom_watermark_1 := { if set.custom_watermark_1 != "" then "/magic-watermarks.mse-include/" + set.custom_watermark_1 else "/magic-watermarks.mse-include/planeswalker.png" }
custom_watermark_2 := { if set.custom_watermark_2 != "" then "/magic-watermarks.mse-include/" + set.custom_watermark_2 else "/magic-watermarks.mse-include/planeswalker.png" }
custom_watermark_3 := { if set.custom_watermark_3 != "" then "/magic-watermarks.mse-include/" + set.custom_watermark_3 else "/magic-watermarks.mse-include/planeswalker.png" }
custom_watermark_4 := { if set.custom_watermark_4 != "" then "/magic-watermarks.mse-include/" + set.custom_watermark_4 else "/magic-watermarks.mse-include/planeswalker.png" }
custom_watermark_5 := { if set.custom_watermark_5 != "" then "/magic-watermarks.mse-include/" + set.custom_watermark_5 else "/magic-watermarks.mse-include/planeswalker.png" }
custom_watermark_6 := { if set.custom_watermark_6 != "" then "/magic-watermarks.mse-include/" + set.custom_watermark_6 else "/magic-watermarks.mse-include/planeswalker.png" }
custom_watermark_7 := { if set.custom_watermark_7 != "" then "/magic-watermarks.mse-include/" + set.custom_watermark_7 else "/magic-watermarks.mse-include/planeswalker.png" }
custom_watermark_8 := { if set.custom_watermark_8 != "" then "/magic-watermarks.mse-include/" + set.custom_watermark_8 else "/magic-watermarks.mse-include/planeswalker.png" }
custom_watermark_9 := { if set.custom_watermark_9 != "" then "/magic-watermarks.mse-include/" + set.custom_watermark_9 else "/magic-watermarks.mse-include/planeswalker.png" }
custom_watermark_10 := { if set.custom_watermark_10 != "" then "/magic-watermarks.mse-include/" + set.custom_watermark_10 else "/magic-watermarks.mse-include/planeswalker.png" }
custom_watermark_a := {"/magic-watermarks.mse-include/planeswalker.png"}
custom_watermark_b := {"/magic-watermarks.mse-include/planeswalker.png"}
invert_watermark := { false }
invert_watermark2 := { false }
invert_watermark3 := { false }
card_new_color := {
if card.card_color == "white" then "w"
else if card.card_color == "blue" then "u"
else if card.card_color == "black" then "b"
else if card.card_color == "red" then "r"
else if card.card_color == "green" then "g"
else if contains(card.card_color, match:"artifact") then "a"
else if contains(card.card_color, match:"multi") or contains(card.card_color, match:"hybrid") then "m"
else "c"
}
# Watermark images
wm_directory := "/magic-modules.mse-include/watermarks/"
watermark_scripts :=
[
"none": { "" }
"mana symbol white": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_w.png") }
"mana symbol blue": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_u.png") }
"mana symbol black": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_b.png") }
"mana symbol red": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_r.png") }
"mana symbol green": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_g.png") }
"mana symbol colorless": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_c.png") }
"mana symbol snow": { watermark_blend(wm_directory + "mana symbols/watermark_s.png") }
"mana symbol old white": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_w_old.png") }
"mana symbol old blue": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_u_old.png") }
"mana symbol old black": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_b_old.png") }
"mana symbol old red": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_r_old.png") }
"mana symbol old green": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_g_old.png") }
"mana symbol old colorless": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_c_old.png") }
"mana symbol hi res white": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_w_big.png") }
"mana symbol hi res blue": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_u_big.png") }
"mana symbol hi res black": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_b_big.png") }
"mana symbol hi res red": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_r_big.png") }
"mana symbol hi res green": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_g_big.png") }
"mana symbol hi res colorless": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "mana symbols/watermark_c_big.png") }
"transparent mana symbol white": { watermark_blend(colored: true, alpha: 0.45, dark_alpha: 0.30, wm_directory + "mana symbols/watermark_w.png") }
"transparent mana symbol blue": { watermark_blend(colored: true, alpha: 0.35, dark_alpha: 0.30, wm_directory + "mana symbols/watermark_u.png") }
"transparent mana symbol black": { watermark_blend(colored: true, alpha: 0.30, dark_alpha: 0.45, wm_directory + "mana symbols/watermark_b.png") }
"transparent mana symbol red": { watermark_blend(colored: true, alpha: 0.35, dark_alpha: 0.30, wm_directory + "mana symbols/watermark_r.png") }
"transparent mana symbol green": { watermark_blend(colored: true, alpha: 0.35, dark_alpha: 0.30, wm_directory + "mana symbols/watermark_g.png") }
"transparent mana symbol old white": { watermark_blend(colored: true, alpha: 0.4, dark_alpha: 0.4, wm_directory + "mana symbols/watermark_w_old.png") }
"transparent mana symbol old blue": { watermark_blend(colored: true, alpha: 0.4, dark_alpha: 0.4, wm_directory + "mana symbols/watermark_u_old.png") }
"transparent mana symbol old black": { watermark_blend(colored: true, alpha: 0.4, dark_alpha: 0.4, wm_directory + "mana symbols/watermark_b_old.png") }
"transparent mana symbol old red": { watermark_blend(colored: true, alpha: 0.4, dark_alpha: 0.4, wm_directory + "mana symbols/watermark_r_old.png") }
"transparent mana symbol old green": { watermark_blend(colored: true, alpha: 0.4, dark_alpha: 0.4, wm_directory + "mana symbols/watermark_g_old.png") }
"transparent mana symbol old colorless": { watermark_blend(colored: true, alpha: 0.4, dark_alpha: 0.4, wm_directory + "mana symbols/watermark_c_old.png") }
"transparent mana symbol hi res white": { watermark_blend(colored: true, alpha: 0.4, dark_alpha: 0.4, wm_directory + "mana symbols/watermark_w_big.png") }
"transparent mana symbol hi res blue": { watermark_blend(colored: true, alpha: 0.4, dark_alpha: 0.4, wm_directory + "mana symbols/watermark_u_big.png") }
"transparent mana symbol hi res black": { watermark_blend(colored: true, alpha: 0.4, dark_alpha: 0.4, wm_directory + "mana symbols/watermark_b_big.png") }
"transparent mana symbol hi res red": { watermark_blend(colored: true, alpha: 0.4, dark_alpha: 0.4, wm_directory + "mana symbols/watermark_r_big.png") }
"transparent mana symbol hi res green": { watermark_blend(colored: true, alpha: 0.4, dark_alpha: 0.4, wm_directory + "mana symbols/watermark_g_big.png") }
"transparent mana symbol hi res colorless": { watermark_blend(colored: true, alpha: 0.4, dark_alpha: 0.4, wm_directory + "mana symbols/watermark_c_big.png") }
"guild symbol The Azorius Senate (W/U)": { watermark_blend(wm_directory + "ravnica/azorius2.png") }
"guild symbol House Dimir (U/B)": { watermark_blend(wm_directory + "ravnica/dimir2.png") }
"guild symbol The Cult of Rakdos (B/R)": { watermark_blend(wm_directory + "ravnica/rakados2.png") }
"guild symbol The Gruul Clans (R/G)": { watermark_blend(wm_directory + "ravnica/gruul2.png") }
"guild symbol The Selesnya Conclave (G/W)": { watermark_blend(wm_directory + "ravnica/selesnya2.png") }
"guild symbol The Orzhov Syndicate (W/B)": { watermark_blend(wm_directory + "ravnica/orzhov2.png") }
"guild symbol The Izzet (U/R)": { watermark_blend(wm_directory + "ravnica/izzet2.png") }
"guild symbol The Golgari (B/G)": { watermark_blend(wm_directory + "ravnica/golgari2.png") }
"guild symbol The Boros Legion (R/W)": { watermark_blend(wm_directory + "ravnica/boros2.png") }
"guild symbol The Simic Combine (G/U)": { watermark_blend(wm_directory + "ravnica/simic2.png") }
"guild symbol originals The Azorius Senate (W/U)": { watermark_blend(wm_directory + "ravnica/azorius.png") }
"guild symbol originals House Dimir (U/B)": { watermark_blend(wm_directory + "ravnica/dimir.png") }
"guild symbol originals The Cult of Rakdos (B/R)": { watermark_blend(wm_directory + "ravnica/rakados.png") }
"guild symbol originals The Gruul Clans (R/G)": { watermark_blend(wm_directory + "ravnica/gruul.png") }
"guild symbol originals The Selesnya Conclave (G/W)": { watermark_blend(wm_directory + "ravnica/selesnya.png") }
"guild symbol originals The Orzhov Syndicate (W/B)": { watermark_blend(wm_directory + "ravnica/orzhov.png") }
"guild symbol originals The Izzet (U/R)": { watermark_blend(wm_directory + "ravnica/izzet.png") }
"guild symbol originals The Golgari (B/G)": { watermark_blend(wm_directory + "ravnica/golgari.png") }
"guild symbol originals The Boros Legion (R/W)": { watermark_blend(wm_directory + "ravnica/boros.png") }
"guild symbol originals The Simic Combine (G/U)": { watermark_blend(wm_directory + "ravnica/simic.png") }
"guild symbol ancients The Azorius Senate (W/U)": { watermark_blend(wm_directory + "frazier/azorius.png") }
"guild symbol ancients House Dimir (U/B)": { watermark_blend(wm_directory + "frazier/dimir.png") }
"guild symbol ancients The Cult of Rakdos (B/R)": { watermark_blend(wm_directory + "frazier/rakdos.png") }
"guild symbol ancients The Gruul Clans (R/G)": { watermark_blend(wm_directory + "frazier/gruul.png") }
"guild symbol ancients The Selesnya Conclave (G/W)": { watermark_blend(wm_directory + "frazier/selesnya.png") }
"guild symbol ancients The Orzhov Syndicate (W/B)": { watermark_blend(wm_directory + "frazier/orzhov.png") }
"guild symbol ancients The Izzet (U/R)": { watermark_blend(wm_directory + "frazier/izzet.png") }
"guild symbol ancients The Golgari (B/G)": { watermark_blend(wm_directory + "frazier/golgari.png") }
"guild symbol ancients The Boros Legion (R/W)": { watermark_blend(wm_directory + "frazier/boros.png") }
"guild symbol ancients The Simic Combine (G/U)": { watermark_blend(wm_directory + "frazier/simic.png") }
"faction symbol mirrodin": { watermark_blend(wm_directory + "mirrodin/mirrodin.png") }
"faction symbol phyrexia": { watermark_blend(wm_directory + "mirrodin/phyrexia.png") }
"clan symbol The Abzan Houses (WBG)": { watermark_blend(wm_directory + "tarkir/abzan.png") }
"clan symbol The Jeskai Way (URW)": { watermark_blend(wm_directory + "tarkir/jeskai.png") }
"clan symbol The Sultai Brood (BGU)": { watermark_blend(wm_directory + "tarkir/sultai.png") }
"clan symbol The Mardu Horde (RWB)": { watermark_blend(h:400, wm_directory + "tarkir/mardu.png") }
"clan symbol The Temur Frontier (GUR)": { watermark_blend(wm_directory + "tarkir/temur.png") }
"brood symbol Dromoka's Brood (GW)": { watermark_blend(wm_directory + "tarkir/dromoka.png") }
"brood symbol Ojutai's Brood (WU)": { watermark_blend(wm_directory + "tarkir/ojutai.png") }
"brood symbol Silumgar's Brood (UB)": { watermark_blend(wm_directory + "tarkir/silumgar.png") }
"brood symbol Kolaghan's Brood (BR)": { watermark_blend(wm_directory + "tarkir/kolaghan.png", h:400) }
"brood symbol Atarka's Brood (RG)": { watermark_blend(wm_directory + "tarkir/atarka.png") }
"family symbol Brokers (GWU)": { watermark_blend(wm_directory + "capenna/brokers.png") }
"family symbol Cabaretti (RGW)": { watermark_blend(wm_directory + "capenna/cabaretti.png") }
"family symbol Maestros (UBR)": { watermark_blend(wm_directory + "capenna/maestros.png") }
"family symbol Obscura (WUB)": { watermark_blend(wm_directory + "capenna/obscura.png") }
"family symbol Riveteers (BRG)": { watermark_blend(wm_directory + "capenna/riveteers.png") }
"unstable factions Order of the Widget": { watermark_blend(wm_directory + "unstable/widget.png") }
"unstable factions Agents of S.N.E.A.K.": { watermark_blend(wm_directory + "unstable/SNEAK.png") }
"unstable factions League of Dastardly Doom": { watermark_blend(wm_directory + "unstable/doom.png") }
"unstable factions Goblin Explosioneers": { watermark_blend(wm_directory + "unstable/explosioneers.png") }
"unstable factions Crossbreed Labs": { watermark_blend(wm_directory + "unstable/crossbreed.png") }
"colored xander hybrid mana B/R": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "xander/brmana_colored.png") }
"colored xander hybrid mana U/B": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "xander/ubmana_colored.png") }
"colored xander hybrid mana B/G": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "xander/bgmana_colored.png") }
"colored xander hybrid mana R/G": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "xander/rgmana_colored.png") }
"colored xander hybrid mana G/U": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "xander/gumana_colored.png") }
"colored xander hybrid mana U/R": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "xander/urmana_colored.png") }
"colored xander hybrid mana W/B": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "xander/wbmana_colored.png") }
"colored xander hybrid mana G/W": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "xander/gwmana_colored.png") }
"colored xander hybrid mana R/W": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "xander/rwmana_colored.png") }
"colored xander hybrid mana W/U": { watermark_blend(colored: true, alpha: 1, dark_alpha: 1, wm_directory + "xander/wumana_colored.png") }
"xander hybrid mana B/R": { watermark_blend(alpha: 0.26, spotlight_alpha: 0.85, dark_alpha: 0.26, dark_spotlight_alpha: 0.85, h:266, l:266, wm_directory + "xander/brmana.png") }
"xander hybrid mana U/B": { watermark_blend(alpha: 0.26, spotlight_alpha: 0.85, dark_alpha: 0.26, dark_spotlight_alpha: 0.85, h:266, l:266, wm_directory + "xander/ubmana.png") }
"xander hybrid mana B/G": { watermark_blend(alpha: 0.26, spotlight_alpha: 0.85, dark_alpha: 0.26, dark_spotlight_alpha: 0.85, h:266, l:266, wm_directory + "xander/bgmana.png") }
"xander hybrid mana R/G": { watermark_blend(alpha: 0.26, spotlight_alpha: 0.85, dark_alpha: 0.26, dark_spotlight_alpha: 0.85, h:266, l:266, wm_directory + "xander/rgmana.png") }
"xander hybrid mana G/U": { watermark_blend(alpha: 0.26, spotlight_alpha: 0.85, dark_alpha: 0.26, dark_spotlight_alpha: 0.85, h:266, l:266, wm_directory + "xander/gumana.png") }
"xander hybrid mana U/R": { watermark_blend(alpha: 0.26, spotlight_alpha: 0.85, dark_alpha: 0.26, dark_spotlight_alpha: 0.85, h:266, l:266, wm_directory + "xander/urmana.png") }
"xander hybrid mana W/B": { watermark_blend(alpha: 0.26, spotlight_alpha: 0.85, dark_alpha: 0.26, dark_spotlight_alpha: 0.85, h:266, l:266, wm_directory + "xander/wbmana.png") }
"xander hybrid mana G/W": { watermark_blend(alpha: 0.26, spotlight_alpha: 0.85, dark_alpha: 0.26, dark_spotlight_alpha: 0.85, h:266, l:266, wm_directory + "xander/gwmana.png") }
"xander hybrid mana R/W": { watermark_blend(alpha: 0.26, spotlight_alpha: 0.85, dark_alpha: 0.26, dark_spotlight_alpha: 0.85, h:266, l:266, wm_directory + "xander/rwmana.png") }
"xander hybrid mana W/U": { watermark_blend(alpha: 0.26, spotlight_alpha: 0.85, dark_alpha: 0.26, dark_spotlight_alpha: 0.85, h:266, l:266, wm_directory + "xander/wumana.png") }
"future sight type symbols artifact": { watermark_blend(wm_directory + "future/artifact.png") }
"future sight type symbols creature": { watermark_blend(wm_directory + "future/creature.png") }
"future sight type symbols enchantment": { watermark_blend(wm_directory + "future/enchantment.png") }
"future sight type symbols instant": { watermark_blend(wm_directory + "future/instant.png") }
"future sight type symbols land": { watermark_blend(wm_directory + "future/land.png") }
"future sight type symbols multiple": { watermark_blend(wm_directory + "future/multiple.png") }
"future sight type symbols planeswalker": { watermark_blend(wm_directory + "future/planeswalker.png") }
"future sight type symbols sorcery": { watermark_blend(wm_directory + "future/sorcery.png") }
"future sight type symbols structure": { watermark_blend(wm_directory + "future/structure.png") }
"other magic symbols chaos symbol": { watermark_blend(h:500, l:500, wm_directory + "other/chaos.png") }
"other magic symbols story spotlight": { watermark_blend(h:500, l:500, wm_directory + "other/planeswalker.png") }
"other magic symbols color spotlight": { watermark_blend(h:500, l:500, wm_directory + "other/planeswalker.png") }
"other magic symbols shooting star": { watermark_blend(h:400, l:500, wm_directory + "promo/shooting_star.png") }
"other magic symbols color pie": { watermark_blend(h:500, l:500, wm_directory + "other/colorpie.png") }
"other magic symbols judge academy": { watermark_blend(h:500, l:500, wm_directory + "promo/judge_academy.png") }
"other magic symbols foretell": { watermark_blend(h:460, l:500, wm_directory + "other/foretell.png") }
"other magic symbols jace consortium": { watermark_blend(h:500, l:500, wm_directory + "other/jace-consortium.png") }
"other magic symbols seekers of carmot": { watermark_blend(h:500, l:500, wm_directory + "other/seekersofcarmot.png") }
"other magic symbols desparked": { watermark_blend(h:500, l:500, wm_directory + "other/desparked.png") }
"other magic symbols aetherprint": { watermark_blend(alpha: 0.28, spotlight_alpha: 0.55, dark_alpha: 0.28, dark_spotlight_alpha: 0.5, h:500, l:317, wm_directory + "other/aetherprint.png") }
"other magic symbols phyrexia": { watermark_blend(alpha: 0.30, spotlight_alpha: 0.60, dark_alpha: 0.30, dark_spotlight_alpha: 0.5, h:217, l:115, wm_directory + "other/phyrexia.png") }
"other magic symbols the thran": { watermark_blend(alpha: 0.25, spotlight_alpha: 0.55, dark_alpha: 0.28, dark_spotlight_alpha: 0.4, h:240, l:163, wm_directory + "other/thran.png") }
"other magic symbols conspiracy stamp": { watermark_blend(colored: true, alpha: 0.35, dark_alpha: 0.25, wm_directory + "other/conspiracy_stamp.png") }
"other magic symbols innistrad provinces stensia": { watermark_blend(wm_directory + "innistrad/stensia.png") }
"other magic symbols innistrad provinces kessig": { watermark_blend(wm_directory + "innistrad/kessig.png") }
"other magic symbols innistrad provinces gavony": { watermark_blend(wm_directory + "innistrad/gavony.png") }
"other magic symbols innistrad provinces nephalia": { watermark_blend(wm_directory + "innistrad/nephalia.png") }
"other magic symbols theros poleis akros": { watermark_blend(wm_directory + "theros/akros.png") }
"other magic symbols theros poleis meletis": { watermark_blend(wm_directory + "theros/meletis.png") }
"other magic symbols theros poleis setessa": { watermark_blend(wm_directory + "theros/setessa.png") }
"alara symbols Bant": { watermark_blend(wm_directory + "alara/bant.png") }
"alara symbols Esper": { watermark_blend(wm_directory + "alara/esper.png") }
"alara symbols Grixis": { watermark_blend(wm_directory + "alara/grixis.png") }
"alara symbols Jund": { watermark_blend(wm_directory + "alara/jund.png") }
"alara symbols Naya": { watermark_blend(wm_directory + "alara/naya.png") }
"alara symbols colored Bant": { watermark_blend(colored: true, alpha: 0.25, dark_alpha: 0.25, wm_directory + "alara/bant_colored.png") }
"alara symbols colored Esper": { watermark_blend(colored: true, alpha: 0.25, dark_alpha: 0.40, wm_directory + "alara/esper_colored.png") }
"alara symbols colored Grixis": { watermark_blend(colored: true, alpha: 0.22, dark_alpha: 0.55, wm_directory + "alara/grixis_colored.png") }
"alara symbols colored Jund": { watermark_blend(colored: true, alpha: 0.25, dark_alpha: 0.40, wm_directory + "alara/jund_colored.png") }
"alara symbols colored Naya": { watermark_blend(colored: true, alpha: 0.25, dark_alpha: 0.30, wm_directory + "alara/naya_colored.png") }
"college symbols Silverquill": { watermark_blend(wm_directory + "strixhaven/silverquill.png") }
"college symbols Prismari": { watermark_blend(wm_directory + "strixhaven/prismari.png") }
"college symbols Witherbloom": { watermark_blend(wm_directory + "strixhaven/witherbloom.png") }
"college symbols Lorehold": { watermark_blend(wm_directory + "strixhaven/lorehold.png") }
"college symbols Quandrix": { watermark_blend(wm_directory + "strixhaven/quandrix.png") }
"universes beyond D&D": { watermark_blend(wm_directory + "ub/d&d.png") }
"universes beyond transformers": { watermark_blend(wm_directory + "ub/transformers.png") }
"universes beyond ponies applejack": { watermark_blend(wm_directory + "ponies/applejack.png") }
"universes beyond ponies pinkie pie": { watermark_blend(wm_directory + "ponies/pinkie pie.png") }
"universes beyond ponies fluttershy": { watermark_blend(wm_directory + "ponies/fluttershy.png") }
"universes beyond ponies rainbow dash": { watermark_blend(wm_directory + "ponies/rainbow dash.png") }
"universes beyond ponies rarity": { watermark_blend(wm_directory + "ponies/rarity.png") }
"universes beyond ponies twilight sparkle": { watermark_blend(wm_directory + "ponies/twilight sparkle.png") }
"universes beyond ponies nightmare moon": { watermark_blend(wm_directory + "ponies/nightmare moon.png") }
"universes beyond ponies luna": { watermark_blend(wm_directory + "ponies/luna.png") }
"custom watermark one": { watermark_blend(custom_watermark_1(), custom:true) }
"custom watermark two": { watermark_blend(custom_watermark_2(), custom:true) }
"custom watermark three": { watermark_blend(custom_watermark_3(), custom:true) }
"custom watermark four": { watermark_blend(custom_watermark_4(), custom:true) }
"custom watermark five": { watermark_blend(custom_watermark_5(), custom:true) }
"custom watermark six": { watermark_blend(custom_watermark_6(), custom:true) }
"custom watermark seven": { watermark_blend(custom_watermark_7(), custom:true) }
"custom watermark eight": { watermark_blend(custom_watermark_8(), custom:true) }
"custom watermark nine": { watermark_blend(custom_watermark_9(), custom:true) }
"custom watermark ten": { watermark_blend(custom_watermark_10(), custom:true) }
"custom watermark card": { watermark_blend(custom_watermark_a(), custom:true) }
"set symbol": { if (styling.watermark_render or else set.blend_with_colors) == "glow" then glow_watermark_blend(symbol_variation(symbol: set.symbol, variation: "watermark")) else shadow_watermark_blend(symbol_variation(symbol: set.symbol, variation: "watermark")) }
]
############################################################## Other scripted fields
#### Dimensions of card faces, can be changed in style files
faces_coordinates := {
[
[
left: 0,
top: 0,
width: stylesheet.card_width,
height: stylesheet.card_height
]
]
}
face_coordinates_string := {
fc := faces_coordinates()
for x from 0 to length(fc) - 1 do fc[x].left + "," + fc[x].top + "," + fc[x].width + "," + fc[x].height + ";"
}
face_coordinates_map := {
fc := faces_coordinates()
fc[input-1] or else [top: 0, left:0, width:0, height:0]
}
face_is_rotated :=
{
map := face_coordinates_map(input)
map.width > map.height
}
############################################################## Information below the textbox
############################################################## Global offsets
#### To shift everything up/down:
information_offset_top_1 := { 0 }
#### To shift the card number, set code and artist credit left/right:
information_codes_offset_left_1 := { 0 }
#### To shift the actual copyright lines left/right:
information_copyright_offset_right_1 := { 0 }
#### To shift the copyright up/down on creatures/walkers, if the pt/loyalty box is very short/tall:
information_copyright_offset_pt_top_1 := { 0 }
#### To shift the secondary copyright left/right on creatures/walkers, if the pt/loyalty box is very narrow/wide:
information_secondary_offset_pt_left_1 := { 0 }
#### For the other faces on DFCs use:
information_offset_top_2 := { 0 }
information_codes_offset_left_2 := { 0 }
information_copyright_offset_right_2 := { 0 }
information_copyright_offset_pt_top_2 := { 0 }
information_secondary_offset_pt_left_2 := { 0 }
information_offset_top_3 := { 0 }
information_codes_offset_left_3 := { 0 }
information_copyright_offset_right_3 := { 0 }
information_copyright_offset_pt_top_3 := { 0 }
information_secondary_offset_pt_left_3 := { 0 }
#### These work the same on 90° rotated cards, but you need to imagine the card is upright
#### For DFC or TFC templates, dont forget to override the faces_coordinates function.
#### You can disable the copyright on some of the faces,
#### by adding the following functions in the init script:
information_disabled_1 := { false }
information_disabled_2 := { false }
information_disabled_3 := { false }
############################################################## Card code fields
set_code_script :=
{
code := if is_masterpiece() then set.masterpiece_set_code else set.set_code
if code == "" then set.set_language else (
brush := if margin_code == "setcode1" then card.additional_credit_brush
else if margin_code == "setcode2" then card.additional_credit_brush_4
else if margin_code == "setcode3" then card.additional_credit_brush_5
else "none"
if brush == "none" or (not set.adaptive_language_height)
then code + (if set.set_language != "" then " • " else "") + set.set_language
else code)
}
set_language_script :=
{
set.set_language
}
#### a/b add-ons for DFCs
card_number_tags := {
if contains(card.shape, match:"double")
then ["a", "b", "b"]
else ["", "", ""]
}
#### General card code handler
card_code_script_core := {
if not use_auto_numbers() and set.card_number_style == "0001" then
### R CUSTOM TEXT
combined_editor(prefix: rarity_code() + " ", field1: card.custom_card_number, separator: " ", field2: card_code_text)
else if not use_auto_numbers() then
### CUSTOM R TEXT
combined_editor(field1: card.custom_card_number, separator: " " + rarity_code() + " ", field2: card_code_text)
else if set.card_number_style == "0001/0099" then
### R 1000/1000 TEXT
forward_editor(prefix: rarity_code() + " " + card_number_mom() + tag + (if over_partition() and set.over_partition_display == "100" then "" else "/" + card_count_mom()) + " ", field: card_code_text)
else if set.card_number_style == "0001" then
### R 1000 TEXT
forward_editor(prefix: rarity_code() + " " + card_number_mom() + tag + " ", field: card_code_text)
else if set.card_number_style == "001/099" then
### 100/100 R TEXT
forward_editor(prefix: card_number_m15() + tag + (if over_partition() and set.over_partition_display == "100" then "" else "/" + card_count_m15()) + " " + rarity_code() + " ", field: card_code_text)
else if set.card_number_style == "001" then
### 100 R TEXT
forward_editor(prefix: card_number_m15() + tag + " " + rarity_code() + " ", field: card_code_text)
else if set.card_number_style == "1/99" then
### 1/99 R TEXT
forward_editor(prefix: card_number() + tag + (if over_partition() and set.over_partition_display == "100" then "" else "/" + card_count()) + " " + rarity_code() + " ", field: card_code_text)
else
### 1 R TEXT
forward_editor(prefix: card_number() + tag + " " + rarity_code() + " ", field: card_code_text)
}@(tag: "")
#### Card code script for individual faces
card_code_script :=
{
card_code_script_core(card_code_text: card.card_code_text, tag:card_number_tags()[0])
}
card_code_script2 :=
{
card_code_script_core(card_code_text: card.card_code_text_2, tag:card_number_tags()[1])
}
card_code_script3 :=
{
card_code_script_core(card_code_text: card.card_code_text_3, tag:card_number_tags()[2])
}
############################################################## Copyright fields
copyright_default := { set.copyright }
secondary_copyright_default := { set.secondary_copyright }
############################################################## Additional credit fields
illustrator_brush_default := { "art" }
illustrator_brush_field := { if input <= 1 then card.illustrator_brush else card["illustrator_brush_" + input] }
illustrator_brush_image :=
{
shape := illustrator_brush_field(field)
image := "/magic-modules.mse-include/information/" + shape + ".png"
color := styling.copyright_text_color or else set.copyright_text_color
recolor_image(image, color: color)
}
additional_credit_default := { "" }
additional_credit_brush_default := { "none" }
additional_credit_brush_field := { if input <= 1 then card.additional_credit_brush else card["additional_credit_brush_" + input] }
additional_credit_brush_image :=
{
shape := additional_credit_brush_field(field)
image := "/magic-modules.mse-include/information/" + shape + ".png"
color := styling.copyright_text_color or else set.copyright_text_color
recolor_image(image, color: color)
}
############################################################## The List
the_list_icon_default := { "none" }
the_list_icon_field := { if input <= 1 then card.the_list_icon else card["the_list_icon_" + input] }
the_list_icon_image :=
{
shape := the_list_icon_field(field)
suffix := if shape == "the list" and face_coordinates_map(face).width != 375 and face_coordinates_map(face).width != 523 then " 750" else ""
image := "/magic-modules.mse-include/information/" + shape + suffix + ".png"
color := styling.copyright_text_color or else set.copyright_text_color
recolor_image(image, color: color)
}
############################################################## Additional textboxes
text_filter_default :=
{
if transfer_levels() then
(
if margin_code == "lv1" then card.rule_text
else if margin_code == "lv2" then card.rule_text_2
else if margin_code == "lv3" then card.rule_text_3
else if margin_code == "lv4" then card.rule_text_4
else if margin_code == "lv5" then card.rule_text_5
else if margin_code == "lv6" then card.rule_text_6
else ""
)
else ""
}
text_style_field := { if input <= 1 then card_style.text else card_style["text_" + input] }
############################################################## Saga/Class reminder
chapter_text_filter_default :=
{
if margin_code == "chapter_text" then (if not a_saga() then "" else if card.rule_text != "" then card.rule_text else "<i-auto>(" + saga_reminder() + ")</i-auto>")
else if margin_code == "chapter_text2" then (if not b_saga() then "" else "<i-auto>(" + saga_reminderb() + ")</i-auto>")
else ""
}
############################################################## Leveler textboxes
level_filter_default := { "" }
level_filter := { input }
#### Correct the CARDNAME atom for levelers
#### This can be overwritten for more complicated levelers
#### Dungeons for example will overwrite with just {if set.alias_as_cardname and card.alias != "" then card.alias else card.name}
card_name_for_level := {
lvl := if input < 5
then ""
else if input < 9
then "_2"
else if input < 13
then "_3"
else if input < 17
then "_4"
else ""
if set.alias_as_cardname and card["alias"+lvl] != "" then card["alias"+lvl] else card["name"+lvl]
}
############################################################## Border
border_color_default := { set.border_color }
corners_default := { set.corner_shape }
corners_field := { if input <= 1 then card.corners else card["corners_" + input] }
corners_image :=
{
shape := corners_field(field)
color := if shape == "none" then card.border_color else rgb(255,255,255)
if shape == "invisible"
then "/magic-modules.mse-include/corners/invisible.png"
else recolor_image("/magic-modules.mse-include/corners/color.png", color: color)
}
corners_mask :=
{
map := face_coordinates_map(face)
if map.width == 0 or map.height == 0 then "" else (
dimensions := map.width + "x" + map.height
dimensions := corners_possible_dimensions[dimensions] or else (if map.height > map.width then "1046x750" else "750x1046")
shape := corners_field(field)
shape := if shape == "none" or shape == "invisible" then "rounded" else shape
"/magic-modules.mse-include/corners/" + dimensions + " " + shape + ".png"
)
}
corners_possible_dimensions :=
[
"375x523": "375x523"
"523x375": "523x375"
"646x902": "646x902"
"902x646": "902x646"
"744x1039": "744x1039"
"1039x744": "1039x744"
"750x1046": "750x1046"
"1046x750": "1046x750"
]
corners_disabled_1 := { false }
corners_disabled_2 := { false }
corners_disabled_3 := { false }
############################################################## Punchout counters
counter_default := { "+1/+1" }
counter_field := { if input <= 1 then card.counter else card["counter_" + input] }
counter_image :=
{
shape := replace(counter_field(field), match: "/", replace: "")
if shape == "custom" then
(
path := styling["symbol_" + field + "_custom_image_location"]
or else styling["counter_symbol_" + field + "_custom_image_location"]
or else ""
if contains(path, match: ".png")
then "/magic-modules.mse-include/counters/" + path
else "/magic-modules.mse-include/counters/none.png"
)
else if shape == "none" then "/magic-modules.mse-include/counters/none.png"
else
(
color := styling.symbol_color
or else styling.counter_symbol_color
or else rgb(255,255,255)
recolor_image("/magic-modules.mse-include/counters/" + shape + ".png", color: color)
)
}
############################################################## Future Sight typesymbols
typesymbol_for :=
to_text +
{ lang_setting("remove_supertypes")(input) } +
{ replace(match: lang_setting("supertype_separator"), replace: "") } +
{
if input == lang_setting("creature") then "creature"
else if input == lang_setting("sorcery") then "sorcery"
else if input == lang_setting("instant") then "instant"
else if input == lang_setting("artifact") then "artifact"
else if input == lang_setting("enchantment") then "enchantment"
else if input == lang_setting("land") then "land"
else if input == lang_setting("planeswalker") then "planeswalker"
else if input == lang_setting("battle") then "battle"
else if input == lang_setting("emblem") then "non standard emblem"
else if input == lang_setting("conspiracy") then "non standard conspiracy"
else if input == lang_setting("dungeon") then "non standard dungeon"
else if input == lang_setting("hero") then "non standard hero"
else if input == lang_setting("phenomenon") then "non standard phenomenon"
else if input == lang_setting("plane") then "non standard plane"
else if input == lang_setting("scheme") then "non standard scheme"
else if input == lang_setting("vanguard") then "non standard vanguard"
else "multitype"
}
typesymbol_type := { typesymbol_for(type) }
############################################################## Transform/Lesson symbols
transform_symbol_default :=
{
if margin_code == "transform1" then "none"
else if margin_code == "transform2" then "none"
else "none"
}
transform_symbol_field := { if input <= 1 then card.transformation else card["transformation_" + input] }
transform_symbol_is_mirrored :=
{
if input <= 1
then transform_symbol_mirrored_1()
else if input == 2
then transform_symbol_mirrored_2()
else transform_symbol_mirrored_3()
}
transform_symbol_image :=
{
map := face_coordinates_map(face)
if map.width == 0 or map.height == 0
then ""
else (
shape := transform_symbol_field(face)
link := clean_transform_symbol_shape(shape)
if transform_symbol_is_mirrored(face) then link := flip_transform_symbol_shape(link)
if contains(link, match:"/default") then (
color := sparker_card_color(card_color_field(face))
link := replace(link, match:"/default", replace:"/"+color)
)
case shape of
"none": "",
"custom symbol one": custom_symbol_1(),
"custom symbol two": custom_symbol_2(),
"custom symbol three": custom_symbol_3(),
"custom symbol four": custom_symbol_4(),
else: "/magic-modules.mse-include/symbols/" + link + ".png";
)
}
clean_transform_symbol_shape :=
replace@(match: "modal front ", replace: "modalfront/") +
replace@(match: "modal back ", replace: "modalback/") +
replace@(match: "sparker [(]colored[)] ", replace: "sparker/") +
replace@(match: "extra |non standard ", replace: "")
flip_transform_symbol_shape :=
replace@(match: "modalfront/", replace: "modalfrontflipped/") +
replace@(match: "modalback/", replace: "modalbackflipped/")
#### General form
transform_symbol_left :=
{
map := face_coordinates_map(face)
mirrored := transform_symbol_is_mirrored(1)
if map.width > map.height then
(
if mirrored then map.left + 455 * map.width/523 + offset
else map.left + 52 * map.width/523 + offset
)
else
(
if mirrored then map.left + 319 * map.width/375 + offset
else map.left + 13 * map.width/375 + offset
)
}
transform_symbol_top :=
{
map := face_coordinates_map(face)
if map.width > map.height then
map.top + 11 * map.height/375 + offset
else map.top + 19 * map.height/523 + offset
}
transform_symbol_width :=
{
map := face_coordinates_map(face)
if map.width > map.height then
43 * map.width/523 + offset
else 43 * map.width/375 + offset
}
transform_symbol_height :=
{
map := face_coordinates_map(face)
if map.width > map.height then
43 * map.height/375 + offset
else 43 * map.height/523 + offset
}
#### Specific faces
transform_symbol_face_1 := { 1 }
transform_symbol_disabled_1 := { false }
transform_symbol_mirrored_1 := { false }
transform_symbol_offset_top_1 := { 0 }
transform_symbol_offset_left_1 := { 0 }
transform_symbol_offset_width_1 := { 0 }
transform_symbol_offset_height_1 := { 0 }
transform_symbol_left_1 := { transform_symbol_left(face:transform_symbol_face_1(), offset:transform_symbol_offset_left_1()) }
transform_symbol_top_1 := { transform_symbol_top(face:transform_symbol_face_1(), offset:transform_symbol_offset_top_1()) }
transform_symbol_width_1 := { transform_symbol_width(face:transform_symbol_face_1(), offset:transform_symbol_offset_width_1()) }
transform_symbol_height_1 := { transform_symbol_height(face:transform_symbol_face_1(), offset:transform_symbol_offset_height_1()) }
transform_symbol_face_2 := { 2 }
transform_symbol_disabled_2 := { false }
transform_symbol_mirrored_2 := { false }
transform_symbol_offset_top_2 := { 0 }
transform_symbol_offset_left_2 := { 0 }
transform_symbol_offset_width_2 := { 0 }
transform_symbol_offset_height_2 := { 0 }
transform_symbol_left_2 := { transform_symbol_left(face:transform_symbol_face_2(), offset:transform_symbol_offset_left_2()) }
transform_symbol_top_2 := { transform_symbol_top(face:transform_symbol_face_2(), offset:transform_symbol_offset_top_2()) }
transform_symbol_width_2 := { transform_symbol_width(face:transform_symbol_face_2(), offset:transform_symbol_offset_width_2()) }
transform_symbol_height_2 := { transform_symbol_height(face:transform_symbol_face_2(), offset:transform_symbol_offset_height_2()) }
transform_symbol_face_3 := { 3 }
transform_symbol_disabled_3 := { false }
transform_symbol_mirrored_3 := { false }
transform_symbol_offset_top_3 := { 0 }
transform_symbol_offset_left_3 := { 0 }
transform_symbol_offset_width_3 := { 0 }
transform_symbol_offset_height_3 := { 0 }
transform_symbol_left_3 := { transform_symbol_left(face:transform_symbol_face_3(), offset:transform_symbol_offset_left_3()) }
transform_symbol_top_3 := { transform_symbol_top(face:transform_symbol_face_3(), offset:transform_symbol_offset_top_3()) }
transform_symbol_width_3 := { transform_symbol_width(face:transform_symbol_face_3(), offset:transform_symbol_offset_width_3()) }
transform_symbol_height_3 := { transform_symbol_height(face:transform_symbol_face_3(), offset:transform_symbol_offset_height_3()) }
############################################################## Tombstone/Alchemy symbols
card_symbol_default := { "" }
card_symbol_field := { if input <= 1 then card.card_symbol else card["card_symbol_" + input] }
card_symbol_image := {
map := face_coordinates_map(face)
shape := card_symbol_field(face)
if shape == "none" or map.width == 0 or map.height == 0
then ""
else "/magic-modules.mse-include/card-symbols/" + shape + ".png"
}
card_symbol_left :=
{
map := face_coordinates_map(face)
has_tr := (transform_symbol_field(face) != "none")
has_sym := (card_symbol_field(face) != "none")
default := if has_tr
then 8 + 18 + 28
else if has_sym
then 8 + 18
else 8
if map.width > map.height then map.left + default * map.width/523 + offset
else map.left + default * map.width/375 + offset
}
card_symbol_top :=
{
map := face_coordinates_map(face)
if map.width > map.height then map.top + 21 * map.height/375 + offset
else map.top + 29 * map.height/523 + offset
}
card_symbol_width :=
{
map := face_coordinates_map(face)
default := if card_symbol_field(face) == "none" then 9 else 23
if map.width > map.height then default * map.width/523 + offset
else default * map.width/375 + offset
}
card_symbol_height :=
{
map := face_coordinates_map(face)
if map.width > map.height then 21 * map.height/375 + offset
else 21 * map.height/523 + offset
}
card_symbol_face_1 := { 1 }
card_symbol_disabled_1 := { false }
card_symbol_offset_top_1 := { 0 }
card_symbol_offset_left_1 := { 0 }
card_symbol_offset_width_1 := { 0 }
card_symbol_offset_height_1 := { 0 }
card_symbol_left_1 := { card_symbol_left( face:card_symbol_face_1(), offset:card_symbol_offset_left_1()) }
card_symbol_top_1 := { card_symbol_top( face:card_symbol_face_1(), offset:card_symbol_offset_top_1()) }
card_symbol_width_1 := { card_symbol_width( face:card_symbol_face_1(), offset:card_symbol_offset_width_1()) }
card_symbol_height_1 := { card_symbol_height(face:card_symbol_face_1(), offset:card_symbol_offset_height_1()) }
card_symbol_face_2 := { 2 }
card_symbol_disabled_2 := { false }
card_symbol_offset_top_2 := { 0 }
card_symbol_offset_left_2 := { 0 }
card_symbol_offset_width_2 := { 0 }
card_symbol_offset_height_2 := { 0 }
card_symbol_left_2 := { card_symbol_left( face:card_symbol_face_2(), offset:card_symbol_offset_left_2()) }
card_symbol_top_2 := { card_symbol_top( face:card_symbol_face_2(), offset:card_symbol_offset_top_2()) }
card_symbol_width_2 := { card_symbol_width( face:card_symbol_face_2(), offset:card_symbol_offset_width_2()) }
card_symbol_height_2 := { card_symbol_height(face:card_symbol_face_2(), offset:card_symbol_offset_height_2()) }
card_symbol_face_3 := { 3 }
card_symbol_disabled_3 := { false }
card_symbol_offset_top_3 := { 0 }
card_symbol_offset_left_3 := { 0 }
card_symbol_offset_width_3 := { 0 }
card_symbol_offset_height_3 := { 0 }
card_symbol_left_3 := { card_symbol_left( face:card_symbol_face_3(), offset:card_symbol_offset_left_3()) }
card_symbol_top_3 := { card_symbol_top( face:card_symbol_face_3(), offset:card_symbol_offset_top_3()) }
card_symbol_width_3 := { card_symbol_width( face:card_symbol_face_3(), offset:card_symbol_offset_width_3()) }
card_symbol_height_3 := { card_symbol_height(face:card_symbol_face_3(), offset:card_symbol_offset_height_3()) }
############################################################## Loyalty costs
loyalty_clean_margin_code := replace@(match: "loy(cost)?", replace: "")
loyalty_cost_field :=
{
input := loyalty_clean_margin_code(input)
card["loyalty_cost_" + input]
}
loyalty_cost_box_field :=
{
input := loyalty_clean_margin_code(input)
card["loyalty_cost_box_" + input]
}
loyalty_cost_box_default :=
{
cost := loyalty_cost_field(margin_code)
if cost == "" then "none"
else if contains(cost, match: "+") then "+, shadow"
else if contains(cost, match: "-") then "-, shadow"
else "0, shadow"
}
loyalty_cost_box_image :=
{
shape := remove_comma(loyalty_cost_box_field(input + (instance-1)*8))
if contains(shape, match: "none") then ""
else "/magic-modules.mse-include/loyalty/loyalty cost " + shape + ".png"
}
loyalty_field :=
{
input := loyalty_clean_margin_code(input)
if input <= 1 then card.loyalty else card["loyalty_" + input]
}
loyalty_box_field :=
{
input := loyalty_clean_margin_code(input)
if input <= 1 then card.loyalty_box else card["loyalty_box_" + input]
}
loyalty_box_default :=
{
margin_code := loyalty_clean_margin_code(margin_code)
loyalty := loyalty_field(margin_code)
if loyalty == "" then "none" else (
type := if margin_code <= 1 then card.super_type else card["super_type_" + margin_code]
if lang_setting("is_battle")(type) or contains(card_shape(), match: "battle") then "defense"
else "loyalty")
}
loyalty_box_image :=
{
shape := remove_comma(loyalty_box_field(instance))
if has_none(shape) then ""
else "/magic-modules.mse-include/loyalty/" + shape + ".png"
}
loyalty_face_1 := { 1 }
loyalty_text_field_1 := { 1 }
loyalty_stamp_field_1 := { 1 }
loyalty_offset_top_1 := { 0 }
loyalty_offset_left_1 := { 0 }
loyalty_offset_width_1 := { 0 }
loyalty_offset_height_1 := { 0 }
loyalty_cost_offset_top_1 := { 0 }
loyalty_cost_offset_left_1 := { 0 }
loyalty_cost_offset_width_1 := { 0 }
loyalty_cost_offset_height_1 := { 0 }
loyalty_cost_offset_text_margin_1 := { 0 }
loyalty_textbox_mask_1 :=
{
if is_stamped(field: loyalty_stamp_field_1())
then "/magic-modules.mse-include/loyalty/default_textbox_stamp_mask.png"
else "/magic-modules.mse-include/loyalty/default_textbox_mask.png"
}
loyalty_face_2 := { 2 }
loyalty_text_field_2 := { 2 }
loyalty_stamp_field_2 := { 2 }
loyalty_offset_top_2 := { 0 }
loyalty_offset_left_2 := { 0 }
loyalty_offset_width_2 := { 0 }
loyalty_offset_height_2 := { 0 }
loyalty_cost_offset_top_2 := { 0 }
loyalty_cost_offset_left_2 := { 0 }
loyalty_cost_offset_width_2 := { 0 }
loyalty_cost_offset_height_2 := { 0 }
loyalty_cost_offset_text_margin_2 := { 0 }
loyalty_textbox_mask_2 :=
{
if is_stamped(field: loyalty_stamp_field_2())
then "/magic-modules.mse-include/loyalty/default_textbox_stamp_mask.png"
else "/magic-modules.mse-include/loyalty/default_textbox_mask.png"
}
loyalty_face_3 := { 3 }
loyalty_text_field_3 := { 3 }
loyalty_stamp_field_3 := { 3 }
loyalty_offset_top_3 := { 0 }
loyalty_offset_left_3 := { 0 }
loyalty_offset_width_3 := { 0 }
loyalty_offset_height_3 := { 0 }
loyalty_cost_offset_top_3 := { 0 }
loyalty_cost_offset_left_3 := { 0 }
loyalty_cost_offset_width_3 := { 0 }
loyalty_cost_offset_height_3 := { 0 }
loyalty_cost_offset_text_margin_3 := { 0 }
loyalty_textbox_mask_3 :=
{
if is_stamped(field: loyalty_stamp_field_3())
then "/magic-modules.mse-include/loyalty/default_textbox_stamp_mask.png"
else "/magic-modules.mse-include/loyalty/default_textbox_mask.png"
}
loyalty_face := { if instance <= 1 then loyalty_face_1() else if instance == 2 then loyalty_face_2() else loyalty_face_3() }
loyalty_text_field := { if instance <= 1 then loyalty_text_field_1() else if instance == 2 then loyalty_text_field_2() else loyalty_text_field_3() }
loyalty_stamp_field := { if instance <= 1 then loyalty_stamp_field_1() else if instance == 2 then loyalty_stamp_field_2() else loyalty_stamp_field_3() }
loyalty_offset_top := { if instance <= 1 then loyalty_offset_top_1() else if instance == 2 then loyalty_offset_top_2() else loyalty_offset_top_3() }
loyalty_offset_left := { if instance <= 1 then loyalty_offset_left_1() else if instance == 2 then loyalty_offset_left_2() else loyalty_offset_left_3() }
loyalty_offset_width := { if instance <= 1 then loyalty_offset_width_1() else if instance == 2 then loyalty_offset_width_2() else loyalty_offset_width_3() }
loyalty_offset_height := { if instance <= 1 then loyalty_offset_height_1() else if instance == 2 then loyalty_offset_height_2() else loyalty_offset_height_3() }
loyalty_cost_offset_top := { if instance <= 1 then loyalty_cost_offset_top_1() else if instance == 2 then loyalty_cost_offset_top_2() else loyalty_cost_offset_top_3() }
loyalty_cost_offset_left := { if instance <= 1 then loyalty_cost_offset_left_1() else if instance == 2 then loyalty_cost_offset_left_2() else loyalty_cost_offset_left_3() }
loyalty_cost_offset_width := { if instance <= 1 then loyalty_cost_offset_width_1() else if instance == 2 then loyalty_cost_offset_width_2() else loyalty_cost_offset_width_3() }
loyalty_cost_offset_height := { if instance <= 1 then loyalty_cost_offset_height_1() else if instance == 2 then loyalty_cost_offset_height_2() else loyalty_cost_offset_height_3() }
loyalty_cost_offset_text_margin := { if instance <= 1 then loyalty_cost_offset_text_margin_1() else if instance == 2 then loyalty_cost_offset_text_margin_2() else loyalty_cost_offset_text_margin_3() }
loyalty_textbox_mask := { if instance <= 1 then loyalty_textbox_mask_1() else if instance == 2 then loyalty_textbox_mask_2() else loyalty_textbox_mask_3() }
#### All these functions are implicitly passed and passing the 'instance' argument:
a_left := { face := loyalty_face(); face_coordinates_map(face).left }
a_top := { face := loyalty_face(); face_coordinates_map(face).top }
a_bottom := { face := loyalty_face(); face_coordinates_map(face).top + face_coordinates_map(face).height }
a_width := { face := loyalty_face(); face_coordinates_map(face).width }
a_height := { face := loyalty_face(); face_coordinates_map(face).height }
r_width := { face := loyalty_face(); face_coordinates_map(face).width/375 }
r_height := { face := loyalty_face(); face_coordinates_map(face).height/523 }
to_744_width := { input/a_width()*744 }
to_744_height := { input/a_height()*1039 }
loyalty_left := { round_near((if contains(loyalty_box_field(instance), match: "defense") then 323 else 313) * r_width() + a_left() + loyalty_offset_left() - loyalty_offset_width()) }
loyalty_top := { round_near(472 * r_height() + a_top() + loyalty_offset_top() - loyalty_offset_height()) }
loyalty_width := { (if contains(loyalty_box_field(instance), match: "defense") then 20 else 40) * r_width() + 2*loyalty_offset_width() }
loyalty_height := { 21 * r_height() + 2*loyalty_offset_height() }
loyalty_font_size := { (if contains(loyalty_box_field(instance), match: "defense") then 15 else 17) * (21 * r_height() + 0.8*loyalty_offset_height())/21 }
loyalty_box_left := { 301 * r_width() + a_left() + loyalty_offset_left() - loyalty_offset_width() }
loyalty_box_top := { 457 * r_height() + a_top() + loyalty_offset_top() - loyalty_offset_height() }
loyalty_box_width := { 64 * r_width() + 2*loyalty_offset_width() }
loyalty_box_height := { 52.5 * r_height() + 2*loyalty_offset_height() }
loyalty_cost_left := { round_near(loyalty_ability_left() - 24 * r_width() + loyalty_cost_offset_left() - loyalty_cost_offset_width()) }
loyalty_cost_top := { round_near(loyalty_ability_center(input) - loyalty_cost_r_height()/2 + loyalty_cost_r_correction(input) + loyalty_cost_move(input) + loyalty_cost_offset_top() - loyalty_cost_offset_height()) }
loyalty_cost_width := { loyalty_cost_r_width() + 2*loyalty_cost_offset_width() }
loyalty_cost_height := { if loyalty_abilities_count() >= input then loyalty_cost_r_height() + 2*loyalty_cost_offset_height() else 0 }
loyalty_cost_r_width := { 24 * r_width() }
loyalty_cost_r_height := { 20 * r_height() }
loyalty_cost_r_correction :=
{
cost := card["loyalty_cost_box_" + input]
if contains(cost, match: "+") or contains(cost, match: "anti ult") then -1 * r_height()
else if contains(cost, match: "-") or contains(cost, match: "ult") then -5 * r_height()
else -3 * r_height()
}
loyalty_cost_font_size := { 13 * (loyalty_cost_r_height() + 0.8*loyalty_cost_offset_height())/20 }
loyalty_cost_box_left := { loyalty_ability_left() - 36 * r_width() + loyalty_cost_offset_left() - loyalty_cost_offset_width() }
loyalty_cost_box_top := { loyalty_ability_center(input) - loyalty_cost_box_r_height()/2 + loyalty_cost_move(input) + loyalty_cost_offset_top() - loyalty_cost_offset_height() }
loyalty_cost_box_width := { loyalty_cost_box_r_width() + 2*loyalty_cost_offset_width() }
loyalty_cost_box_height := { if loyalty_abilities_count() >= input then loyalty_cost_box_r_height() + 2*loyalty_cost_offset_height() else 0 }
loyalty_cost_box_r_width := { 47 * r_width() }
loyalty_cost_box_r_height := { 36 * r_height() }
loyalty_colon_left := { round_near(loyalty_ability_left() + 9 * r_width() + loyalty_cost_offset_left() + loyalty_cost_offset_width()) }
loyalty_colon_top := { round_near(loyalty_ability_center(input) - loyalty_colon_r_height()/2 + loyalty_colon_r_correction(input) + loyalty_cost_move(input) + loyalty_cost_offset_top() - loyalty_cost_offset_height()) }
loyalty_colon_width := { loyalty_colon_r_width() }
loyalty_colon_height := { loyalty_colon_r_height() }
loyalty_colon_r_width := { 5 * r_width() }
loyalty_colon_r_height := { 21 * r_height() }
loyalty_colon_r_correction := { -3 * r_height() }
loyalty_colon_font_size := { 13 * (loyalty_colon_r_height() + 2*loyalty_cost_offset_height())/21 }
loyalty_stripe_separator_top := { (loyalty_ability_bottom(input) + loyalty_ability_top(input+1) - loyalty_stripe_separator_height())/2 + loyalty_separator_move(input) }
loyalty_stripe_separator_height := { 8.06 * r_height() }
loyalty_cost_move :=
{
styling_field := if instance <= 1 then (styling.move_loyalty_costs or else "") else (styling["move_loyalty_costs_" + instance] or else "")
text := pull_comma_array(styling_field, cell:input-1, end:0, default:0)
if text == "-" then 0 else clamp(text, minimum: -300, maximum: 300)
}
loyalty_separator_move :=
{
styling_field := if instance <= 1 then (styling.move_separators or else "") else (styling["move_separators_" + instance] or else "")
text := pull_comma_array(styling_field, cell:input-1, end:0, default:0)
if text == "-" then 0 else clamp(text, minimum: -300, maximum: 300)
}
loyalty_level_is_active :=
{
number := to_int(replace(input, match: "lv", replace: "")) or else 999
if number > 24 then false else (
instance := if number < 9 then 1 else if number < 17 then 2 else 3
loyalty_abilities_count() >= (number mod 8))
}
loyalty_abilities_count :=
{
styling_field := if instance <= 1 then (styling.number_of_textboxes or else "0") else (styling["number_of_textboxes_" + instance] or else "0")
to_int(styling_field)
}
loyalty_ability_left :=
{
style_field := text_style_field(loyalty_text_field())
if style_field.left or else 0 > 0
then style_field.left
else stylesheet.card_width * 1.2
}
loyalty_ability_top :=
{
style_field := text_style_field(loyalty_text_field())
if style_field.layout.blocks[input-1].bottom or else 0 > 0
then style_field.top + style_field.layout.blocks[input-1].top
else stylesheet.card_height * 1.2
}
loyalty_ability_center :=
{
style_field := text_style_field(loyalty_text_field())
if style_field.layout.blocks[input-1].bottom or else 0 > 0
then style_field.top + style_field.layout.blocks[input-1].middle
else stylesheet.card_height * 1.2
}
loyalty_ability_bottom :=
{
style_field := text_style_field(loyalty_text_field())
if style_field.layout.blocks[input-1].bottom or else 0 > 0
then style_field.top + style_field.layout.blocks[input-1].bottom
else stylesheet.card_height * 1.2
}
loyalty_stripe_separator_mask :=
{
mask := loyalty_textbox_mask()
if mask == "/magic-modules.mse-include/loyalty/default_textbox_stamp_mask.png"
or mask == "/magic-modules.mse-include/loyalty/default_textbox_mask.png" then
(
crop_safe(
mask,
offset_x: 0,
offset_y: to_744_height(loyalty_stripe_separator_top(input) - a_top()),
width: 744,
height: to_744_height(loyalty_stripe_separator_height()),
max_x: 744,
max_y: 1039
)
)
else
(
crop_safe(
mask,
offset_x: 0,
offset_y: loyalty_stripe_separator_top(input) - a_top(),
width: a_width(),
height: loyalty_stripe_separator_height(),
max_x: a_width(),
max_y: a_height()
)
)
}
loyalty_stripe_mask :=
{
mask := loyalty_textbox_mask()
if mask == "/magic-modules.mse-include/loyalty/default_textbox_stamp_mask.png"
or mask == "/magic-modules.mse-include/loyalty/default_textbox_mask.png" then
(
top := if input > 1 then loyalty_stripe_separator_top(2*input-2) + loyalty_stripe_separator_height() else a_top()
height := (if loyalty_abilities_count() >= 2*input then loyalty_stripe_separator_top(2*input-1) else a_bottom()) - top
top := to_744_height(top - a_top())
height := to_744_height(height)
crop_safe(
mask,
offset_x: 0,
offset_y: top,
width: 744,
height: height,
max_x: 744,
max_y: 1039
)
)
else
(
top := if input > 1 then loyalty_stripe_separator_top(2*input-2) + loyalty_stripe_separator_height() else a_top()
height := (if loyalty_abilities_count() >= 2*input then loyalty_stripe_separator_top(2*input-1) else a_bottom()) - top
top := top - a_top()
crop_safe(
mask,
offset_x: 0,
offset_y: top,
width: a_width(),
height: height,
max_x: a_width(),
max_y: a_height()
)
)
}
loyalty_stripe_separator_image :=
{
color := if instance <= 1 then (styling.stripes_color or else rgb(255,255,255)) else (styling["stripes_color_" + instance] or else rgb(255,255,255))
alpha := if instance <= 1 then (styling.stripes_opacity_percentage or else "40") else (styling["stripes_opacity_percentage_" + instance] or else "40")
set_alpha(
recolor_image(
"/magic-modules.mse-include/loyalty/stripe_" + (if (input mod 2) == 0 then "top" else "bottom") + ".png",
color: color
),
alpha: get_alpha_percentage(
alpha,
default: 40
)
)
}
loyalty_stripe_image :=
{
color := if instance <= 1 then (styling.stripes_color or else rgb(255,255,255)) else (styling["stripes_color_" + instance] or else rgb(255,255,255))
alpha := if instance <= 1 then (styling.stripes_opacity_percentage or else "40") else (styling["stripes_opacity_percentage_" + instance] or else "40")
set_alpha(
recolor_image(
"/magic-modules.mse-include/loyalty/color.png",
color: color
),
alpha: get_alpha_percentage(
alpha,
default: 40
)
)
}
loyalty_textbox_background_image :=
{
color := if instance <= 1 then (styling.textbox_color or else rgb(255,255,255)) else (styling["textbox_color_" + instance] or else rgb(255,255,255))
alpha := if instance <= 1 then (styling.textbox_opacity_percentage or else "70") else (styling["textbox_opacity_percentage_" + instance] or else "70")
set_alpha(
recolor_image(
"/magic-modules.mse-include/loyalty/color.png",
color: color
),
alpha: get_alpha_percentage(
alpha,
default: 70
)
)
}
############################################################## Separators
separator_enable_level := { false }
separator_default := { if set.use_flavor_bar then "flavor bar" else "none" }
flavor_bar_left := { face_coordinates_map(input).left }
flavor_bar_top :=
{
style := if input <= 1 then card_style.text else card_style["text_" + input]
rule := if input <= 1 then card.rule_text else card["rule_text_" + input]
flavor := if input <= 1 then card.flavor_text else card["flavor_text_" + input]
disabled := if input <= 1 then flavor_bar_disabled_1() else if input == 2 then flavor_bar_disabled_2() else flavor_bar_disabled_3()
uninitialized := (style.layout.blocks[1].bottom or else 0) <= 0
if disabled
or rule == ""
or remove_tags(flavor) == ""
then stylesheet.card_height + 1
else if uninitialized
then (if input <= 1 then old_bar_equation() else if input == 2 then old_bar_equation2() else old_bar_equation3()) - flavor_bar_height(input)/2
else style.top + (style.layout.blocks[0].bottom + style.layout.blocks[1].top)/2 - flavor_bar_height(input)/2
}
flavor_bar_width := { face_coordinates_map(input).width }
flavor_bar_height := { 24 * face_coordinates_map(input).height/1039 }
flavor_bar_disabled_1 := { false }
flavor_bar_offset_top_1 := { 0 }
flavor_bar_offset_left_1 := { 0 }
flavor_bar_offset_width_1 := { 0 }
flavor_bar_offset_height_1 := { 0 }
flavor_bar_disabled_2 := { false }
flavor_bar_offset_top_2 := { 0 }
flavor_bar_offset_left_2 := { 0 }
flavor_bar_offset_width_2 := { 0 }
flavor_bar_offset_height_2 := { 0 }
flavor_bar_disabled_3 := { false }
flavor_bar_offset_top_3 := { 0 }
flavor_bar_offset_left_3 := { 0 }
flavor_bar_offset_width_3 := { 0 }
flavor_bar_offset_height_3 := { 0 }
############################################################## Watermark offsets
watermark_face_1 := { 1 }
watermark_text_field_1 := { 1 }
watermark_stamp_field_1 := { 1 }
watermark_disabled_1 := { false }
watermark_offset_top_1 := { 0 }
watermark_offset_left_1 := { 0 }
watermark_offset_width_1 := { 0 }
watermark_offset_height_1 := { 0 }
watermark_offset_stamp_1 := { 0 }
watermark_face_2 := { 2 }
watermark_text_field_2 := { 2 }
watermark_stamp_field_2 := { 2 }
watermark_disabled_2 := { false }
watermark_offset_top_2 := { 0 }
watermark_offset_left_2 := { 0 }
watermark_offset_width_2 := { 0 }
watermark_offset_height_2 := { 0 }
watermark_offset_stamp_2 := { 0 }
watermark_face_3 := { 3 }
watermark_text_field_3 := { 3 }
watermark_stamp_field_3 := { 3 }
watermark_disabled_3 := { false }
watermark_offset_top_3 := { 0 }
watermark_offset_left_3 := { 0 }
watermark_offset_width_3 := { 0 }
watermark_offset_height_3 := { 0 }
watermark_offset_stamp_3 := { 0 }
############################################################## Color indicator offsets
indicator_left :=
{
map := face_coordinates_map(face)
if map.width > map.height then
map.left + 65 * map.width/523 + offset
else map.left + 31 * map.width/375 + offset
}
indicator_top :=
{
map := face_coordinates_map(face)
if map.width > map.height then
map.top + 223 * map.height/375 + offset
else map.top + 301 * map.height/523 + offset
}
indicator_size :=
{
map := face_coordinates_map(face)
17 * min(map.width, map.height)/375 + offset
}
indicator_disabled_1 := { false }
indicator_offset_top_1 := { 0 }
indicator_offset_left_1 := { 0 }
indicator_offset_size_1 := { 0 }
indicator_left_1 := { indicator_left(face:typeline_face_1(), offset: indicator_offset_left_1()) }
indicator_top_1 := { indicator_top(face:typeline_face_1(), offset: indicator_offset_top_1()) }
indicator_size_1 := { indicator_size(face:typeline_face_1(), offset: indicator_offset_size_1()) }
indicator_disabled_2 := { false }
indicator_offset_top_2 := { 0 }
indicator_offset_left_2 := { 0 }
indicator_offset_size_2 := { 0 }
indicator_left_2 := { indicator_left(face:typeline_face_2(), offset: indicator_offset_left_2()) }
indicator_top_2 := { indicator_top(face:typeline_face_2(), offset: indicator_offset_top_2()) }
indicator_size_2 := { indicator_size(face:typeline_face_2(), offset: indicator_offset_size_2()) }
indicator_disabled_3 := { false }
indicator_offset_top_3 := { 0 }
indicator_offset_left_3 := { 0 }
indicator_offset_size_3 := { 0 }
indicator_left_3 := { indicator_left(face:typeline_face_3(), offset: indicator_offset_left_3()) }
indicator_top_3 := { indicator_top(face:typeline_face_3(), offset: indicator_offset_top_3()) }
indicator_size_3 := { indicator_size(face:typeline_face_3(), offset: indicator_offset_size_3()) }
############################################################## Rarity offsets
rarity_right :=
{
map := face_coordinates_map(face)
user_offsets := styling.rarity_offsets or else ""
if map.width > map.height then
map.left + (483 * map.width/523) + offset + rarity_user_offset_left(user_offsets)
else map.left + (344 * map.width/375) + offset + rarity_user_offset_left(user_offsets)
}
rarity_top :=
{
map := face_coordinates_map(face)
user_offsets := styling.rarity_offsets or else ""
if map.width > map.height then
map.top + 219 * map.height/375 + offset + rarity_user_offset_top(user_offsets)
else map.top + 297 * map.height/523 + offset + rarity_user_offset_top(user_offsets)
}
rarity_width :=
{
map := face_coordinates_map(face)
user_offsets := styling.rarity_offsets or else ""
if map.width > map.height then
44 * map.width/523 + offset + rarity_user_offset_top(user_offsets) + rarity_user_offset_width(user_offsets)
else 44 * map.width/375 + offset + rarity_user_offset_top(user_offsets) + rarity_user_offset_width(user_offsets)
}
rarity_height :=
{
map := face_coordinates_map(face)
user_offsets := styling.rarity_offsets or else ""
if map.width > map.height then
22 * map.height/375 + offset + rarity_user_offset_top(user_offsets) + rarity_user_offset_height(user_offsets)
else 22 * map.height/523 + offset + rarity_user_offset_top(user_offsets) + rarity_user_offset_height(user_offsets)
}
rarity_size :=
{
map := face_coordinates_map(face)
user_offsets := styling.rarity_offsets or else ""
24 * min(map.width, map.height)/375 + offset + 2*rarity_user_offset_size(user_offsets)
}
rarity_real_width := {
map := face_coordinates_map(face)
multi := if map.width > map.height then
map.height/375
else map.height/523
cw := if face > 1 then card_style["rarity_" + face].content_width else card_style.rarity.content_width
cwf := if cw > multi*44 then (if set.print_fix != "" then set.print_fix else multi*22) else if cw < multi*22 then multi*22 else cw
if not set.shorten_types_for_rarity or cw == 0 then 0 else cwf
}
rarity_disabled_1 := { false }
rarity_offset_top_1 := { 0 }
rarity_offset_left_1 := { 0 }
rarity_offset_size_1 := { 0 }
rarity_right_1 := { rarity_right(face:typeline_face_1(), offset:rarity_offset_left_1()) }
rarity_top_1 := { rarity_top(face:typeline_face_1(), offset:rarity_offset_top_1()) }
rarity_height_1 := { rarity_height(face:typeline_face_1(), offset:rarity_offset_size_1()) }
rarity_width_1 := { rarity_width(face:typeline_face_1(), offset:rarity_offset_size_1()) }
rarity_left_1 := { rarity_right_1() - rarity_real_width(face:typeline_face_1()) }
rarity_disabled_2 := { false }
rarity_offset_top_2 := { 0 }
rarity_offset_left_2 := { 0 }
rarity_offset_size_2 := { 0 }
rarity_right_2 := { rarity_right(face:typeline_face_2(), offset:rarity_offset_left_2()) }
rarity_top_2 := { rarity_top(face:typeline_face_2(), offset:rarity_offset_top_2()) }
rarity_height_2 := { rarity_height(face:typeline_face_2(), offset:rarity_offset_size_2()) }
rarity_width_2 := { rarity_width(face:typeline_face_2(), offset:rarity_offset_size_2()) }
rarity_left_2 := { rarity_right_2() - rarity_real_width(face:typeline_face_2()) }
rarity_disabled_3 := { false }
rarity_offset_top_3 := { 0 }
rarity_offset_left_3 := { 0 }
rarity_offset_size_3 := { 0 }
rarity_right_3 := { rarity_right(face:typeline_face_3(), offset:rarity_offset_left_3()) }
rarity_top_3 := { rarity_top(face:typeline_face_3(), offset:rarity_offset_top_3()) }
rarity_height_3 := { rarity_height(face:typeline_face_3(), offset:rarity_offset_size_3()) }
rarity_width_3 := { rarity_width(face:typeline_face_3(), offset:rarity_offset_size_3()) }
rarity_left_3 := { rarity_right_3() - rarity_real_width(face:typeline_face_3()) }
rarity_user_offset_left := { split := split_comma(input); if length(split) > 0 and split.0 != "" and split.0 != "-" then clamp(split.0, maximum:500, minimum:-500) else 0 }
rarity_user_offset_top := { split := split_comma(input); if length(split) > 1 and split.1 != "" and split.1 != "-" then clamp(split.1, maximum:500, minimum:-500) else 0 }
rarity_user_offset_width := { split := split_comma(input); if length(split) > 2 and split.2 != "" and split.2 != "-" then clamp(split.2, maximum:500, minimum:-500) else 0 }
rarity_user_offset_height := { split := split_comma(input); if length(split) > 3 and split.2 != "" and split.3 != "-" then clamp(split.3, maximum:500, minimum:-500) else 0 }
############################################################## Type offsets
type_indicator_shift :=
{
if (not identity) or disabled
then 0
else offset
}
type_disabled_1 := { false }
type_offset_top_1 := { 0 }
type_offset_left_1 := { 0 }
type_offset_right_1 := { 0 }
type_offset_height_1 := { 0 }
type_indicator_shift_1 := { type_indicator_shift(identity:has_identity(), offset:indicator_size_1()*1.15 + typeline_offset_height_1(), disabled:indicator_disabled_1()) }
type_disabled_2 := { false }
type_offset_top_2 := { 0 }
type_offset_left_2 := { 0 }
type_offset_right_2 := { 0 }
type_offset_height_2 := { 0 }
type_indicator_shift_2 := { type_indicator_shift(identity:has_identity_2(), offset:indicator_size_2()*1.15 + typeline_offset_height_2(), disabled:indicator_disabled_2()) }
type_disabled_3 := { false }
type_offset_top_3 := { 0 }
type_offset_left_3 := { 0 }
type_offset_right_3 := { 0 }
type_offset_height_3 := { 0 }
type_indicator_shift_3 := { type_indicator_shift(identity:has_identity_3(), offset:indicator_size_3()*1.15 + typeline_offset_height_3(), disabled:indicator_disabled_3()) }
typeline_face_1 := { 1 }
typeline_disabled_1 := { false }
typeline_offset_top_1 := { 0 }
typeline_offset_left_1 := { 0 }
typeline_offset_width_1 := { 0 }
typeline_offset_height_1 := { 0 }
typeline_face_2 := { 2 }
typeline_disabled_2 := { false }
typeline_offset_top_2 := { 0 }
typeline_offset_left_2 := { 0 }
typeline_offset_width_2 := { 0 }
typeline_offset_height_2 := { 0 }
typeline_face_3 := { 3 }
typeline_disabled_3 := { false }
typeline_offset_top_3 := { 0 }
typeline_offset_left_3 := { 0 }
typeline_offset_width_3 := { 0 }
typeline_offset_height_3 := { 0 }
############################################################## Casting cost offsets
casting_cost_right :=
{
map := face_coordinates_map(face)
if map.width > map.height then
map.left + 485 * map.width/523 + offset
else map.left + 346 * map.width/375 + offset
}
casting_cost_top :=
{
map := face_coordinates_map(face)
if map.width > map.height then
map.top + 19 * map.height/375 + offset
else map.top + 27 * map.height/523 + offset
}
casting_cost_width :=
{
map := face_coordinates_map(face)
scale := min(map.width, map.height)/375
minimum := 30 * scale
buffer := 5 * scale
max(minimum, card_style.casting_cost.content_width) + buffer + offset
}
casting_cost_height :=
{
map := face_coordinates_map(face)
26 * min(map.width, map.height)/375 + offset
}
casting_cost_disabled_1 := { false }
casting_cost_offset_top_1 := { 0 }
casting_cost_offset_left_1 := { 0 }
casting_cost_offset_width_1 := { 0 }
casting_cost_offset_height_1 := { 0 }
casting_cost_right_1 := { casting_cost_right(face:nameline_face_1(), offset:casting_cost_offset_left_1()) }
casting_cost_top_1 := { casting_cost_top(face:nameline_face_1(), offset:casting_cost_offset_top_1()) }
casting_cost_width_1 := { casting_cost_width(face:nameline_face_1(), offset:casting_cost_offset_width_1()) }
casting_cost_height_1 := { casting_cost_height(face:nameline_face_1(), offset:casting_cost_offset_height_1()) }
casting_cost_disabled_2 := { false }
casting_cost_offset_top_2 := { 0 }
casting_cost_offset_left_2 := { 0 }
casting_cost_offset_width_2 := { 0 }
casting_cost_offset_height_2 := { 0 }
casting_cost_right_2 := { casting_cost_right(face:nameline_face_2(), offset:casting_cost_offset_left_2()) }
casting_cost_top_2 := { casting_cost_top(face:nameline_face_2(), offset:casting_cost_offset_top_2()) }
casting_cost_width_2 := { casting_cost_width(face:nameline_face_2(), offset:casting_cost_offset_width_2()) }
casting_cost_height_2 := { casting_cost_height(face:nameline_face_2(), offset:casting_cost_offset_height_2()) }
casting_cost_disabled_3 := { false }
casting_cost_offset_top_3 := { 0 }
casting_cost_offset_left_3 := { 0 }
casting_cost_offset_width_3 := { 0 }
casting_cost_offset_height_3 := { 0 }
casting_cost_right_3 := { casting_cost_right(face:nameline_face_3(), offset:casting_cost_offset_left_3()) }
casting_cost_top_3 := { casting_cost_top(face:nameline_face_3(), offset:casting_cost_offset_top_3()) }
casting_cost_width_3 := { casting_cost_width(face:nameline_face_3(), offset:casting_cost_offset_width_3()) }
casting_cost_height_3 := { casting_cost_height(face:nameline_face_3(), offset:casting_cost_offset_height_3()) }
############################################################## Name offsets
name_left :=
{
map := face_coordinates_map(face)
if map.width > map.height then
map.left + 67 * map.width/523 + offset
else map.left + 32 * map.width/375 + offset
}
name_top :=
{
map := face_coordinates_map(face)
if map.width > map.height then
map.top + 19 * map.height/375 + offset
else map.top + 27 * map.height/523 + offset
}
name_right :=
{
map := face_coordinates_map(face)
casting_cost_width_1 := if card_style.casting_cost.content_width == 0 then 0 else card_style.casting_cost.content_width + 3 * min(map.width, map.height)/375
if map.width > map.height then
map.left + 482 * map.width/523 - casting_cost_width_1 + offset
else map.left + 341 * map.width/375 - casting_cost_width_1 + offset
}
name_height :=
{
map := face_coordinates_map(face)
26 * min(map.width, map.height)/375 + offset
}
name_transform_symbol_shift :=
{
if transform_symbol_field(face) == "none" or disabled
then 0
else (
map := face_coordinates_map(face)
29 * (min(map.width, map.height)/375) + offset
)
}
name_card_symbol_shift := {
if card_symbol_field(face) == "none" or disabled
then 0
else (
map := face_coordinates_map(face)
18 * (min(map.width, map.height)/375) + offset
)
}
name_max_width_1 := { card_style.name.width }
name_disabled_1 := { false }
name_offset_top_1 := { 0 }
name_offset_left_1 := { 0 }
name_offset_right_1 := { 0 }
name_offset_height_1 := { 0 }
name_transform_symbol_offset_left_1 := { 0 }
name_left_1 := { name_left(face:nameline_face_1(), offset:name_offset_left_1()) }
name_top_1 := { name_top(face:nameline_face_1(), offset:name_offset_top_1()) }
name_right_1 := { name_right(face:nameline_face_1(), offset:name_offset_right_1()) }
name_height_1 := { name_height(face:nameline_face_1(), offset:name_offset_height_1()) }
name_card_symbol_shift_1 := { name_card_symbol_shift(face:nameline_face_1(), offset:name_transform_symbol_offset_left_1(), disabled:card_symbol_disabled_1()) }
name_transform_symbol_shift_1 := { name_transform_symbol_shift(face:nameline_face_1(), offset:name_transform_symbol_offset_left_1() + nameline_offset_height_1(), disabled:transform_symbol_disabled_1()) }
name_disabled_2 := { false }
name_offset_top_2 := { 0 }
name_offset_left_2 := { 0 }
name_offset_right_2 := { 0 }
name_offset_height_2 := { 0 }
name_transform_symbol_offset_left_2 := { 0 }
name_max_width_2 := { card_style.name_2.width }
name_left_2 := { name_left(face:nameline_face_2(), offset:name_offset_left_2()) }
name_top_2 := { name_top(face:nameline_face_2(), offset:name_offset_top_2()) }
name_right_2 := { name_right(face:nameline_face_2(), offset:name_offset_right_2()) }
name_height_2 := { name_height(face:nameline_face_2(), offset:name_offset_height_2()) }
name_card_symbol_shift_2 := { name_card_symbol_shift(face:nameline_face_2(), offset:name_transform_symbol_offset_left_2(), disabled:card_symbol_disabled_2()) }
name_transform_symbol_shift_2 := { name_transform_symbol_shift(face:nameline_face_2(), offset:name_transform_symbol_offset_left_2() + nameline_offset_height_2(), disabled:transform_symbol_disabled_2()) }
name_disabled_3 := { false }
name_offset_top_3 := { 0 }
name_offset_left_3 := { 0 }
name_offset_right_3 := { 0 }
name_offset_height_3 := { 0 }
name_transform_symbol_offset_left_3 := { 0 }
name_max_width_3 := { card_style.name_3.width }
name_left_3 := { name_left(face:nameline_face_3(), offset:name_offset_left_3()) }
name_top_3 := { name_top(face:nameline_face_3(), offset:name_offset_top_3()) }
name_right_3 := { name_right(face:nameline_face_3(), offset:name_offset_right_3()) }
name_height_3 := { name_height(face:nameline_face_3(), offset:name_offset_height_3()) }
name_card_symbol_shift_3 := { name_card_symbol_shift(face:nameline_face_3(), offset:name_transform_symbol_offset_left_3(), disabled:card_symbol_disabled_3()) }
name_transform_symbol_shift_3 := { name_transform_symbol_shift(face:nameline_face_3(), offset:name_transform_symbol_offset_left_3() + nameline_offset_height_3(), disabled:transform_symbol_disabled_3()) }
############################################################## Nameline offsets
nameline_face_1 := { 1 }
nameline_disabled_1 := { false }
nameline_offset_top_1 := { 0 }
nameline_offset_left_1 := { 0 }
nameline_offset_width_1 := { 0 }
nameline_offset_height_1 := { 0 }
nameline_face_2 := { 2 }
nameline_disabled_2 := { false }
nameline_offset_top_2 := { 0 }
nameline_offset_left_2 := { 0 }
nameline_offset_width_2 := { 0 }
nameline_offset_height_2 := { 0 }
nameline_face_3 := { 3 }
nameline_disabled_3 := { false }
nameline_offset_top_3 := { 0 }
nameline_offset_left_3 := { 0 }
nameline_offset_width_3 := { 0 }
nameline_offset_height_3 := { 0 }
############################################################## Stamps
### The stamp to use if the user hasn't overwritten it for this card
card_stamp_default := {
shape := styling.default_stamp or else set.default_stamp
stamp_behavior := styling.stamp_behavior or else set.stamp_behavior
if stamp_behavior == "default" or stamp_behavior == "flatstamped default" then stamp_behavior := set.stamp_behavior
rare_face := is_rare(field:field)
stamp_behavior_checks[stamp_behavior](rare_face:rare_face, shape:shape)
}@(field:1)
### Map for easier checks than if/else or case
stamp_behavior_checks := [
"All unstamped": {"none"},
"All holostamped": {shape},
"All flatstamped": {"flatstamped " + shape},
"Standard, rares holostamped": {
if rare_face then shape else "none"
},
"UB, rares holostamped, others flatstamped": {
if rare_face then shape else "flatstamped " + shape
}
]
### The image to use for custom stamp
custom_stamp := {
if set.custom_stamp_name != "" and has_png(set.custom_stamp_name)
then "/magic-mainframe-extras.mse-include/" + un_png(set.custom_stamp_name) + (if flat then " flat" else "") + ".png"
else "/magic-modules.mse-include/stamps/375x523 " + (if flat then "flatstamped " else "") + "heart.png"
}@(flat:false)
### The shape of the background stamp for templates
### This can be overwritten to give a template a special stamp for the heart stamp, for example
stamp_shape := {
case card_stamp_field(field) of
"universes beyond": "triangle",
"flatstamped universes beyond": "triangle",
"none": "none",
"custom": set.custom_stamp_shape,
"flatstamped custom": set.custom_stamp_shape,
else: "round";
}@(field:1)
### The card_stamp_X field for this face
card_stamp_field := { if input <= 1 then card.card_stamp else card["card_stamp_" + input] }
### Does this face have any stamp?
is_stamped := { card_stamp_field(field) != "none" }@(field: 1)
### Does this face have a foil stamp?
is_foil_stamped := { not contains(card_stamp_field(field), match:"flatstamped") }@(field:1)
### Determine the image for the stamp
card_stamp_image :=
{
if not is_stamped(field: field)
then ""
else (
map := face_coordinates_map(face)
if map.width == 0 or map.height == 0
then ""
else (
dimensions := map.width + "x" + map.height
dimensions := card_stamp_possible_dimensions[dimensions] or else (if map.width > map.height then "1039x744" else "744x1039")
shape := card_stamp_field(field)
if shape == "default" then shape := set.default_stamp
if shape == "custom" or shape == "flatstamped custom"
then custom_stamp(flat:not is_foil_stamped(field:field))
else "/magic-modules.mse-include/stamps/" + dimensions + " " + shape + ".png"
)
)
}
card_stamp_possible_dimensions :=
[
"375x523": "375x523"
"523x375": "523x375"
"744x1039": "744x1039"
"1039x744": "1039x744"
]
### Offsets for the stamps module
card_stamp_disabled_1 := { false }
card_stamp_offset_top_1 := { 0 }
card_stamp_offset_left_1 := { 0 }
card_stamp_offset_width_1 := { 0 }
card_stamp_offset_height_1 := { 0 }
card_stamp_disabled_2 := { false }
card_stamp_offset_top_2 := { 0 }
card_stamp_offset_left_2 := { 0 }
card_stamp_offset_width_2 := { 0 }
card_stamp_offset_height_2 := { 0 }
card_stamp_disabled_3 := { false }
card_stamp_offset_top_3 := { 0 }
card_stamp_offset_left_3 := { 0 }
card_stamp_offset_width_3 := { 0 }
card_stamp_offset_height_3 := { 0 }
############################################################## Pinlines
#### Face 1
pinline_disabled_1 := { false }
pinline_offset_left_1 := { 0 }
pinline_offset_top_1 := { 0 }
pinline_offset_width_1 := { 0 }
pinline_offset_height_1 := { 0 }
#### Face 2
pinline_disabled_2 := { false }
pinline_offset_left_2 := { 0 }
pinline_offset_top_2 := { 0 }
pinline_offset_width_2 := { 0 }
pinline_offset_height_2 := { 0 }
#### Face 3
pinline_disabled_3 := { false }
pinline_offset_left_3 := { 0 }
pinline_offset_top_3 := { 0 }
pinline_offset_width_3 := { 0 }
pinline_offset_height_3 := { 0 }
#### The primary image script. May apply a mask with set_mask to cut around art and other inner components
pinline_image_1 := {""}
pinline_image_2 := {""}
pinline_image_3 := {""}
#### The mask used within the image script
pinline_inner_mask_1 := {""}
pinline_inner_mask_2 := {""}
pinline_inner_mask_3 := {""}
#### The mask used on the actual field, allowing invisible parts to be clicked through
pinline_mask_1 := {""}
pinline_mask_2 := {""}
pinline_mask_3 := {""}
############################################################## Custom corner symbols
custom_symbol_1 := { if set.custom_symbol_1 != "" then "/magic-modules.mse-include/symbols/" + set.custom_symbol_1 else "/magic-modules.mse-include/symbols/aetherprint.png" }
custom_symbol_2 := { if set.custom_symbol_2 != "" then "/magic-modules.mse-include/symbols/" + set.custom_symbol_2 else "/magic-modules.mse-include/symbols/aetherprint.png" }
custom_symbol_3 := { if set.custom_symbol_3 != "" then "/magic-modules.mse-include/symbols/" + set.custom_symbol_3 else "/magic-modules.mse-include/symbols/aetherprint.png" }
custom_symbol_4 := { if set.custom_symbol_4 != "" then "/magic-modules.mse-include/symbols/" + set.custom_symbol_4 else "/magic-modules.mse-include/symbols/aetherprint.png" }
############################################################## Custom fonts
swap_font := {styling.apply_custom_fonts or else false}
split_font := split_text@(match:";")
pop_font_name := {split_font(input).0 or else ""}
pop_font_size := {split_font(input).1 or else ""}
pop_font_color := {split_font(input).2 or else ""}
pop_font_vertical := {split_font(input).3 or else ""}
pop_font_italic := {split_font(input).4 or else ""}
#### General swap functions
swap_font_name := {
if swap_font() then (
test := pop_font_name(src)
if test != "" then font_name := test
)
font_name
}
swap_font_size := {
if swap_font() then (
test := pop_font_size(src)
if test != "" then font_size := test
)
font_size
}
swap_font_color := {
if swap_font() then (
test := pop_font_color(src)
nums := split_text(test, match:",")
test_color := nil
if length(nums) >= 4 then test_color := rgba(nums.0, nums.1, nums.2, nums.3) or else nil
if test_color == nil and length(nums) >= 3 then test_color := rgb(nums.0, nums.1, nums.2) or else nil
if test_color == nil and test != "" then test_color := to_color(test) or else nil
if test_color != nil then font_color := test_color
) else ""
font_color
}
swap_font_vertical := {
if swap_font() then (
test := pop_font_vertical(src)
if test != "" then vertical := to_number(test)
)
vertical
}
swap_font_italic := {
if swap_font() then (
test := pop_font_italic(src)
test2 := pop_font_name(src)
if test != "" then font_name := test
else if test2 != "" then font_name := ""
)
font_name
}
#### defaults, can be changed in style
swap_fonts_name_default := [
name: {"Beleren Bold"},
size: {16},
color: {"black"},
vertical: {0},
italic: {""}
]
swap_fonts_name2_default := [
name: {"Beleren Bold"},
size: {16},
color: {"black"},
vertical: {0},
italic: {""}
]
swap_fonts_name3_default := [
name: {"Beleren Bold"},
size: {16},
color: {"black"},
vertical: {0},
italic: {""}
]
swap_fonts_type_default := [
name: {"Beleren Bold"},
size: {13},
color: {"black"},
vertical: {0},
italic: {""}
]
swap_fonts_type2_default := [
name: {"Beleren Bold"},
size: {13},
color: {"white"},
vertical: {0},
italic: {""}
]
swap_fonts_type3_default := [
name: {"Beleren Bold"},
size: {13},
color: {"white"},
vertical: {0},
italic: {""}
]
swap_fonts_body_default := [
name: {"MPlantin"},
size: {13},
color: {"black"},
vertical: {0},
italic: {"MPlantin-Italic"}
]
swap_fonts_pt_default := [
name: {"Beleren Bold"},
size: {16},
color: {"black"},
vertical: {0},
italic: {""}
]
swap_fonts_name_src := { styling.custom_name_font or else "" }
swap_fonts_name_src := { styling.custom_name_font or else "" }
swap_fonts_name2_src := { styling.custom_name_2_font or else "" }
swap_fonts_name3_src := { styling.custom_name_3_font or else "" }
swap_fonts_type_src := { styling.custom_type_font or else "" }
swap_fonts_type2_src := { styling.custom_type_2_font or else "" }
swap_fonts_type3_src := { styling.custom_type_3_font or else "" }
swap_fonts_body_src := { styling.custom_body_font or else "" }
swap_fonts_pt_src := { styling.custom_pt_font or else "" }
#### specific swap functions
name_font := {
swap_font_name(
src: swap_fonts_name_src(),
font_name: swap_fonts_name_default.name()
)
}
name_font_size := {
swap_font_size(
src: swap_fonts_name_src(),
font_size: swap_fonts_name_default.size()
) - shrink_name()
}
name_font_color := {
swap_font_color(
src: swap_fonts_name_src(),
font_color: swap_fonts_name_default.color()
)
}
name_font_vertical := {
swap_font_vertical(
src: swap_fonts_name_src(),
vertical: swap_fonts_name_default.vertical()
)
}
name_font_italic := {
swap_font_italic(
src: swap_fonts_name_src(),
font_name: swap_fonts_name_default.italic()
)
}
name2_font := {
swap_font_name(
src: swap_fonts_name2_src(),
font_name: swap_fonts_name2_default.name()
)
}
name2_font_size := {
swap_font_size(
src: swap_fonts_name2_src(),
font_size: swap_fonts_name2_default.size()
) - shrink_name2()
}
name2_font_color := {
swap_font_color(
src: swap_fonts_name2_src(),
font_color: swap_fonts_name2_default.color()
)
}
name2_font_vertical := {
swap_font_vertical(
src: swap_fonts_name2_src(),
vertical: swap_fonts_name2_default.vertical()
)
}
name2_font_italic := {
swap_font_italic(
src: swap_fonts_name2_src(),
font_name: swap_fonts_name2_default.italic()
)
}
name3_font := {
swap_font_name(
src: swap_fonts_name3_src(),
font_name: swap_fonts_name3_default.name()
)
}
name3_font_size := {
swap_font_size(
src: swap_fonts_name3_src(),
font_size: swap_fonts_name3_default.size()
) - shrink_name2()
}
name3_font_color := {
swap_font_color(
src: swap_fonts_name3_src(),
font_color: swap_fonts_name3_default.color()
)
}
name3_font_vertical := {
swap_font_vertical(
src: swap_fonts_name3_src(),
vertical: swap_fonts_name3_default.vertical()
)
}
name3_font_italic := {
swap_font_italic(
src: swap_fonts_name3_src(),
font_name: swap_fonts_name3_default.italic()
)
}
type_font := {
swap_font_name(
src: swap_fonts_type_src(),
font_name: swap_fonts_type_default.name()
)
}
type_font_size := {
swap_font_size(
src: swap_fonts_type_src(),
font_size: swap_fonts_type_default.size()
) - shrink_type()
}
type_font_color := {
swap_font_color(
src: swap_fonts_type_src(),
font_color: swap_fonts_type_default.color()
)
}
type_font_vertical := {
swap_font_vertical(
src: swap_fonts_type_src(),
vertical: swap_fonts_type_default.vertical()
)
}
type_font_italic := {
swap_font_italic(
src: swap_fonts_type_src(),
font_name: swap_fonts_type_default.italic()
)
}
type2_font := {
swap_font_name(
src: swap_fonts_type2_src(),
font_name: swap_fonts_type2_default.name()
)
}
type2_font_size := {
swap_font_size(
src: swap_fonts_type2_src(),
font_size: swap_fonts_type2_default.size()
) - shrink_type2()
}
type2_font_color := {
swap_font_color(
src: swap_fonts_type2_src(),
font_color: swap_fonts_type2_default.color()
)
}
type2_font_vertical := {
swap_font_vertical(
src: swap_fonts_type2_src(),
vertical: swap_fonts_type2_default.vertical()
)
}
type2_font_italic := {
swap_font_italic(
src: swap_fonts_type2_src(),
font_name: swap_fonts_type2_default.italic()
)
}
type3_font := {
swap_font_name(
src: swap_fonts_type3_src(),
font_name: swap_fonts_type3_default.name()
)
}
type3_font_size := {
swap_font_size(
src: swap_fonts_type3_src(),
font_size: swap_fonts_type3_default.size()
) - shrink_type2()
}
type3_font_color := {
swap_font_color(
src: swap_fonts_type3_src(),
font_color: swap_fonts_type3_default.color()
)
}
type3_font_vertical := {
swap_font_vertical(
src: swap_fonts_type3_src(),
vertical: swap_fonts_type3_default.vertical()
)
}
type3_font_italic := {
swap_font_italic(
src: swap_fonts_type3_src(),
font_name: swap_fonts_type3_default.italic()
)
}
body_font := {
swap_font_name(
src: swap_fonts_body_src(),
font_name: swap_fonts_body_default.name()
)
}
body_font_size := {
swap_font_size(
src: swap_fonts_body_src(),
font_size: swap_fonts_body_default.size()
)
}
body_font_color := {
swap_font_color(
src: swap_fonts_body_src(),
font_color: swap_fonts_body_default.color()
)
}
body_font_vertical := {
swap_font_vertical(
src: swap_fonts_body_src(),
vertical: swap_fonts_body_default.vertical()
)
}
body_font_italic := {
swap_font_italic(
src: swap_fonts_body_src(),
font_name: swap_fonts_body_default.italic()
)
}
body2_font := {
swap_font_name(
src: swap_fonts_body_src(),
font_name: swap_fonts_body_default.name()
)
}
body2_font_size := {
swap_font_size(
src: swap_fonts_body_src(),
font_size: swap_fonts_body_default.size()
)
}
body2_font_color := {
swap_font_color(
src: swap_fonts_body_src(),
font_color: swap_fonts_body_default.color()
)
}
body2_font_vertical := {
swap_font_vertical(
src: swap_fonts_body_src(),
vertical: swap_fonts_body_default.vertical()
)
}
body2_font_italic := {
swap_font_italic(
src: swap_fonts_body_src(),
font_name: swap_fonts_body_default.italic()
)
}
body3_font := {
swap_font_name(
src: swap_fonts_body_src(),
font_name: swap_fonts_body_default.name()
)
}
body3_font_size := {
swap_font_size(
src: swap_fonts_body_src(),
font_size: swap_fonts_body_default.size()
)
}
body3_font_color := {
swap_font_color(
src: swap_fonts_body_src(),
font_color: swap_fonts_body_default.color()
)
}
body3_font_vertical := {
swap_font_vertical(
src: swap_fonts_body_src(),
vertical: swap_fonts_body_default.vertical()
)
}
body3_font_italic := {
swap_font_italic(
src: swap_fonts_body_src(),
font_name: swap_fonts_body_default.italic()
)
}
pt_font := {
swap_font_name(
src: swap_fonts_pt_src(),
font_name: swap_fonts_pt_default.name()
)
}
pt_font_size := {
swap_font_size(
src: swap_fonts_pt_src(),
font_size: swap_fonts_pt_default.size()
)
}
pt_font_color := {
swap_font_color(
src: swap_fonts_pt_src(),
font_color: swap_fonts_pt_default.color()
)
}
pt_font_vertical := {
swap_font_vertical(
src: swap_fonts_pt_src(),
vertical: swap_fonts_pt_default.vertical()
)
}
pt_font_italic := {
swap_font_italic(
src: swap_fonts_pt_src(),
font_name: swap_fonts_pt_default.italic()
)
}
pt2_font := {
swap_font_name(
src: swap_fonts_pt_src(),
font_name: swap_fonts_pt_default.name()
)
}
pt2_font_size := {
swap_font_size(
src: swap_fonts_pt_src(),
font_size: swap_fonts_pt_default.size()
)
}
pt2_font_color := {
swap_font_color(
src: swap_fonts_pt_src(),
font_color: swap_fonts_pt_default.color()
)
}
pt2_font_vertical := {
swap_font_vertical(
src: swap_fonts_pt_src(),
vertical: swap_fonts_pt_default.vertical()
)
}
pt2_font_italic := {
swap_font_italic(
src: swap_fonts_pt_src(),
font_name: swap_fonts_pt_default.italic()
)
}
pt3_font := {
swap_font_name(
src: swap_fonts_pt_src(),
font_name: swap_fonts_pt_default.name()
)
}
pt3_font_size := {
swap_font_size(
src: swap_fonts_pt_src(),
font_size: swap_fonts_pt_default.size()
)
}
pt3_font_color := {
swap_font_color(
src: swap_fonts_pt_src(),
font_color: swap_fonts_pt_default.color()
)
}
pt3_font_vertical := {
swap_font_vertical(
src: swap_fonts_pt_src(),
vertical: swap_fonts_pt_default.vertical()
)
}
pt3_font_italic := {
swap_font_italic(
src: swap_fonts_pt_src(),
font_name: swap_fonts_pt_default.italic()
)
}
shrink_name := {0}
shrink_type := {0}
shrink_name2 := {0}
shrink_type2 := {0}
############################################################## Custom rarity symbol
use_main_rarity := { contains(set.mainframe_rarity_name, match: ".png") }
mainframe_rarity := {"/magic-mainframe-extras.mse-include/" + un_png(set.mainframe_rarity_name) + input + ".png"}
alt_rarity := { styling.alt_rarity_color or else "" }
use_alt_rarity := { alt_rarity() != "" }
alt_rarity_color := {
string := "83,67,53:177,150,131:0,0,0:0,0,0:0.07:"
src := alt_rarity()
if match(src, match:":$") then string := src
colons := length(filter_text(string, match:":"))
output := split_text(string, match:",|:")
splits := split_text(string, match:":")
final_num := to_real(splits[length(splits)-2]) or else 0
final_border := final_num > 0 and final_num < 1
final_num := if not final_border then "0.07" else to_string(final_num);
if final_border then (
colons := colons - 1;
string := replace(string, match:"{final_num}:", replace:"")
)
if colons == 4
then output := split_text(string+final_num+":", match:",|:")
if colons == 3
then output := split_text(string+splits[2]+":"+final_num+":", match:",|:")
else if colons == 2
then output := split_text(string+"0,0,0:0,0,0:"+final_num+":", match:",|:")
else if colons == 1
then output := split_text(string+splits[0]+":0,0,0:0,0,0:"+final_num+":", match:",|:")
output
}
alt_symbol := {
alt_array := alt_rarity_color()
symbol_variation(
symbol:set.symbol,
border_radius: alt_array.12,
fill_type: "linear gradient",
fill_color_1: rgb(alt_array.0, alt_array.1, alt_array.2),
fill_color_2: rgb(alt_array.3, alt_array.4, alt_array.5),
border_color_1: rgb(alt_array.6, alt_array.7, alt_array.8),
border_color_2: rgb(alt_array.9, alt_array.10, alt_array.11),
center_x:0.5, center_y:0.5, end_x:1, end_y:1
)
}
############################################################## Card column sorting
type_sort_script :=
{
if set.alphabetical_type_column then super_type + " " + sub_type else
#### first sort by 5 broad categories
(
if is_tokenish_statistics(card.shape) then "4"
else if lang_setting("is_nonstandard")(super_type) then "3"
else if lang_setting("is_land")(super_type) then "0"
else if lang_setting("is_spell")(super_type) then "2"
else "1" #### nonland permanents
) +
#### then check if creature
(if lang_setting("is_creature")(super_type) then "0" else "1") +
#### then sort by type, no need to re-check for land or creature
(if lang_setting("is_sorcery")(super_type) then "1" else "0") +
(if lang_setting("is_instant")(super_type) then "1" else "0") +
(if lang_setting("is_planeswalker")(super_type) then "1" else "0") +
(if lang_setting("is_battle")(super_type) then "1" else "0") +
(if lang_setting("is_enchantment")(super_type) then "1" else "0") +
(if lang_setting("is_artifact")(super_type) then "1" else "0") +
(if contains(card.shape, match: "rulestip") then "1" else "0") +
(if contains(card.shape, match: "checklist") then "1" else "0") +
(if lang_setting("is_token")(super_type)
or contains(card.shape, match: "token") then "1" else "0") +
(if lang_setting("is_emblem")(super_type)
or contains(card.shape, match: "emblem") then "1" else "0") +
(if contains(card.shape, match: "counter") then "1" else "0") +
(if contains(card.shape, match: "designation") then "1" else "0") +
(if lang_setting("is_conspiracy")(super_type) then "1" else "0") +
(if lang_setting("is_dungeon")(super_type) then "1" else "0") +
(if lang_setting("is_phenomenon")(super_type) then "1" else "0") +
(if lang_setting("is_plane")(super_type) then "1" else "0") +
(if lang_setting("is_scheme")(super_type) then "1" else "0") +
(if lang_setting("is_vanguard")(super_type) then "1" else "0") +
(if lang_setting("is_hero")(super_type) then "1" else "0") +
#### then sort by super type
(if lang_setting("is_ongoing")(super_type) then "1" else "0") +
(if lang_setting("is_basic")(super_type) then "1" else "0") +
(if lang_setting("is_legendary")(super_type) then "1" else "0") +
(if lang_setting("is_world")(super_type) then "1" else "0") +
(if lang_setting("is_snow")(super_type) then "1" else "0") +
(if lang_setting("is_kindred")(super_type) then "1" else "0") +
#### then sort by sub type
to_text(sub_type)
}
color_sort_script :=
{
if chosen(input, choice:"land") then "0" + prefixed_color_identity_statistic() + input
else "1" + prefixed_color_statistic() + input
}
rarity_sort_script :=
{
if input == "basic land" then "0"
else if input == "common" then "1"
else if input == "uncommon" then "2"
else if input == "rare" then "3"
else if input == "mythic rare" then "4"
else if input == "masterpiece" then "5"
else "6"
}
############################################################## Custom index
search_pull := filter_text@(match:"search(name|mana|type|rules|flavor|text|notes)")
search_snip := replace@(match:"search(name|mana|type|rules|flavor|text|notes)_", replace:"")
custom_index := {
sorting_index := split_text(set.custom_index, match:",")
for each field in sorting_index do
apply_index(to_lower(field))
or else (
search_index(to_lower(search_pull(field)), query:search_snip(field))
)
or else ""
}
apply_index := {
[
name: {
fill_len(to_string(position (
of: card
in: set
order_by: { sort_name(card.name) + sort_name(export_name())}
filter: set_filter()
)), lead:"0", fill_to:3)
},
alias: {
fill_len(to_string(position (
of: card
in: set
order_by: { sort_name(card.alias) + sort_name(export_name())}
filter: set_filter()
)), lead:"0", fill_to:3)
}
name2: {
fill_len(to_string(position (
of: card
in: set
order_by: { sort_name(card.name_2) + sort_name(export_name())}
filter: set_filter()
)), lead:"0", fill_to:3)
},
alias2: {
fill_len(to_string(position (
of: card
in: set
order_by: { sort_name(card.alias_2) + sort_name(export_name())}
filter: set_filter()
)), lead:"0", fill_to:3)
}
color: {fill_len(color_of_card(), lead:"A")},
"color category": {
indexes := [[lang_setting("colorless")], [lang_setting("white")], [lang_setting("blue")], [lang_setting("black")], [lang_setting("red")], [lang_setting("green")], [lang_setting("purple")], [lang_setting("pink")], [lang_setting("yellow")], [lang_setting("orange")], [lang_setting("brown")], [lang_setting("multicolor")], [lang_setting("hybrid")]]
fill_len(position(of:[card.color_category], in:indexes, lead:"0", fill_to:2))
},
"exact color": {
fill_len(card.exact_color, lead:"X", fill_to:5)
},
"color identity": {
fill_len(card.color_identity, lead:"X", fill_to:5)
},
"color count": {card.color_count},
"time created": {card.time_created},
"created": {card.time_created},
"time modified": {card.time_modified},
"modified": {card.time_modified},
"template": {fill_len(substring(card.template, begin:0, end:9), follow:" ", fill_to:10)},
artist: {fill_len(substring(card.illustrator, end:7), follow:" ", fill_to:7)},
artist2: {fill_len(substring(card.illustrator_2, end:7), follow:" ", fill_to:7)},
design: {fill_len(substring(card.card_code_text, end:7), follow:" ", fill_to:7)},
mv: {fill_len(to_string(cmc(card.casting_cost)), lead:"0")},
"mana value": {fill_len(to_string(cmc(card.casting_cost)), lead:"0")},
cmc: {fill_len(to_string(cmc(card.casting_cost)), lead:"0")},
"converted mana cost": {fill_len(to_string(cmc(card.casting_cost)), lead:"0")},
rarity: {index_of_rarity()},
power: {fill_len(card.power, lead:"0")},
toughness: {fill_len(card.toughness, lead:"0")},
pt: {fill_len(card.power, lead:"0") + fill_len(card.toughness, lead:"0")},
loyalty: {fill_len(card.loyalty, lead:"0")},
type: {fill_len(filter_text(match:"[A-Z][A-Z]?[A-Z]?", filter_text(match:"[A-Z]", card.super_type)), follow:"0", fill_to:3)},
hasrules: {if remove_tags(card.rule_text) != "" then "A" else "B"},
hasflavor: {if remove_tags(card.flavor_text) != "" then "A" else "B"},
hasrules2: {if remove_tags(card.rule_text_2) != "" then "A" else "B"},
hasflavor2: {if remove_tags(card.flavor_text_2) != "" then "A" else "B"},
][input]()
}
search_index := {
[
searchname: { if contains(card.name, match:query) or contains(card.name_2, match:query) then "A" else "B"},
searchmana: { if contains(card.casting_cost, match:query) or contains(card.casting_cost_2, match:query) then "A" else "B"},
searchtype: { if contains(card.type, match:query) or contains(card.type_2, match:query) then "A" else "B"},
searchrules: { if contains(card.rule_text, match:query) or contains(card.rule_text_2, match:query) then "A" else "B"},
searchflavor: { if contains(card.flavor_text, match:query) or contains(card.flavor_text_2, match:query) then "A" else "B"},
searchartist: { if contains(card.illustrator, match:query) or contains(card.illustrator_2, match:query) then "A" else "B"},
searchdesign: { if contains(card.card_code_text, match:query) then "A" else "B"},
searchtext: { if contains(card.text, match:query) or contains(card.text_2, match:query) then "A" else "B"},
searchnotes: { if contains(card.notes, match:query) then "A" else "B"},
unsearchname: { if contains(card.name, match:query) or contains(card.name_2, match:query) then "B" else "A"},
unsearchmana: { if contains(card.casting_cost, match:query) or contains(card.casting_cost_2, match:query) then "B" else "A"},
unsearchtype: { if contains(card.type, match:query) or contains(card.type_2, match:query) then "B" else "A"},
unsearchrules: { if contains(card.rule_text, match:query) or contains(card.rule_text_2, match:query) then "B" else "A"},
unsearchflavor: { if contains(card.flavor_text, match:query) or contains(card.flavor_text_2, match:query) then "B" else "A"},
unsearchartist: { if contains(card.illustrator, match:query) or contains(card.illustrator_2, match:query) then "B" else "A"},
unsearchdesign: { if contains(card.card_code_text, match:query) then "B" else "A"},
unsearchtext: { if contains(card.text, match:query) or contains(card.text_2, match:query) then "B" else "A"},
unsearchnotes: { if contains(card.notes, match:query) then "B" else "A"}
][input]()
}
index_of_rarity := {
if card.rarity == "basic land" then "A"
else if card.rarity == "common" then "C"
else if card.rarity == "uncommon" then "D"
else if card.rarity == "rare" then "E"
else if card.rarity == "mythic rare" then "F"
else if card.rarity == "special" then "G"
else "J"
}
############################################################## Skeleton generator
skeleton_commons := 19
skeleton_uncommons := 11
skeleton_rares := 7
skeleton_mythics := 2
skeleton_land_commons := 1
skeleton_land_uncommons := 5
skeleton_land_rares := 0
skeleton_gold_commons := 0
skeleton_gold_uncommons := 1
skeleton_gold_rares := 1
skeleton_shard_commons := 0
skeleton_shard_uncommons := 0
skeleton_shard_rares := 0
skeleton_wedge_commons := 0
skeleton_wedge_uncommons := 0
skeleton_wedge_rares := 0
skeleton_artifact_commons := 5
skeleton_artifact_uncommons := 5
skeleton_artifact_rares := 0
skeleton_blank_commons := 0
skeleton_blank_uncommons := 5
skeleton_blank_rares := 8
skeleton_blank_mythics := 5
#### generates a set of CCXX Skeleton cards for each color
#### by insertnamehere and cajun
skeleton_runner := {
cards := []
for x from 0 to length(letter_list)-1 do
(
for y from 1 to count do
if mana_list == "nope" then
(cards := cards + [new_card([name:prefix+letter_list[x]+fill_len(y, lead:"0"), rarity:rarity, card_color:color_list[x], super_type:super_type])];)
else
(cards := cards + [new_card([name:prefix+letter_list[x]+fill_len(y, lead:"0"), rarity:rarity, super_type:super_type, casting_cost:mana_list[x]])];)
)
cards
}@(count:1, rarity:"common", type:"", prefix:"C", super_type:"", color_list:["white", "blue", "black", "red", "green"], letter_list:["W", "U", "B", "R", "G"], mana_list:"nope")
#### outside to make singleton scripts easier
blank_list_5 := ["","","","",""]
blank_list_10 := ["","","","","","","","","",""]
mana_list_ally := ["WU","UB","BR","RG","GW"]
mana_list_enemy := ["WB","UR","BG","RW","GU"]
mana_list_shard := ["WUB","UBR","BRG","RGW","GWU"]
mana_list_wedge := ["WBG","URW","BGU","RWB","GUR"]
skeleton_script := {
cards := [];
cards := cards + skeleton_runner(count:skeleton_commons);
cards := cards + skeleton_runner(count:skeleton_uncommons, prefix:"U", rarity:"uncommon");
cards := cards + skeleton_runner(count:skeleton_rares, prefix:"R", rarity:"rare");
cards := cards + skeleton_runner(count:skeleton_mythics, prefix:"M", rarity:"mythic rare");
cards := cards + skeleton_runner(count:skeleton_gold_commons, prefix:"CM", rarity:"common", letter_list:blank_list_10, mana_list:mana_list_ally+mana_list_enemy);
cards := cards + skeleton_runner(count:skeleton_gold_uncommons, prefix:"UM", rarity:"uncommon", letter_list:blank_list_10, mana_list:mana_list_ally+mana_list_enemy);
cards := cards + skeleton_runner(count:skeleton_gold_rares, prefix:"RM", rarity:"rare", letter_list:blank_list_10, mana_list:mana_list_ally+mana_list_enemy);
cards := cards + skeleton_runner(count:skeleton_shard_commons, prefix:"CM", rarity:"common", letter_list:blank_list_5, mana_list:mana_list_shard);
cards := cards + skeleton_runner(count:skeleton_shard_uncommons, prefix:"UM", rarity:"uncommon", letter_list:blank_list_5, mana_list:mana_list_shard);
cards := cards + skeleton_runner(count:skeleton_shard_rares, prefix:"RM", rarity:"rare", letter_list:blank_list_5, mana_list:mana_list_shard);
cards := cards + skeleton_runner(count:skeleton_wedge_commons, prefix:"CM", rarity:"common", letter_list:blank_list_5, mana_list:mana_list_wedge);
cards := cards + skeleton_runner(count:skeleton_wedge_uncommons, prefix:"UM", rarity:"uncommon", letter_list:blank_list_5, mana_list:mana_list_wedge);
cards := cards + skeleton_runner(count:skeleton_wedge_rares, prefix:"RM", rarity:"rare", letter_list:blank_list_5, mana_list:mana_list_wedge);
for i from 1 to skeleton_artifact_commons do cards := cards + [new_card([name:"CA"+fill_len(i, lead:"0"), rarity:"common", super_type:"Artifact"])];
for i from 1 to skeleton_artifact_uncommons do cards := cards + [new_card([name:"UA"+fill_len(i, lead:"0"), rarity:"uncommon", super_type:"Artifact"])];
for i from 1 to skeleton_artifact_rares do cards := cards + [new_card([name:"RA"+fill_len(i, lead:"0"), rarity:"rare", super_type:"Artifact"])];
for i from 1 to skeleton_land_commons do cards := cards + [new_card([name:"CL"+fill_len(i, lead:"0"), super_type:"Land", rarity:"common"])];
for i from 1 to skeleton_land_uncommons do cards := cards + [new_card([name:"UL"+fill_len(i, lead:"0"), super_type:"Land", rarity:"uncommon"])];
for i from 1 to skeleton_land_rares do cards := cards + [new_card([name:"RL"+fill_len(i, lead:"0"), super_type:"Land", rarity:"rare"])];
for i from 1 to skeleton_blank_commons do cards := cards + [new_card([name:"CX"+fill_len(i, lead:"0"), rarity:"common"])];
for i from 1 to skeleton_blank_uncommons do cards := cards + [new_card([name:"UX"+fill_len(i, lead:"0"), rarity:"uncommon"])];
for i from 1 to skeleton_blank_rares do cards := cards + [new_card([name:"RX"+fill_len(i, lead:"0"), rarity:"rare"])];
for i from 1 to skeleton_blank_mythics do cards := cards + [new_card([name:"MX"+fill_len(i, lead:"0"), rarity:"mythic rare"])];
cards
}
skeleton_info := {
trace("Set Skeleton Generator Help:"
+"\nSet variables here to modify the Skeleton Add Cards script, for example 'skeleton_commons := 10'"
+"\nCurrent variables:\n"
+"skeleton_commons: " + skeleton_commons + " (of each color)\n"
+"skeleton_uncommons: " + skeleton_uncommons + " (of each color)\n"
+"skeleton_rares: " + skeleton_rares + " (of each color)\n"
+"skeleton_mythics: " + skeleton_mythics + " (of each color)\n"
+"skeleton_gold_commons: " + skeleton_gold_commons + " (of each color pair)\n"
+"skeleton_gold_uncommons: " + skeleton_gold_uncommons + " (of each color pair)\n"
+"skeleton_gold_rares: " + skeleton_gold_rares + " (of each color pair)\n"
+"skeleton_artifact_commons: " + skeleton_artifact_commons + "\n"
+"skeleton_artifact_uncommons: " + skeleton_artifact_uncommons + "\n"
+"skeleton_artifact_rares: " + skeleton_artifact_rares + "\n"
+"skeleton_land_commons: " + skeleton_land_commons + "\n"
+"skeleton_land_uncommons: " + skeleton_land_uncommons + "\n"
+"skeleton_land_rares: " + skeleton_land_rares + "\n"
+"skeleton_blank_commons: " + skeleton_blank_commons + "\n"
+"skeleton_blank_uncommons: " + skeleton_blank_uncommons + "\n"
+"skeleton_blank_rares: " + skeleton_blank_rares + "\n"
+"skeleton_blank_mythics: " + skeleton_blank_mythics + "\n"
+"skeleton_shard_commons: " + skeleton_shard_commons + "\n"
+"skeleton_shard_uncommons: " + skeleton_shard_uncommons + "\n"
+"skeleton_shard_rares: " + skeleton_shard_rares + "\n"
+"skeleton_wedge_commons: " + skeleton_wedge_commons + "\n"
+"skeleton_wedge_uncommons: " + skeleton_wedge_uncommons + "\n"
+"skeleton_wedge_rares: " + skeleton_wedge_rares)
}