From acd0b2e5eadb7f6c7552fa828663c88490057cba Mon Sep 17 00:00:00 2001 From: Quercitron Date: Thu, 5 Dec 2013 22:53:35 +0400 Subject: [PATCH] Add script that generates list of unimplemented cards for a set --- Utils/gen-list-unimplemented-cards-for-set.pl | 77 +++++++++++++++++++ Utils/readme.txt | 3 +- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 Utils/gen-list-unimplemented-cards-for-set.pl diff --git a/Utils/gen-list-unimplemented-cards-for-set.pl b/Utils/gen-list-unimplemented-cards-for-set.pl new file mode 100644 index 00000000000..2e1a6061ec7 --- /dev/null +++ b/Utils/gen-list-unimplemented-cards-for-set.pl @@ -0,0 +1,77 @@ +#!/usr/bin/perl -w + +#author: North + +use strict; + + +my $dataFile = "mtg-cards-data.txt"; +my $setsFile = "mtg-sets-data.txt"; +my $knownSetsFile = "known-sets.txt"; + +my %sets; +my %knownSets; + +my @setCards; + +# gets the set name +my $setName = $ARGV[0]; +if(!$setName) { + print 'Enter a set name: '; + $setName = ; + chomp $setName; +} + + +open (DATA, $dataFile) || die "can't open $dataFile"; +while(my $line = ) { + my @data = split('\\|', $line); + if ($data[1] eq $setName) { + push(@setCards, \@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, $setsFile) || die "can't open $setsFile"; +while(my $line = ) { + my @data = split('\\|', $line); + $sets{$data[0]}= $data[1]; +} +close(DATA); + + +sub cardSort { + if (@{$a}[2] < @{$b}[2]) { return -1; } + elsif (@{$a}[2] == @{$b}[2]) { return 0;} + elsif (@{$a}[2] > @{$b}[2]) { return 1; } +} + +sub toCamelCase { + my $string = $_[0]; + $string =~ s/\b([\w']+)\b/ucfirst($1)/ge; + $string =~ s/[-,\s\']//g; + $string; +} + +my $toPrint = ''; +foreach my $card (sort cardSort @setCards) { + my $className = toCamelCase(@{$card}[0]); + my $currentFileName = "../Mage.Sets/src/mage/sets/" . $knownSets{$setName} . "/" . $className . ".java"; + if(! -e $currentFileName) { + if ($toPrint) { + $toPrint .= "\n"; + } + $toPrint .= "@{$card}[2]|@{$card}[0]"; + } +} +open CARD, "> " . lc($sets{$setName}) . ".txt"; +print CARD $toPrint; +close CARD; + diff --git a/Utils/readme.txt b/Utils/readme.txt index 2e1bd414270..5ffc9f7b2eb 100644 --- a/Utils/readme.txt +++ b/Utils/readme.txt @@ -6,7 +6,8 @@ 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 -gen-list-cards-for-set.pl - generates the file for unimplemented cards for a set +gen-list-cards-for-set.pl - generates the file for cards for a set +gen-list-unimplemented-cards-for-set.pl - generates the file for unimplemented cards for a set Files used: - author.txt - one line file that contains the author name you want to appear in the generated java files