﻿mse version: 0.3.7
full name: VS System
short name: VS
installer group: VS System/game files
icon: card-back.png
position hint: 3

version: 2008-08-08
depends on:
	package: vs-common.mse-include
	version: 2008-01-03

############################################################## Functions & filters
# General functions
init script:
	# Index for sorting, character/concealed, equipment, location then plot twist
	sort_index := {
		if	card.team=="Planet"		then "1"
		else if card.team=="PLANET"		then "1"
		else if card.team==""			then "3"
		else if	card.team=="EQUIPMENT"		then "4"
		else if	card.team=="Equipment"		then "4"
		else if card.team=="LOCATION"		then "5"
		else if card.team=="Location"		then "5"
		else if card.team=="PLOT TWIST"		then "6"
		else if card.team=="Plot Twist"		then "6"
		else 					     "2"
	};
	############################################################## Text Filters
	
	# add symbols to text
	symbol_filter :=
		# step 5a : add arrow/diamond/dot symbols
		replace_rule(
			match: "->|>>>|@|<>",
			replace: "<sym-auto>&</sym-auto>" )+
		# step 5b : longdash for keywords
		replace_rule(
			match: "--",
			replace: "—")+
		# step 5c : dot separator
		replace_rule(
			match: "`|::",
			replace: "•")+
		# step 5e : trademark symbol
		replace_rule(
			match: "TM",
			replace: "™")+
		# step 5e : copyright symbol
		replace_rule(
			match: "CR",
			replace: "©")
		
	# the rule text filter
	#  - adds -> symbols
	#  - adds @ symbols
	#  - adds :: symbols
	#  - makes text in parentheses italic
	text_filter := 
		# step 1 : remove all automatic tags
		tag_remove_rule(tag: "<sym-auto>") +
		tag_remove_rule(tag: "<i-auto>")   +
		tag_remove_rule(tag: "<b-auto>")   +
		# step 2 : reminder text for keywords
		expand_keywords@(
			condition: {
				correct_case
			}
			default_expand: {
				chosen(choice:if correct_case then mode else "lower case", set.automatic_reminder_text)
			},
			combine:        { "<b-auto>{keyword}</b-auto><atom-reminder-{mode}> ({process_english_hints(reminder)})</atom-reminder-{mode}>" }
			) +
		# step 3 : expand shortcut words ~ and CARDNAME
		replace_rule(
			match: "~|~THIS~|CARDNAME",
			in_context: "(^|[[:space:]])<match>",
			replace: "<atom-cardname>&</atom-cardname>"
			) +
		# step 4 : fill in atom fields
		tag_contents_rule(
			tag: "<atom-cardname>",
			contents: { if card.name=="" then "CARDNAME" else card.name }
			) +
		# step 5 : symbols
		symbol_filter +
		# step 6a : Bold keywords without reminder text
		replace_rule(
		 	match: "<kw[^>]*>[^<]+</kw-a>",
	 		replace: "<b-auto>&</b-auto>") +
		# step 6b : Bold keywords with reminder text
		replace_rule(
		 	match: "<kw[^>]*>[^<]+</kw-A>",
	 		replace: "<b-auto>&</b-auto>") +
		# step 7 : italic reminder text
		replace_rule(
		 	match: "[(][^)\n]*[)]?",
			in_context: "(^|[[:space:]])<match>|<atom-keyword><match>",
		 	replace: "<i-auto>&</i-auto>")
	
	############### Determine type of card
	c_optional_character := filter_rule(match: "Concealed—Optional")
	concealed_character := filter_rule(match: "Concealed")
	keyword_sort_equipment := filter_rule(match: "Transferable")
	keyword_sort_location := filter_rule(match: "Terraform")
	keyword_sort_plot_twist := filter_rule(match: "Ongoing:")
	card_type := {
		if      card.team == "Location"    				then "location"
		else if card.team == "LOCATION"					then "location"
		else if keyword_sort_location(card.rule_text) != ""     	then "location"
		else if card.team == "Planet"					then "planet"
		else if card.team == "PLANET"					then "planet"
		else if card.team == "Equipment"   				then "equipment visible equipment"
		else if card.team == "EQUIPMENT"				then "equipment visible equipment"
		else if keyword_sort_equipment(card.rule_text) != ""    	then "equipment visible equipment"
		else if card.team == "Plot Twist"  				then "plot twist"
		else if card.team == "PLOT TWIST"				then "plot twist"
		else if keyword_sort_plot_twist(card.rule_text) != ""   	then "plot twist"
		else if card.symbols == "ongoing"		        	then "plot twist"
		else if c_optional_character(card.rule_text) != ""		then c_optional_script()
		else if concealed_character(card.rule_text) != ""      		then concealed_script()
		else if card.team_2 != ""        				then "characters visible character dual"
		else if card.team_2_of_2 != "" 	   				then "characters visible character dual (new)"
		else								     "characters visible character"
	}
	# Default Concealed Optional Card Type
	c_optional_script := {
		if	card.team_2 != ""        			then "characters concealed-optional concealed-optional dual"
		else if	card.team_2_of_2 != "" 	   			then "characters concealed-optional concealed-optional dual (new)"
		else                                    		     "characters concealed-optional concealed-optional character"
	}
	# Default Concealed Card Type
	concealed_script := {
		if 	card.team_2 != ""        			then "characters hidden concealed dual"
		else if card.team_2_of_2 != "" 	   			then "characters hidden concealed dual (new)"
		else                                    		     "characters hidden concealed"
	}
	# Default symbols
	symbol_default := {
		if	keyword_sort_plot_twist(card.rule_text) != ""   then "ongoing"
		else ""
	}
	# Default 'team' name of card
	team := {
		if      is_location()   then "Location"
		else if is_equipment()  then "Equipment"
		else if is_plot_twist() then "Plot Twist"
		else                         ""
	}
	true_pass := {
		if	is_character() then false else true
	}
	
	# Only pass numbers
	only_numbers := filter_rule(match: "[0-9]")
	
	############### Type of card
	
	is_dual := {
		card.card_type == "characters visible character dual" or
	        card.card_type == "characters hidden concealed dual" or
	        card.card_type == "characters concealed-optional concealed-optional dual"
	}
	is_new_dual := {
		card.card_type == "characters visible character dual (new)" or
	        card.card_type == "characters hidden concealed dual (new)" or
	        card.card_type == "characters concealed-optional concealed-optional dual (new)"
	}
	is_not_new_dual := {
		card.card_type == "characters visible character" or
	        card.card_type == "characters visible character dual" or
	        card.card_type == "characters hidden character concealed" or
	        card.card_type == "characters hidden character concealed dual" or
		card.card_type == "characters concealed-optional concealed-optional character" or
	        card.card_type == "characters concealed-optional concealed-optional dual"
	}
	is_character := { contains(card.card_type, match: "characters")
	#	card.card_type == "characters visible character" or
	#        card.card_type == "characters visible character dual" or
	#        card.card_type == "characters visible character dual (new)" or
	#        card.card_type == "characters hidden concealed" or
	#        card.card_type == "characters hidden concealed dual" or
	#        card.card_type == "characters hidden concealed dual (new)" or
	#        card.card_type == "characters concealed-optional concealed-optional character" or
	#        card.card_type == "characters concealed-optional concealed-optional character dual" or
	#        card.card_type == "characters concealed-optional concealed-optional character dual (new)"
	}
	is_concealed := {
	        card.card_type == "characters hidden concealed" or
	        card.card_type == "characters hidden concealed dual" or
	        card.card_type == "characters hidden concealed dual (new)" or
		card.card_type == "characters concealed-optional concealed-optional character" or
	        card.card_type == "characters concealed-optional concealed-optional dual" or
	        card.card_type == "characters concealed-optional concealed-optional dual (new)" or
	        card.card_type == "concealed equipment" or
	        card.card_type == "concealed-optional equipment"
	}
	is_equipment := {
		card.card_type == "visible equipment" or
		card.card_type == "concealed equipment" or
	        card.card_type == "concealed-optional equipment"
	}
	is_location := {
		card.card_type == "location"
	}
	is_plot_twist := {
		card.card_type == "plot twist"
	}
	is_ch_or_eq := {
		is_character() or is_equipment()
	}
	is_ch_or_pt := {
		is_character() or is_plot_twist()
	}
	############### Watermark Scripts
	
	watermark_narrow := {
		card.watermark == "Marvel A-C Brood" or
		card.watermark == "Marvel A-C Brotherhood" or
		card.watermark == "Marvel D-H Hellfire Club" or
		card.watermark == "DC A-C Anti-Matter" or
		card.watermark == "DC A-C Arkham Inmates" or
		card.watermark == "DC N-S Shadowpact"
	}
	watermark_wide := {
		card.watermark == "Marvel D-H Horsemen of Apocalypse" or
		card.watermark == "DC I-M JLA" or
		card.watermark == "DC I-M JSA"
	}
	############### Determine Card Position
	pos_of_card := {
		position(
			of: card
			in: set
			order_by: {
				sort_index() + card.team + card.team_2_of_2 + card.team_2 + card.team_2_of_2_2 + card.name + card.version + " • " + card.team_affiliation
			}) + 1
	}
	
	word_count := break_text@(match:"[^[:space:]]+") + length
	
