forked from External/mage
update gen-list-unimplemented-cards-for-set to match current GitHub template
This commit is contained in:
parent
55ded952bc
commit
d59136cc33
2 changed files with 96 additions and 51 deletions
|
|
@ -1,13 +1,14 @@
|
||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
#author: North
|
#author: North
|
||||||
|
use Text::Template;
|
||||||
use strict;
|
use strict;
|
||||||
use Scalar::Util qw(looks_like_number);
|
use Scalar::Util qw(looks_like_number);
|
||||||
|
|
||||||
my $dataFile = "mtg-cards-data.txt";
|
my $dataFile = "mtg-cards-data.txt";
|
||||||
my $setsFile = "mtg-sets-data.txt";
|
my $setsFile = "mtg-sets-data.txt";
|
||||||
my $knownSetsFile = "known-sets.txt";
|
my $knownSetsFile = "known-sets.txt";
|
||||||
|
my $templateFile = "issue_tracker.tmpl";
|
||||||
|
|
||||||
my %sets;
|
my %sets;
|
||||||
my %knownSets;
|
my %knownSets;
|
||||||
|
|
@ -16,12 +17,13 @@ my @setCards;
|
||||||
|
|
||||||
open (DATA, $knownSetsFile) || die "can't open $knownSetsFile";
|
open (DATA, $knownSetsFile) || die "can't open $knownSetsFile";
|
||||||
while(my $line = <DATA>) {
|
while(my $line = <DATA>) {
|
||||||
|
chomp $line;
|
||||||
my @data = split('\\|', $line);
|
my @data = split('\\|', $line);
|
||||||
$knownSets{$data[0]} = $data[1];
|
$knownSets{$data[0]} = $data[1];
|
||||||
#print ("$data[0] ===> $data[1]\n");
|
|
||||||
}
|
}
|
||||||
close(DATA);
|
close(DATA);
|
||||||
|
|
||||||
|
my @basicLands = ("Plains", "Island", "Swamp", "Mountain", "Forest");
|
||||||
|
|
||||||
# gets the set name
|
# gets the set name
|
||||||
my $setName = $ARGV[0];
|
my $setName = $ARGV[0];
|
||||||
|
|
@ -29,7 +31,6 @@ if(!$setName) {
|
||||||
print 'Enter a set name: ';
|
print 'Enter a set name: ';
|
||||||
$setName = <STDIN>;
|
$setName = <STDIN>;
|
||||||
chomp $setName;
|
chomp $setName;
|
||||||
$setName = $setName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!defined ($knownSets{$setName}))
|
while (!defined ($knownSets{$setName}))
|
||||||
|
|
@ -49,13 +50,12 @@ while (!defined ($knownSets{$setName}))
|
||||||
|
|
||||||
print 'Enter a set name: ';
|
print 'Enter a set name: ';
|
||||||
$setName = <STDIN>;
|
$setName = <STDIN>;
|
||||||
$setName = $setName;
|
|
||||||
chomp $setName;
|
chomp $setName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
open (DATA, $dataFile) || die "can't open $dataFile";
|
open (DATA, $dataFile) || die "can't open $dataFile";
|
||||||
while(my $line = <DATA>) {
|
while(my $line = <DATA>) {
|
||||||
|
chomp $line;
|
||||||
my @data = split('\\|', $line);
|
my @data = split('\\|', $line);
|
||||||
if ($data[1] eq $setName) {
|
if ($data[1] eq $setName) {
|
||||||
push(@setCards, \@data);
|
push(@setCards, \@data);
|
||||||
|
|
@ -65,12 +65,12 @@ close(DATA);
|
||||||
|
|
||||||
open (DATA, $setsFile) || die "can't open $setsFile";
|
open (DATA, $setsFile) || die "can't open $setsFile";
|
||||||
while(my $line = <DATA>) {
|
while(my $line = <DATA>) {
|
||||||
|
chomp $line;
|
||||||
my @data = split('\\|', $line);
|
my @data = split('\\|', $line);
|
||||||
$sets{$data[0]}= $data[1];
|
$sets{$data[0]}= $data[1];
|
||||||
}
|
}
|
||||||
close(DATA);
|
close(DATA);
|
||||||
|
|
||||||
|
|
||||||
sub cardSort {
|
sub cardSort {
|
||||||
if (!looks_like_number(@{$a}[2])) { return -1; }
|
if (!looks_like_number(@{$a}[2])) { return -1; }
|
||||||
if (!looks_like_number(@{$b}[2])) { return 1; }
|
if (!looks_like_number(@{$b}[2])) { return 1; }
|
||||||
|
|
@ -82,53 +82,80 @@ sub cardSort {
|
||||||
sub toCamelCase {
|
sub toCamelCase {
|
||||||
my $string = $_[0];
|
my $string = $_[0];
|
||||||
$string =~ s/\b([\w']+)\b/ucfirst($1)/ge;
|
$string =~ s/\b([\w']+)\b/ucfirst($1)/ge;
|
||||||
$string =~ s/[-,\s\']//g;
|
$string =~ s/[-,\s\'!@#*\(\)]//g;
|
||||||
$string;
|
$string;
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: check for basic lands with ending 1,2,3,4,5 ...
|
# Check which cards are implemented
|
||||||
my %cardNames;
|
my %cardNames;
|
||||||
my $toPrint = '';
|
my %seenCards; # Track which card names we've already processed
|
||||||
|
my @implementedCards;
|
||||||
|
my @unimplementedCards;
|
||||||
|
my $previousCollectorNumber = -1;
|
||||||
|
my %vars;
|
||||||
|
|
||||||
my $setAbbr = $sets{$setName};
|
my $setAbbr = $sets{$setName};
|
||||||
|
|
||||||
foreach my $card (sort cardSort @setCards) {
|
foreach my $card (sort cardSort @setCards) {
|
||||||
my $className = toCamelCase(@{$card}[0]);
|
my $className = toCamelCase(@{$card}[0]);
|
||||||
|
if ($className ~~ @basicLands) {
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
$cardNames {@{$card}[0]} = 1;
|
my $cardName = @{$card}[0];
|
||||||
|
my $collectorNumber = @{$card}[2];
|
||||||
|
|
||||||
|
# Skip if we've already processed this card name or is the back face of a card
|
||||||
|
if (exists $seenCards{$cardName} or $previousCollectorNumber == $collectorNumber) {
|
||||||
|
$seenCards{$cardName} = 1;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
$seenCards{$cardName} = 1;
|
||||||
|
$previousCollectorNumber = $collectorNumber;
|
||||||
|
|
||||||
my $currentFileName = "../Mage.Sets/src/mage/cards/" . lc(substr($className, 0, 1)) . "/" . $className . ".java";
|
my $currentFileName = "../Mage.Sets/src/mage/cards/" . lc(substr($className, 0, 1)) . "/" . $className . ".java";
|
||||||
if(! -e $currentFileName) {
|
my $cardNameForUrl = $cardName;
|
||||||
$cardNames {@{$card}[0]} = 0;
|
$cardNameForUrl =~ s/ //g;
|
||||||
if ($toPrint) {
|
my $cardEntry = "- [ ] In progress -- [$cardName](https://scryfall.com/search?q=!\"$cardNameForUrl\" e:$setAbbr)";
|
||||||
$toPrint .= "\n";
|
|
||||||
}
|
if(-e $currentFileName) {
|
||||||
my $cardName = @{$card}[0];
|
# Card is implemented
|
||||||
$cardName =~ s/ /+/g;
|
$cardNames{$cardName} = 1;
|
||||||
$toPrint .= "@{$card}[2]|[@{$card}[0]](https://scryfall.com/search?q=!\"$cardName\" e:$setAbbr)";
|
my $implementedEntry = "- [x] Done -- [$cardName](https://scryfall.com/search?q=!\"$cardNameForUrl\" e:$setAbbr)";
|
||||||
|
push(@implementedCards, $implementedEntry);
|
||||||
|
} else {
|
||||||
|
# Card is not implemented
|
||||||
|
$cardNames{$cardName} = 0;
|
||||||
|
push(@unimplementedCards, $cardEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open CARD, "> " . lc($sets{$setName}) ."_unimplemented.txt";
|
# Build the unimplemented URL for Scryfall
|
||||||
print CARD $toPrint;
|
my $unimplementedUrl = "https://scryfall.com/search?q=";
|
||||||
close CARD;
|
my @unimplementedNames;
|
||||||
|
foreach my $cardName (sort keys %cardNames) {
|
||||||
|
if ($cardNames{$cardName} == 0) {
|
||||||
print ("Unimplemented cards are here: " . lc($sets{$setName}) ."_unimplemented.txt\n");
|
my $urlCardName = $cardName;
|
||||||
|
$urlCardName =~ s/ //g;
|
||||||
open ISSUE_TRACKER, "> " . lc($sets{$setName}) ."_issue_tracker.txt";
|
$urlCardName =~ s/"/\\"/g; # Escape quotes
|
||||||
print ISSUE_TRACKER "# Cards in set:\n";
|
push(@unimplementedNames, "!\"$urlCardName\"");
|
||||||
|
|
||||||
|
|
||||||
my $cn;
|
|
||||||
foreach $cn (sort keys (%cardNames))
|
|
||||||
{
|
|
||||||
my $x_or_not = "[ ]";
|
|
||||||
if ($cardNames {$cn} == 1)
|
|
||||||
{
|
|
||||||
$x_or_not = "[x]";
|
|
||||||
}
|
}
|
||||||
my $cn2 = $cn;
|
|
||||||
$cn2 =~ s/ /+/g;
|
|
||||||
print ISSUE_TRACKER "- $x_or_not [$cn](https://scryfall.com/search?q=!\"$cn2\" e:$setAbbr)\n";
|
|
||||||
}
|
}
|
||||||
close ISSUE_TRACKER;
|
$unimplementedUrl .= join("or", @unimplementedNames) . "&unique=cards";
|
||||||
print ("Tracking Issue text for a new Github issue (similar to https://github.com/magefree/mage/issues/2215): " . lc($setAbbr) ."_issue_tracker.txt\n");
|
|
||||||
|
# Read template file
|
||||||
|
my $template = Text::Template->new(TYPE => 'FILE', SOURCE => $templateFile, DELIMITERS => [ '[=', '=]' ]);
|
||||||
|
$vars{'unimplemented'} = join("\n", @unimplementedCards);
|
||||||
|
$vars{'implemented'} = join("\n", @implementedCards);
|
||||||
|
$vars{'setName'} = $setName;
|
||||||
|
$vars{'unimplementedUrl'} = $unimplementedUrl;
|
||||||
|
my $result = $template->fill_in(HASH => \%vars);
|
||||||
|
# Write the final issue tracker file
|
||||||
|
my $outputFile = lc($sets{$setName}) . "_issue_tracker.txt";
|
||||||
|
open(OUTPUT, "> $outputFile") || die "can't open $outputFile for writing";
|
||||||
|
print OUTPUT $result;
|
||||||
|
close(OUTPUT);
|
||||||
|
|
||||||
|
print "Issue tracker generated: $outputFile\n";
|
||||||
|
print "Implemented cards: " . scalar(@implementedCards) . "\n";
|
||||||
|
print "Unimplemented cards: " . scalar(@unimplementedCards) . "\n";
|
||||||
18
Utils/issue_tracker.tmpl
Normal file
18
Utils/issue_tracker.tmpl
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
This checklist is here to help manage the implementation of [=$setName=]. If a card is marked as being in progress then someone is working on it.
|
||||||
|
|
||||||
|
If you're new to implementing cards then you likely don't have permission to check things off. This is totally fine! We still appreciate your contributions so just leave a comment to let us know that you're working on it.
|
||||||
|
|
||||||
|
Don't worry about moving things from in progress to completed either, there's a script that handles that, and don't worry about fixing text issues as those are usually handled when the set is done.
|
||||||
|
|
||||||
|
[All Sets](https://github.com/magefree/mage/wiki/Set-implementation-list)
|
||||||
|
|
||||||
|
# Unimplemented Cards
|
||||||
|
|
||||||
|
[=$unimplemented=]
|
||||||
|
|
||||||
|
[Scryfall gallery of everything currently unimplemented]([=$unimplementedUrl=])
|
||||||
|
# Implemented Cards
|
||||||
|
<details><summary>Click to expand</summary>
|
||||||
|
|
||||||
|
[=$implemented=]
|
||||||
|
</details>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue