﻿mse version: 0.3.4
short name: Yu-Gi-Oh!
icon: card-back.png
position hint: 4

############################################################## Functions & filters
## Copied and Pasted from vs.mse-game, with a few modifications
# General functions
init script:
	# the rule text filter
	#  - adds continuous symbols
	#  - adds counter symbols
	#  - adds equipment symbols
	#  - adds field symbols
	#  - adds quickplay symbols
	#  - adds ritual symbols
	#  - adds level symbols
	#  - adds infinity symbols
	#  - makes text in parentheses italic
	text_filter := 
		# step 1 : remove all automatic tags
		tag_remove_rule(tag: "<sym-auto>") +
		# step 2 : expand shortcut words ~ and CARDNAME
		replace_rule(
			match: "~|~THIS~|CARDNAME",
			in_context: "(^|[[:space:]]|\\()<match>", # TODO: Allow any punctuation before
			replace: "<atom-cardname></atom-cardname>"
			) +
		# step 3 : fill in the cardname atom field
		tag_contents_rule(
			tag: "<atom-cardname>",
			contents: { if card.name=="" then "CARDNAME" else card.name }
			) +
		# step 4 : symbols
		replace_rule(
			match: "[|@|::|]",
			replace: "<sym-auto>&</sym-auto>" );
	level_filter := 
		# step 1 : remove all automatic tags
		tag_remove_rule(tag: "<sym-auto>") +
		# step 2 : symbols
		replace_rule(
			match: "[|%|!|+|&|$|#|*|]",
			replace: "<sym-auto>&</sym-auto>" );
	a_and_d_filter := 
		# step 1 : remove all automatic tags
		tag_remove_rule(tag: "<sym-auto>") +
		# step 2 : symbols
		replace_rule(
			match: "@",
			replace: "<sym-auto>&</sym-auto>" );
	copyright_filter :=
		# step 1 : trademark symbol
		replace_rule(
			match: "TM",
			replace: "™") +
		# step 2 : copyright symbol
		replace_rule(
			match: "CR|\\(C\\)",
			replace: "©")
	
	# the flavor text filter
	flavor_text_filter :=
		# step 1 : remove italic tags
		tag_remove_rule(tag: "<i-flavor>") +
		# step 2 : surround by <i> tags
		{ "<i-flavor>" + input + "</i-flavor>" };
	
	# Determine type of card
	card_type := {
		if	card.type2	== "Effect<sym>]</sym>"				then "effect monster"
		else if card.type2	== "Fusion<sym>]</sym>"				then "fusion monster"
		else if card.type2	== "Fusion / Effect<sym>]</sym>"		then "fusion monster"
		else if card.type2	== "Fusion/Effect<sym>]</sym>"			then "fusion monster"
		else if card.type2	== "Ritual<sym>]</sym>"				then "ritual monster"
		else if card.type2	== "Ritual / Effect<sym>]</sym>"		then "ritual monster"
		else if card.type2	== "Ritual/Effect<sym>]</sym>"			then "ritual monster"
		else if card.type1	== "<sym>[</sym>Legendary Dragon"		then "legendary dragon"
		else if card.type1	== "<sym>[</sym>Divine-Beast"			then "obelisk"
		else if card.attribute	== "spell"					then "spell card"
		else if card.level	== "<sym>[</sym>Spell Card<sym>]</sym>"		then "spell card"
		else if card.level	== "<sym>[</sym>Spell Card%<sym>]</sym>"	then "spell card"
		else if card.level	== "<sym>[</sym>Spell Card!<sym>]</sym>"	then "spell card"
		else if card.level	== "<sym>[</sym>Spell Card+<sym>]</sym>"	then "spell card"
		else if card.level	== "<sym>[</sym>Spell Card&<sym>]</sym>"	then "spell card"
		else if card.level	== "<sym>[</sym>Spell Card$<sym>]</sym>"	then "spell card"
		else if card.level	== "<sym>[</sym>Spell Card#<sym>]</sym>"	then "spell card"
		else if card.attribute	== "trap"					then "trap card"
		else if card.level	== "<sym>[</sym>Trap Card<sym>]</sym>"		then "trap card"
		else if card.level	== "<sym>[</sym>Trap Card%<sym>]</sym>"		then "trap card"
		else if card.level	== "<sym>[</sym>Trap Card!<sym>]</sym>"		then "trap card"
		else if card.level	== "<sym>[</sym>Trap Card+<sym>]</sym>"		then "trap card"
		else if card.level	== "<sym>[</sym>Trap Card&<sym>]</sym>"		then "trap card"
		else if card.level	== "<sym>[</sym>Trap Card$<sym>]</sym>"		then "trap card"
		else if card.level	== "<sym>[</sym>Trap Card#<sym>]</sym>"		then "trap card"
		else                                          				     "normal monster"
	}
	# Default 'attribute' of card
	attribute := {
		if      is_spell_card() then "Spell"
		else if is_trap_card()  then "Trap"
		else                         "none"
	}
	
	############### Type of card
	
	is_nmonster := {
		card.card_type == "spell card" or
	        card.card_type == "trap card"
	}
	is_monster := {
		card.card_type == "normal monster" or
	        card.card_type == "effect monster" or
	        card.card_type == "ritual monster" or
	        card.card_type == "fusion monster" or
		card.card_type == "obelisk"        or
		card.card_type == "slifer"	   or
		card.card_type == "ra"		   or
		card.card_type == "legendary dragons"
	}
	is_normal_monster := {
		card.card_type == "normal monster" or
		card.card_type == "obelisk"        or
		card.card_type == "slifer"	   or
		card.card_type == "ra"		   or
		card.card_type == "legendary dragons"
	}
	is_spell_card := {
		card.card_type == "spell card"	or
		card.attribute == "spell"	or
		card.level     == "Spell"
	}
	is_trap_card := {
	        card.card_type == "trap card"	or
		card.attribute == "trap"	or
		card.level     == "Trap"
	}
	############### Determine Card Position
	pos_of_card := {
		position(
			of: card
			in: set
			order_by: {
				card.card_type + card.attribute + card.monster_type + card.name
			}) + 1
	}