############################################################## Set fields
set field:
	type: text
	name: title
	description: This information will not appear on the card.
set field:
	type: choice
	name: logo
	choice: none
	choice: Marvel
	choice: DC-new
	choice: DC-old
	choice: Hellboy
	choice: Other...
	initial: none
	description: The logo for the company.
set field:
	type: text
	name: code
	description: Recommended only 3 Capital digits. Will appear before card number. ex: MOR-1
set field:
	type: text
	name: description
	multi line: true
	description: This information will not appear on the card.
set field:
	type: text
	name: artist
	description: Editting this will set 1 artist for all the cards and will appear in the artist bar below the picture.
set field:
	type: text
	name: copyright
	description: Copytight information. This information will not appear on the card.
set field:
	type: choice
	name: set rarity
	choice: common
	choice: uncommon
	choice: rare
	choice: promo
	initial: none
	description: Set the rarity for all cards in the set.
set field:
	type: multiple choice
	name: automatic reminder text
	choice: real
	choice: custom
	initial: custom
	# Convert from older mse versions
	script:
		if value = "yes" then "real, custom"
		else if value = "no" then ""
		else value
	description: For which kinds of keywords should reminder text be added by default? Note: you can enable/disable reminder text by right clicking the keyword.
set field:
	type: boolean
	name: automatic card numbers
	description: Should card numbers be shown on the cards?
