Updated extract_in_wiki_format.pl. Now the name of the cars are used for output.

This commit is contained in:
North 2011-08-30 18:10:44 +03:00
parent 9929470807
commit e02b6980c7
3 changed files with 73 additions and 41 deletions

View file

@ -2,22 +2,47 @@
use strict; use strict;
my $dataFile = 'mtg-cards-data.txt';
my $setsFile = 'mtg-sets-data.txt';
my $knownSetsFile = 'known-sets.txt'; my $knownSetsFile = 'known-sets.txt';
my $cards_count = 0; my $cards_count = 0;
my %knownSets; my %knownSets;
my %sets;
my %cardsBySet;
my %cards; 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 = <DATA>) {
my @data = split('\\|', $line);
$cardsBySet{$data[1]}{toCamelCase($data[0])} = \@data;
}
close(DATA);
open (DATA, $setsFile) || die "can't open $setsFile";
while(my $line = <DATA>) {
my @data = split('\\|', $line);
$sets{$data[0]}= $data[1];
}
close(DATA);
open (DATA, $knownSetsFile) || die "can't open $knownSetsFile"; open (DATA, $knownSetsFile) || die "can't open $knownSetsFile";
while(my $line = <DATA>) { while(my $line = <DATA>) {
my @data = split('\\|', $line); my @data = split('\\|', $line);
$knownSets{$data[1]}= $data[2]; $knownSets{$data[1]}= $data[0];
} }
close(DATA); close(DATA);
open CARDS, "< added_cards.txt" or die;
open CARDS, "< added_cards.txt" or die;
while (<CARDS>) { while (<CARDS>) {
my $line = $_; my $line = $_;
if ( $line =~/A Mage.Sets\\src\\mage\\sets\\(\w.*)\\(\w.*)\.java/ ) { if ( $line =~/A Mage.Sets\\src\\mage\\sets\\(\w.*)\\(\w.*)\.java/ ) {
@ -28,7 +53,7 @@ while (<CARDS>) {
$cards{$set} = []; $cards{$set} = [];
} }
push $cards{$set}, $card; push @{$cards{$set}}, $card;
} }
} }
@ -37,18 +62,25 @@ print REPORT " * Added cards ($cards_count):\n";
foreach my $set (keys(%cards)) { foreach my $set (keys(%cards)) {
if ($set ne "tokens") { if ($set ne "tokens") {
if (exists $knownSets{$set}) { if (exists $knownSets{$set}) {
print REPORT " * $knownSets{$set}: "; print REPORT " * $sets{$knownSets{$set}}: ";
} else { } else {
print REPORT " $set: "; print REPORT " $set: ";
} }
my $first = 1; my $first = 1;
foreach my $card (@{$cards{$set}}) { foreach my $card (@{$cards{$set}}) {
if ($first == 0) { print REPORT ","; } if ($first == 0) {
$card =~ s/([A-Z]{1}[a-z]+)/ $1/g; print REPORT "; ";
$card =~ s/A Ether/ AEther/g; } else {
print REPORT $card;
$first = 0; $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"; print REPORT "\n";
} }
} }

View file

@ -1,32 +1,31 @@
Tenth Edition|tenth|10E| Tenth Edition|tenth|
Magic 2010|magic2010|M10| Magic 2010|magic2010|
Magic 2011|magic2011|M11| Magic 2011|magic2011|
Magic 2012|magic2012|M12| Magic 2012|magic2012|
Planechase|planechase|HOP| Planechase|planechase|
Duel Decks: Elspeth vs. Tezzeret|elspethvstezzeret|DDF| Duel Decks: Elspeth vs. Tezzeret|elspethvstezzeret|
Tempest|tempest|TMP| Tempest|tempest|
Invasion|invasion|INV| Invasion|invasion|
Planeshift|planeshift|PLS| Planeshift|planeshift|
Apocalypse|apocalypse|APC| Apocalypse|apocalypse|
Mirrodin|mirrodin|MRD| Mirrodin|mirrodin|
Darksteel|darksteel|DST| Darksteel|darksteel|
Fifth Dawn|fifthdawn|5DN| Fifth Dawn|fifthdawn|
Champions of Kamigawa|championsofkamigawa|CHK| Champions of Kamigawa|championsofkamigawa|
Ravnica: City of Guilds|ravnika|RAV| Ravnica: City of Guilds|ravnika|
Guildpact|guildpact|GPT| Guildpact|guildpact|
Dissension|dissension|DIS| Dissension|dissension|
Lorwyn|lorwyn|LRW| Lorwyn|lorwyn|
Morningtide|morningtide|MOR| Morningtide|morningtide|
Shadowmoor|shadowmoor|SHM| Shadowmoor|shadowmoor|
Eventide|eventide|EVE| Eventide|eventide|
Shards of Alara|shardsofalara|ALA| Shards of Alara|shardsofalara|
Conflux|conflux|CON| Conflux|conflux|
Alara Reborn|alarareborn|ARB| Alara Reborn|alarareborn|
Zendikar|zendikar|ZEN| Zendikar|zendikar|
Worldwake|worldwake|WWK| Worldwake|worldwake|
Rise of the Eldrazi|riseoftheeldrazi|ROE| Rise of the Eldrazi|riseoftheeldrazi|
Scars of Mirrodin|scarsofmirrodin|SOM| Scars of Mirrodin|scarsofmirrodin|
Mirrodin Besieged|mirrodinbesieged|MBS| Mirrodin Besieged|mirrodinbesieged|
New Phyrexia|newphyrexia|NPH| New Phyrexia|newphyrexia|
Innistrad|innistrad|ISD| Innistrad|innistrad|
Dark Ascension|darkascension|DKA|

View file

@ -39,6 +39,7 @@ Guildpact|GPT|
Homelands|HML| Homelands|HML|
Planechase|HOP| Planechase|HOP|
Ice Age|ICE| Ice Age|ICE|
Innistrad|ISD|
Invasion|INV| Invasion|INV|
Judgment|JUD| Judgment|JUD|
Limited Edition Alpha|LEA| Limited Edition Alpha|LEA|