############################################################## Set fields

set field:
	type: info
	name: Set Information
set field:
	type: text
	name: title
	description: This information will not appear on the card.
set field:
	type: text
	name: code
	description: Recommended only 3 Capital digits. Will appear before card number. ex: LOB-XX101
set field:
	type: text
	name: language
	description: Recommended 2 - 3 Captital digits. Will appear before the card number, after the code. ex: XXX-EN101
set field:
	type: text
	name: description
	multi line: true
	description: This information will not appear on the card.
set field:
	type: text
	name: edition
	description: Editting this will set 1 edition for all the cards and will appear in the edition bar below the picture. ex-> LIMITED EDITION
set field:
	type: text
	name: copyright
	description: Copyright information. This will not appear on the card.


############################# Default style

default set style:
	title:
		padding left: 2
		font:
			size: 16

############################################################## Card fields

############################# Background stuff
card field:
	type: choice
	name: card type
	choice: normal monster
	choice: effect monster
	choice: ritual monster
	choice: fusion monster
	choice: obelisk
	choice: slifer
	choice: ra
	choice: legendary dragons
	choice: spell card
	choice: trap card
	default: card_type()
	choice colors cardlist:
		normal monster:	   rgb(120,18,0)
		effect monster:	   rgb(120,18,0)
		ritual monster:	   rgb(26,26,26)
		fusion monster:	   rgb(26,26,26)
		obelisk:	   rgb(26,26,26)
		slifer:		   rgb(26,26,26)
		ra:		   rgb(26,26,26)
		legendary dragons: rgb(26,26,26)
		spell card:	   rgb(80,80,80)
		trap card:	   rgb(30,110,0)
card field:
	type: choice
	name: foils
	editable: false
	choice: none
	choice: holo image
	choice: secret holo image
	choice: parallel holo card

############################# Name line
card field:
	type: text
	name: name
	identifying: true
	show statistics: false
	card list visible: true
	card list column: 1
card field:
	type: choice
	name: attribute
	choice: none
	choice: earth
	choice: water
	choice: fire
	choice: wind
	choice: light
	choice: dark
	choice: divine
	choice: spell
	choice: trap
	default: attribute()
	card list visible: true
	card list column: 2
card field:
	type: text
	name: level
	description: `=] * = star, % = continuous, ! = counter, + = equipment, & = field, $ = quickplay, # = ritual
	script: level_filter(value)

############################# Image
card field:
	type: image
	name: image
	show statistics: false

############################# Card type
card field:
	type: text
	name: type1
	script: a_and_d_filter(value)
	default: "<sym>[</sym>"
	editable: false
card field:
	type: text
	name: type2
	script: a_and_d_filter(value)
	default: "<sym>]</sym>"
	editable: false
card field:
	type: text
	name: monster type
	script:
		# Either just monster, monster / type1
		combined_editor(
			field1: card.type1,
			separator: " / ",
			field2: card.type2,
			soft_before_empty: true,
			hide_when_empty:   true,
			type_over1: " /",
			type_over2: "/"
		)
	card list visible: true
	card list column: 3

############################# Edition and Card ID
card field:
	type: text
	name: number
	script:
		set.code
		+ "-" +
		set.language +
		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: #
	editable: false
	show statistics: false
card field:
	type: text
	name: edition
	default: set.edition
	show statistics: false

############################# Text box
card field:
	type: text
	name: rules
	script: text_filter(value)
	editable: false
	show statistics: false
card field:
	type: text
	name: flavor
	script: flavor_text_filter(value)
	editable: false
	show statistics: false
card field:
	type: text
	name: rule text
	multi line: true
	save value: false
	show statistics: false
	script:
		if is_normal_monster(value) then
			combined_editor(field1: card.rules, separator: "<line>\n</>", field2: card.flavor)
		else 
			forward_editor(field: card.rules)

############################# Attack/Defense
card field:
	type: text
	name: attack
	save value: true
	script: a_and_d_filter(value)
	card list visible: true
	card list column: 4
	card list width: 33
	card list name: ATK
card field:
	type: text
	name: defense
	save value: true
	script: a_and_d_filter(value)
	card list visible: true
	card list column: 5
	card list width: 33
	card list name: DEF

############################# Copyright stuff
card field:
	type: text
	name: gamecode
	show statistics: false
card field:
	type: text
	name: copyright
	default: set.copyright
	script: copyright_filter(value)
	show statistics: false


############################################################## Word lists
# Doesn't do anything yet

#word list:
#	name: type
#	word: Dragon
#	word: Spellcaster
#	word: Zombie
#	word: Warrior
#	word: Beast-Warrior
#	word: Beast
#	word: Winged Beast
#	word: Fiend
#	word: Fiary
#	word: Insect
#	word: Dinosaur
#	word: Reptile
#	word: Fish
#	word: Sea Serpent
#	word: Machine
#	word: Thunder
#	word: Aqua
#	word: Pyro
#	word: Rock
#	word: Plant
#	word: Divine-Beast
#	word: Toon
#	word: Spirit
#	word: Union
#	word: Effect
#	word: Fusion
#	word: Ritual
#	word: Divine