############################# Default style
default set style:
	logo:
		font:
			size: 16
		render style: both
		choice images:
			Marvel: /vs-common.mse-include/marvel.png
			DC-new:	/vs-common.mse-include/dcnew.png
			DC-old: /vs-common.mse-include/dcold.png
			Hellboy: /vs-common.mse-include/hellboy.png
			Other...: /vs-common.mse-include/other.png
	title:
		padding left: 2
		font:
			size: 16
	automatic reminder text:
		render style: checklist
		direction: vertical
############################################################## Card fields
############################# Background stuff
card field:
	type: choice
	name: card type
	choice: characters
		choice: 
			name: visible
			choice: character
			choice: character dual
			choice: character dual (new)
		choice:
			name: hidden
			choice: concealed
			choice: concealed dual
			choice: concealed dual (new)
		choice:
			name: concealed-optional
			choice: concealed-optional character
			choice: concealed-optional dual
			choice: concealed-optional dual (new)
	choice:
		name: equipment
		choice: visible equipment
		choice: concealed equipment
		choice: concealed-optional equipment
	choice: location
	choice: plot twist
	choice: planet
	default: card_type()
	show statistics: false
############################# Name line
card field:
	type: text
	name: name
	editable: false
	show statistics: false
card field:
	type: text
	name: sep
	editable: false
	script: if is_character() and card.identity=="" then "™" else if is_character() and card.identity!="" then "™ <sym>@</sym>" else ""
	show statistics: false
card field:
	type: text
	name: identity
	editable: false
