mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
Added new script (generates a list of implemented cards)
Added readme.txt for the util files Added required files to ignore list
This commit is contained in:
parent
929d982e38
commit
f399db14a9
3 changed files with 88 additions and 0 deletions
|
@ -27,6 +27,8 @@ Mage/target
|
|||
|
||||
releases
|
||||
Utils/author.txt
|
||||
Utils/newList.txt
|
||||
Utils/oldList.txt
|
||||
syntax: regexp
|
||||
.class
|
||||
.jar
|
||||
|
|
15
Utils/readme.txt
Normal file
15
Utils/readme.txt
Normal file
|
@ -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
|
71
Utils/update-list-implemented-cards.pl
Normal file
71
Utils/update-list-implemented-cards.pl
Normal file
|
@ -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 = <DATA>) {
|
||||
my @data = split('\\|', $line);
|
||||
$cardsBySet{$data[1]}{$data[0]} = \@data;
|
||||
}
|
||||
close(DATA);
|
||||
|
||||
|
||||
open (DATA, $knownSetsFile) || die "can't open $knownSetsFile";
|
||||
while(my $line = <DATA>) {
|
||||
my @data = split('\\|', $line);
|
||||
$knownSets{$data[0]}= $data[1];
|
||||
}
|
||||
close(DATA);
|
||||
|
||||
|
||||
open (DATA, $oldListFile) || die "can't open $oldListFile";
|
||||
while(my $line = <DATA>) {
|
||||
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);
|
Loading…
Reference in a new issue