update gen-list-unimplemented-cards-for-set to match current GitHub template

This commit is contained in:
jmlundeen 2025-08-29 14:55:56 -05:00
parent 55ded952bc
commit d59136cc33
2 changed files with 96 additions and 51 deletions

View file

@ -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,70 +65,97 @@ 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; }
if (@{$a}[2] < @{$b}[2]) { return -1; } if (@{$a}[2] < @{$b}[2]) { return -1; }
elsif (@{$a}[2] == @{$b}[2]) { return 0;} elsif (@{$a}[2] == @{$b}[2]) { return 0;}
elsif (@{$a}[2] > @{$b}[2]) { return 1; } elsif (@{$a}[2] > @{$b}[2]) { return 1; }
} }
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 $setAbbr = $sets{$setName}; my @implementedCards;
foreach my $card (sort cardSort @setCards) { my @unimplementedCards;
my $className = toCamelCase(@{$card}[0]); my $previousCollectorNumber = -1;
my %vars;
$cardNames {@{$card}[0]} = 1; my $setAbbr = $sets{$setName};
foreach my $card (sort cardSort @setCards) {
my $className = toCamelCase(@{$card}[0]);
if ($className ~~ @basicLands) {
next;
}
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\"&nbsp;e:$setAbbr)";
$toPrint .= "\n";
}
my $cardName = @{$card}[0];
$cardName =~ s/ /+/g;
$toPrint .= "@{$card}[2]|[@{$card}[0]](https://scryfall.com/search?q=!\"$cardName\"&nbsp;e:$setAbbr)";
}
}
open CARD, "> " . lc($sets{$setName}) ."_unimplemented.txt"; if(-e $currentFileName) {
print CARD $toPrint; # Card is implemented
close CARD; $cardNames{$cardName} = 1;
my $implementedEntry = "- [x] Done -- [$cardName](https://scryfall.com/search?q=!\"$cardNameForUrl\"&nbsp;e:$setAbbr)";
push(@implementedCards, $implementedEntry);
print ("Unimplemented cards are here: " . lc($sets{$setName}) ."_unimplemented.txt\n"); } else {
# Card is not implemented
open ISSUE_TRACKER, "> " . lc($sets{$setName}) ."_issue_tracker.txt"; $cardNames{$cardName} = 0;
print ISSUE_TRACKER "# Cards in set:\n"; push(@unimplementedCards, $cardEntry);
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\"&nbsp;e:$setAbbr)\n";
} }
close ISSUE_TRACKER;
print ("Tracking Issue text for a new Github issue (similar to https://github.com/magefree/mage/issues/2215): " . lc($setAbbr) ."_issue_tracker.txt\n"); # Build the unimplemented URL for Scryfall
my $unimplementedUrl = "https://scryfall.com/search?q=";
my @unimplementedNames;
foreach my $cardName (sort keys %cardNames) {
if ($cardNames{$cardName} == 0) {
my $urlCardName = $cardName;
$urlCardName =~ s/ //g;
$urlCardName =~ s/"/\\"/g; # Escape quotes
push(@unimplementedNames, "!\"$urlCardName\"");
}
}
$unimplementedUrl .= join("or", @unimplementedNames) . "&unique=cards";
# 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
View 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>