card field:
	type: text
	name: full name
	script: 
		combined_editor(
			field1: card.name,
			separator: card.sep,
			field2: card.identity,
			soft_before_empty: false,
			hide_when_empty:   false,
			type_over1: "TM",
			type_over2: "@"
		)
	identifying: true
	show statistics: false
	card list visible: true
	card list column: 1
	card list width: 200
	description: The name of the card, use @ for a diamond
card field:
	type: text
	name: cost
	script: only_numbers(value)
	icon: stats/cost.png
	card list visible: true
	card list column: 3
	card list alignment: right
	card list width: 37
	card list name: Cost
############################# Image
card field:
	type: image
	name: image
	show statistics: false
card field:
	type: choice
	name: card symbol
	choice: none
	choice: Marvel
	choice: DC-new
	choice: DC-old
	choice: Hellboy
	choice: Other...
	show statistics: false
	default: set.logo
	editable: false
	description: Double click to load a symbol for the card
card field:
	type: image
	name: custom symbol
	show statistics: false
card field:
	type: choice
	name: edition
	choice: first edition
	editable: false
	show statistics: false
############################# Type Bar
card field:
	type: text
	name: type text
	script: to_upper(value)
	editable: false
card field:
	type: text
	name: sub type
	script: to_upper(value)
	editable: false
card field:
	type: text
	name: type text full
	script:
		# Either just type_text, or type_text—sub_type 
		combined_editor(
			field1: card.type_text,
			separator: " - ",
			field2: card.sub_type,
			soft_before_empty: true,
			hide_when_empty:   true,
			type_over1: " -",
			type_over2: "-"
		)
	description: The type of the card
card field:
	type: choice
	name: type bar
	choice: type bar
	editable: false
	show statistics: false
############################# Version
card field:
	type: text
	name: version
	script: to_lower(value)
	editable: false
	show statistics: false
card field:
	type: text
	name: team affiliation
	script: to_lower(value)
	editable: false
card field:
	type: text
	name: version full
	script:
		# Either just version, or version • team_affiliation 
		combined_editor(
			field1: card.version,
			separator: " • ",
			field2: card.team_affiliation,
			soft_before_empty: true,
			hide_when_empty:   true,
			type_over1: " `"
			)
	card list visible: true
	card list column: 2
	show statistics: false
############################# Card ID
card field:
	type: text
	name: number
	save value: false
	script:
		if pos_of_card()<=9 then "00" + pos_of_card(value) else
		if pos_of_card()>=9 and pos_of_card()<=99 then "0" + pos_of_card(value) else
		"" + pos_of_card(value)
	card list visible: true
	card list column: 6
	card list width: 55
	card list name: #
	card list alignment: right
	editable: false
	show statistics: false
card field:
	type: text
	name: number text
	script: to_upper(value)
	default: set.code + "-" + card.number
	editable: false
	show statistics: false
card field:
	type: text
	name: number line
	save value: false
	show statistics: false
	script:
		if set.automatic_card_numbers then
			combined_editor(field1: set.code, separator: "-", field2: card.number)
		else
			forward_editor(field: card.number_text)
	description: Copyright of this card and cardnumber, the default value can be changed on the 'set info' tab
card field:
	type: text
	name: promo outliner
	save value: false
	show statistics: false
	editable: false
	default: card.number_line
card field:
	type: text
	name: promo outliner 2
	save value: false
	show statistics: false
	editable: false
	default: card.number_line
card field:
	type: choice
	name: rarity
	choice: common
	choice: uncommon
	choice: rare
	choice: promo
	default: set.set_rarity
	icon: stats/rarity.png
############################# Affiliation
card field:
	type: text
	name: team
	default: team()
	editable: false
	show statistics: false
card field:
	type: text
	name: team 2 of 2
	editable: false
	show statistics: false
card field:
	type: text
	name: team full
	script:
		# Either just team, or team • team 2 of 2 
		combined_editor(
			field1: card.team,
			separator: " • ",
			field2: card.team_2_of_2,
			soft_before_empty: true,
			hide_when_empty:   true,
			type_over1: " `"
		)
	description: The team of the card, use ` for a separator for dual cards
card field:
	type: text
	name: team 2
	editable: false
	show statistics: false
card field:
	type: text
	name: team 2 of 2 2
	editable: false
	show statistics: false
card field:
	type: text
	name: team 2 full
	script:
		# Either just team, or team 2 • team 2 of 2 2
		combined_editor(
			field1: card.team_2,
			separator: " • ",
			field2: card.team_2_of_2_2,
			soft_before_empty: true,
			hide_when_empty:   true,
			type_over1: " `"
		)
	description: The second affiliation of the card (for dual cards)
