PlayDeck Analyser v0.1
Written in JustBASIC by CirothUngol
-----------------------------------
January 21, 2012


The PlayDeck Analyser is a small app that attempts to correct
Manalink PlayDeck.dck files by comparing them to a specific
Manalink.csv. If the CardName in the PlayDeck doesn't match the
CardID# in the .csv, then the entire .csv is searched for a
matching CardName and the CardID# in the PlayDeck is corrected. If
the CardName is not found in the .csv,  then the CardName in the
PlayDeck is changed to match the CardID# in the .csv.

Besides correcting CardNames and CardID#s, it also has the capacity to:
   Identify and use both pre and post 2,000-Card-Limit Manalink.csv files
   Identify PlayDecks that violate Banned\Restricted Lists
   Identify PlayDecks that violate the Minimum Deck Size
   Swap cards into and out of PlayDecks using Card Substitution Lists
   Sort cards in PlayDecks by CardColor, CardQuantity, CardName or CardID#
   Give PlayDecks a correct, accurate and consistent Color Description
   Choose the % of Non-Land cards needed to describe a deck as "Artifact"
   Check and correct PlayDeck Headers to match DeckBuilder Format
   Separate rebuilt decks: Rebuilt, Invalid, FixDescription and FixDeck

The program always operates on copies of the source files, and therefore
will automatically import both PlayDeck.dck files and the Manalink.csv.
Please use the import function when loading new files, as this allows
the program an attempt to verify the proper format of these files, which
helps to assure more accurate output and prevents the program from
choking on improperly formatted data.

A logfile is created that details all of the corrections\substitutions
made as well as any matches found in the Banned\Restricted lists.
The logfile will be named Date-Time, and will be located in the
".\PlayDeckAnalyser\" directory after the scan completes. Since all
matches are made using the Full CardName even the tiniest of misspellings
will cause the match to fail. Be sure and check the LogFile after
all corrections have been made.


MAKE A DECK LIST:
-----------------
DeckLists must be created using the same version of Manalink
associated with the CSV file used for scanning the PlayDecks.

To create Banned\Restricted lists, simply make a PlayDeck in Manalink's
DeckBuilder containing all of the cards you'd like to search for. Any
amount of Basic Lands may be added so that DeckBuilder will allow you to
save the PlayDeck, as Basic Lands are ignored in the B\R lists. Then name
the PlayDeck so that the first 6 or 10 characters in the filename are
"Banned" or "Restricted", and then place them in the ".\Lists\"
folder before you run the Analyser. "Restricted" lists will alert
if more than one copy is in the PlayDeck (and tell you how many).
"Banned" lists will alert if the card is present at all in the PlayDeck.

Substitute card lists are similar. Use the DeckBuilder and make a PlayDeck
containing the cards you'd like to substitute into your decks and the
quantity you'd like to trade in (up to 4), then name it so the first
10 characters of the name are "Substitute". Then, open the PlayDeck with
a texteditor and change the CardNames to the cards you'd like to trade
out and remove any that you don't (Basic Lands are NOT ignored). The
Analyser will swap-out cards in the PlayDecks up-to the quantity in the
Substitute list, making sure that no more than 4 copies are in the
PlayDeck (except for Basic Lands).

You can make as many of these lists as you like, they will all be
searched simultaneously. The current Banned-Legacy, Banned-Vintage
and Restricted-Vintage lists are available in the ".\Lists\" directory,
along with a few example Substitute lists. Example1 removes Moxes and
replaces with Basic Land (up to 4), Example2 will then remove 1 of each
Basic Land and replace with an appropriate-colored Mox.


HOW TO USE:
-----------

Step 1: Select the Manalink.csv File
If the file is selected from anywhere other than ".\PlayDeckAnalyser\CSV\"
then the program will request a unique filename for the .csv. This
allows keeping multiple copies of the .csv in the default directory (I
would recommend using the date for the update... e.g. 20120101).
After selecting, the .csv file will be checked, verified and backed-up
into the default directory.

Step 2: Select the PlayDeck Directory
Navigate to the PlayDeck folder you'd like to import and select a .dck
file. If the file is selected from anywhere other than
".\PlayDeckAnalyser\PlayDeck\" then all PlayDeck.dck files in the chosen
directory will be checked, verified and backed-up to the default directory
before the examination process begins.

Step 3: Check settings and Rebuild
Make any additional settings you'd like to use and hit "Rebuild PlayDecks".
The program will now begin examining and correcting the PlayDeck.dck files.

...and that's it! As long as the cards in the PlayDecks are available
in the Manalink update in question, this program should be able to
translate any PlayDecks created with any version of Manalink to compatible
PlayDecks for any other version of Manalink. I hope. ^_^


PLAYDECK FORMAT
---------------
This program will reject as "Invalid" any PlayDecks that do not strictly
adhere to the format produced by Manalink's DeckBuilder. Here is an
example of a valid PlayDeck:

;White Death
;White
;CirothUngol
;nunya@yomama.com
;February 12, 2007
;1
;4th Edition
;

.64	2	Disenchant
.616	4	Divine Transformation
.417	4	Eye for an Eye
.161	2	Mesa Pegasus
.862	4	Rainbow Knights
.213	4	Savannah Lions
.221	4	Serra Angel
.240	4	Swords to Plowshares
.816	4	Thunder Spirit
.283	4	White Knight
.17	1	Black Lotus
.167	1	Mox Pearl
.188	22	Plains

...and a more precise definition of the 8-line header:

;Header Item               |MaxCharacters - Description
--------------------------------------------------------------------------------
;Name of PlayDeck          |28 - Required - Must be equal to FileName
;PlayDeck Description      |18 - Optional - Description seen in Gauntlet\Duel
;Player's Name             |78 - Optional - Name of Player creating the Deck
;Player's email address    |78 - Optional
;Date of PlayDeck Creation |19 - Optional
;PlayFace Value            | 2 - Required - Integer > 0 and < 56 (1-55)
;MtG Edition               |11 - Required - Must be equal to "4th Edition"
;PlayDeck Comments         |398- Optional - Comments seen on Deck Info screen
                           | 0 - Blank Line separating Header from Contents
--------------------------------------------------------------------------------
The PlayFace Value was used in Microprose's MtG ver1.0 to directly associate
PlayDecks with 1 of 55 different villains, whose face would show whenever
the PlayDeck was used in Gauntlet\Duel.

The Header is followed directly by the Contents of the PlayDeck
listed one card per line in the following format:

.CardID# <TAB> CardQty <TAB> Full CardName

Header items are prefaced with a semi-colon (;) and Content items are
prefaced with a period (.). The blank line separating the two is required.
Although Manalink will allow slight deviations from this format and still
have the PlayDeck be playable, if you load said PlayDeck into DeckBuilder
and re-save, this is the format it creates, so PlayDeck Analyser will attempt
to correct imported decks into this format. If it can't it will copy the
PlayDeck into the ".\Invalid\" folder for you to review.
