diff --git a/.hgignore b/.hgignore index bc5647318b..c88b84caec 100644 --- a/.hgignore +++ b/.hgignore @@ -27,6 +27,8 @@ Mage/target releases Utils/author.txt +Utils/newList.txt +Utils/oldList.txt syntax: regexp .class .jar diff --git a/Utils/readme.txt b/Utils/readme.txt new file mode 100644 index 0000000000..dfaec661ad --- /dev/null +++ b/Utils/readme.txt @@ -0,0 +1,15 @@ +Usage: +gen-card.pl - enter the card name when prompted to generate the java classes +gen-existing-cards-by-set.pl - generates the java clases for the cards from the set of your choice that already have an implementation +gen-simple-cards-by-set.pl - generates the java clases for the cards from the set of your choice that can be completly generated +update-list-implemented-cards.pl + - generates + - oldList.txt: list of cards implemented at the time the script is ran + - newList.txt: list of cards implemented since the last time the script was ran + +Files used: + - author.txt - one line file that contains the author name you want to appear in the generated java files + - keywords.txt - list of keywords that have an implementaion and are automatically added to the card implementation + - known-sets.txt - list of sets used in mage (Set name and Package name) + - mtg-cards-data.txt - MTG cards data (generated from the Gatherer database) + - mtg-sets-data.txt - list of sets in MTG and the 3 letters code for each of them \ No newline at end of file diff --git a/Utils/update-list-implemented-cards.pl b/Utils/update-list-implemented-cards.pl new file mode 100644 index 0000000000..5432e23ed7 --- /dev/null +++ b/Utils/update-list-implemented-cards.pl @@ -0,0 +1,71 @@ +#!/usr/bin/perl -w + +#author: North + +use strict; + +my $dataFile = "mtg-cards-data.txt"; +my $knownSetsFile = "known-sets.txt"; +my $oldListFile = "oldList.txt"; +my $newListFile = "newList.txt"; + + +my %cardsBySet; +my %knownSets; +my %oldList; + + +sub getClassName { + 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]}{$data[0]} = \@data; +} +close(DATA); + + +open (DATA, $knownSetsFile) || die "can't open $knownSetsFile"; +while(my $line = ) { + my @data = split('\\|', $line); + $knownSets{$data[0]}= $data[1]; +} +close(DATA); + + +open (DATA, $oldListFile) || die "can't open $oldListFile"; +while(my $line = ) { + chomp $line; + $oldList{$line} = 1; +} +close(DATA); + + +# Logic starts here + +my %implementedCards; + +foreach my $setName (keys %knownSets) { + foreach my $keyCard (keys %{$cardsBySet{$setName}}) { + my $fileName = "../Mage.Sets/src/mage/sets/" . $knownSets{$setName} . "/" . getClassName($keyCard) . ".java"; + if(-e $fileName) { + $implementedCards{$keyCard} = 1; + } + } +} + +open (OLD, "> $oldListFile"); +open (NEW, "> newList.txt"); +foreach my $cardName (sort (keys %implementedCards)) { + print OLD $cardName . "\n"; + if (!exists $oldList{$cardName}) { + print NEW $cardName . "\n"; + } +} +close (OLD); +close (NEW); \ No newline at end of file