############################# FlightRange
card field:
	type: multiple choice
	name: symbols
	icon: stats/symbols.png
	choice: flight
	choice: range
	choice: ongoing
	default: symbol_default()
	description: Symbols for this card (flight/range/ongoing), multiple symbols can be selected
	show statistics: false
############################# Text box
card field:
	type: text
	name: rule text
	show statistics: false
	multi line: true
	script: text_filter(value)
	description: Rule text of the card, use @ for a diamond, -> for an arrow
card field:
	type: text
	name: flavor text
	show statistics: false
	multi line: true
card field:
	type: choice
	name: watermark
	include file: /vs-common.mse-include/watermark-names
	editable: false
	description: The Watermark for this set.
############################# Atack / Defense
card field:
	type: text
	name: attack
	script: only_numbers(value)
	icon: stats/attack.png
	save value: true
	card list visible: true
	card list column: 4
	card list width: 33
	card list name: ATK
	card list alignment: right
card field:
	type: text
	name: defence
	script: only_numbers(value)
	icon: stats/defence.png
	save value: true
	card list visible: true
	card list column: 5
	card list width: 33
	card list name: DEF
	card list alignment: right
############################# Copyright stuff
card field:
	type: text
	name: illustrator
	default: set.artist
	icon: stats/illustrator.png
card field:
	type: text
	name: copyright
	script: symbol_filter(value)
	default: set.copyright
	multi line: true
	show statistics: false
############################################################# Extra Statistics
statistics dimension:
	name: keywords
	position hint: 1000
	script: keyword_usage(unique:true)
	show empty: false
	split list: true
	icon: stats/keywords.png
statistics dimension:
	name: style
	position hint: 1001
	script: stylesheet.short_name
	icon: stats/stylesheet.png
statistics dimension:
	name: text length (words)
	position hint: 100
	script: word_count(to_text(card.rule_text))
	numeric: true
	bin size: 5
	icon: stats/text_length.png
############################################################## Auto replace
# Do we need categories?
#auto replace category: text box
#auto replace category: copyright
#auto replace category: everywhere
auto replace:
	match: (C)
	replace: ©
auto replace:
	match: AE
	replace: Æ
	whole word: false
auto replace:
	match: TM
	replace: ™
	whole word: false
auto replace:
	match: --
	replace: —
auto replace:
	# note the spaces
	match:
		 - 
	replace:
		 — 
