From e02b6980c76cf7efc1de3ee5cd07b8e8559a018d Mon Sep 17 00:00:00 2001 From: North Date: Tue, 30 Aug 2011 18:10:44 +0300 Subject: [PATCH] Updated extract_in_wiki_format.pl. Now the name of the cars are used for output. --- Utils/extract_in_wiki_format.pl | 50 +++++++++++++++++++++----- Utils/known-sets.txt | 63 ++++++++++++++++----------------- Utils/mtg-sets-data.txt | 1 + 3 files changed, 73 insertions(+), 41 deletions(-) diff --git a/Utils/extract_in_wiki_format.pl b/Utils/extract_in_wiki_format.pl index 925adb15f6..af796182ac 100644 --- a/Utils/extract_in_wiki_format.pl +++ b/Utils/extract_in_wiki_format.pl @@ -2,22 +2,47 @@ use strict; +my $dataFile = 'mtg-cards-data.txt'; +my $setsFile = 'mtg-sets-data.txt'; my $knownSetsFile = 'known-sets.txt'; my $cards_count = 0; my %knownSets; +my %sets; +my %cardsBySet; my %cards; +sub toCamelCase { + my $string = $_[0]; + $string =~ s/\b([\w']+)\b/ucfirst($1)/ge; + $string =~ s/[-,\s\']//g; + $string; +} + +open (DATA, $dataFile) || die "can't open $dataFile"; +while(my $line = ) { + my @data = split('\\|', $line); + $cardsBySet{$data[1]}{toCamelCase($data[0])} = \@data; +} +close(DATA); + +open (DATA, $setsFile) || die "can't open $setsFile"; +while(my $line = ) { + my @data = split('\\|', $line); + $sets{$data[0]}= $data[1]; +} +close(DATA); + open (DATA, $knownSetsFile) || die "can't open $knownSetsFile"; while(my $line = ) { my @data = split('\\|', $line); - $knownSets{$data[1]}= $data[2]; + $knownSets{$data[1]}= $data[0]; } close(DATA); -open CARDS, "< added_cards.txt" or die; +open CARDS, "< added_cards.txt" or die; while () { my $line = $_; if ( $line =~/A Mage.Sets\\src\\mage\\sets\\(\w.*)\\(\w.*)\.java/ ) { @@ -28,7 +53,7 @@ while () { $cards{$set} = []; } - push $cards{$set}, $card; + push @{$cards{$set}}, $card; } } @@ -37,17 +62,24 @@ print REPORT " * Added cards ($cards_count):\n"; foreach my $set (keys(%cards)) { if ($set ne "tokens") { if (exists $knownSets{$set}) { - print REPORT " * $knownSets{$set}: "; + print REPORT " * $sets{$knownSets{$set}}: "; } else { print REPORT " $set: "; } my $first = 1; foreach my $card (@{$cards{$set}}) { - if ($first == 0) { print REPORT ","; } - $card =~ s/([A-Z]{1}[a-z]+)/ $1/g; - $card =~ s/A Ether/ AEther/g; - print REPORT $card; - $first = 0; + if ($first == 0) { + print REPORT "; "; + } else { + $first = 0; + } + if ($cardsBySet{$knownSets{$set}}{$card}) { + print REPORT $cardsBySet{$knownSets{$set}}{$card}[0]; + } else { + #$card =~ s/([A-Z]{1}[a-z]+)/ $1/g; + #$card =~ s/A Ether/ AEther/g; + print "not processed: $sets{$knownSets{$set}} $card\n"; + } } print REPORT "\n"; } diff --git a/Utils/known-sets.txt b/Utils/known-sets.txt index 125ba6cd0f..507e7667a0 100644 --- a/Utils/known-sets.txt +++ b/Utils/known-sets.txt @@ -1,32 +1,31 @@ -Tenth Edition|tenth|10E| -Magic 2010|magic2010|M10| -Magic 2011|magic2011|M11| -Magic 2012|magic2012|M12| -Planechase|planechase|HOP| -Duel Decks: Elspeth vs. Tezzeret|elspethvstezzeret|DDF| -Tempest|tempest|TMP| -Invasion|invasion|INV| -Planeshift|planeshift|PLS| -Apocalypse|apocalypse|APC| -Mirrodin|mirrodin|MRD| -Darksteel|darksteel|DST| -Fifth Dawn|fifthdawn|5DN| -Champions of Kamigawa|championsofkamigawa|CHK| -Ravnica: City of Guilds|ravnika|RAV| -Guildpact|guildpact|GPT| -Dissension|dissension|DIS| -Lorwyn|lorwyn|LRW| -Morningtide|morningtide|MOR| -Shadowmoor|shadowmoor|SHM| -Eventide|eventide|EVE| -Shards of Alara|shardsofalara|ALA| -Conflux|conflux|CON| -Alara Reborn|alarareborn|ARB| -Zendikar|zendikar|ZEN| -Worldwake|worldwake|WWK| -Rise of the Eldrazi|riseoftheeldrazi|ROE| -Scars of Mirrodin|scarsofmirrodin|SOM| -Mirrodin Besieged|mirrodinbesieged|MBS| -New Phyrexia|newphyrexia|NPH| -Innistrad|innistrad|ISD| -Dark Ascension|darkascension|DKA| \ No newline at end of file +Tenth Edition|tenth| +Magic 2010|magic2010| +Magic 2011|magic2011| +Magic 2012|magic2012| +Planechase|planechase| +Duel Decks: Elspeth vs. Tezzeret|elspethvstezzeret| +Tempest|tempest| +Invasion|invasion| +Planeshift|planeshift| +Apocalypse|apocalypse| +Mirrodin|mirrodin| +Darksteel|darksteel| +Fifth Dawn|fifthdawn| +Champions of Kamigawa|championsofkamigawa| +Ravnica: City of Guilds|ravnika| +Guildpact|guildpact| +Dissension|dissension| +Lorwyn|lorwyn| +Morningtide|morningtide| +Shadowmoor|shadowmoor| +Eventide|eventide| +Shards of Alara|shardsofalara| +Conflux|conflux| +Alara Reborn|alarareborn| +Zendikar|zendikar| +Worldwake|worldwake| +Rise of the Eldrazi|riseoftheeldrazi| +Scars of Mirrodin|scarsofmirrodin| +Mirrodin Besieged|mirrodinbesieged| +New Phyrexia|newphyrexia| +Innistrad|innistrad| \ No newline at end of file diff --git a/Utils/mtg-sets-data.txt b/Utils/mtg-sets-data.txt index cef3b3a5f6..6f78d1fb61 100644 --- a/Utils/mtg-sets-data.txt +++ b/Utils/mtg-sets-data.txt @@ -39,6 +39,7 @@ Guildpact|GPT| Homelands|HML| Planechase|HOP| Ice Age|ICE| +Innistrad|ISD| Invasion|INV| Judgment|JUD| Limited Edition Alpha|LEA|