auto replace:
	match: `
	replace: •
auto replace:
	match: ::
	replace: •
############################################################## Card pack items
pack item:
	name: common / uncommon
	filter: card.rarity == "common" or card.rarity == "uncommon"
pack item:
	name: rare
	filter: card.rarity == "rare"
############################################################## Card packs
pack type:
	name: booster pack
	item:
		name: rare
		amount: 1
	item:
		name: common / uncommon
		amount: 13
pack type:
	name: additional common / uncommon
	item:
		name: common / uncommon
pack type:
	name: additional rare
	item:
		name: rare
############################################################## Keywords
############################# Keyword rules

has keywords: true

keyword match script: text_filter(value)

keyword mode:
	name: real
	description: Actual keywords.
keyword mode:
	is default: true
	name: custom
	description: Custom keywords.

keyword parameter type:
	name: number
	match: [0-9XYZ?!]+
keyword parameter type:
	name: action
	match: 
		[^
		(.,]+
keyword parameter type:
	name: name
	match:
		[^
		(.,]+

############################# All VS System keywords
keyword:
	keyword: Concealed—Optional
	match: Concealed—Optional
	mode: real
	reminder: This card may come into play in the hidden area.
keyword:
	keyword: Concealed
	match: Concealed 
	mode: real
	reminder: This card comes into play in the hidden area.
keyword:
	keyword: Loyalty—Reveal
	match: Loyalty—Reveal
	mode: real
	reminder: If you don’t control a character that shares an affiliation with this character, then as an additional cost to recruit this character, reveal a character card from your hand or resource row that shares an affiliation with this character.
keyword:
	keyword: Loyalty
	match: Loyalty 
	mode: real
	reminder: Recruit this character only if you control a character that shares at least one team affiliation with this character.
keyword:
	keyword: Evasion
	match: Evasion
	mode: real
	reminder: Stun this character -> Recover this character at the start of the recovery phase this turn.
keyword:
	keyword: Invulnerability
	match: Invulnerability
	mode: real
	reminder: Whenever this character becomes stunned, you do not take stun damage. Breakthrough is applied normally.
keyword:
	keyword: Cosmic—Surge:
	match: Cosmic—Surge: <atom-param>action</atom-param>
	mode: real
	reminder: This character does not come into play with a cosmic counter. At the start of the recovery phase each turn, put a cosmic counter on this character.
keyword:
	keyword: Cosmic:
	match: Cosmic: <atom-param>action</atom-param>
	mode: real
	reminder: This character comes into play with a cosmic counter on it. While this character has a cosmic counter on it, it has this ability in addition to any other text it has.
keyword:
	keyword: Cosmic
	match: Cosmic
	mode: real
	reminder: This character comes into play with a cosmic counter on it.
keyword:
	keyword: Boost
	match: Boost <atom-param>number</atom-param>
	mode: real
	reminder: As an additional cost to play this card, you may pay its boost cost. If you pay, this card has this this this ability in addition to any other text it has this turn.
keyword:
	keyword: Willpower
	match: Willpower <atom-param>number</atom-param>
	mode: real
	reminder: This character has willpower equal to <param1>.
keyword:
	keyword: Leader:
	match: Leader: <atom-param>action</atom-param>
	mode: real
	reminder: The designated characters are affected by this text.
keyword:
	keyword: Ally:
	match: Ally: <atom-param>action</atom-param>
	mode: real
	reminder: This character's ally power is activated whenever a character becomes powered-up.
keyword:
	keyword: Unique
	match: Unique
	mode: real
	reminder: You may only have one copy of this card in play at a time.
keyword:
	keyword: Ongoing:
	match: Ongoing <atom-param>action</atom-param>
	mode: real
	reminder: As long as this card remains face-up in your resource row, this text is active.
keyword:
	keyword: Reservist
	match: Reservist
	mode: real
	reminder: You may recruit this card from your resource row. If you do, you may put a card from your hand face down into your resource row.
keyword:
	keyword: Press
	match: Press
	mode: real
	reminder: When you recruit this card, your next character costs 1 less to recruit this turn for each press card you recruited this turn, but no less than 1.
keyword:
	keyword: Terraform
	match: Terraform
	mode: real
	reminder: Reveal this card -> You may return a face-down resource you control to its owner's hand. If you do, put this card face-down into your resource row. Use this power only if this card is in your hand and only during your recruit step.
keyword:
	keyword: Transferable
	match: Transferable
	mode: real
	reminder: At the start of the formation step, you may transfer this card.
keyword:
	keyword: Vengeance:
	match: Vengeance: <atom-param>action</atom-param>
	mode: real
	reminder: This ability is activated whenever this character is stunned.
keyword:
	keyword: Backup:
	match: Backup: <atom-param>action</atom-param>
	mode: real
	reminder: This ability can only be used during the build phase.
keyword:
	keyword: Dual Loyalty
	match: Dual Loyalty
	mode: real
	reminder: Recruit this card only if both its printed affiliations are among the affiliations of characters you control.
keyword:
	keyword: Substitute
	match: Substitute
	mode: real
	reminder: Reveal this card -> You may remove from the game a ready character you control with cost greater than or equal to the cost of this card. If you do, put this card into play. Use only if this card is in your hand and only during your recruit step." 
keyword:
	keyword: Insanity:
	match: Insanity: <atom-param>action</atom-param>
	mode: real
	reminder: You may not have more than one copy of this card in your deck.
