mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
update gen-card.pl to support adding multiple versions of a card to a set
This commit is contained in:
parent
f07cc4a7f2
commit
a9f9407fc2
1 changed files with 74 additions and 66 deletions
|
|
@ -5,7 +5,6 @@
|
||||||
use Text::Template;
|
use Text::Template;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
|
||||||
my $authorFile = 'author.txt';
|
my $authorFile = 'author.txt';
|
||||||
my $dataFile = 'mtg-cards-data.txt';
|
my $dataFile = 'mtg-cards-data.txt';
|
||||||
my $setsFile = 'mtg-sets-data.txt';
|
my $setsFile = 'mtg-sets-data.txt';
|
||||||
|
|
@ -32,7 +31,7 @@ sub fixCost {
|
||||||
|
|
||||||
my $author;
|
my $author;
|
||||||
if (-e $authorFile) {
|
if (-e $authorFile) {
|
||||||
open (DATA, $authorFile) || die "can't open $authorFile : $!";
|
open(DATA, $authorFile) || die "can't open $authorFile : $!";
|
||||||
$author = <DATA>;
|
$author = <DATA>;
|
||||||
chomp $author;
|
chomp $author;
|
||||||
close(DATA);
|
close(DATA);
|
||||||
|
|
@ -40,32 +39,32 @@ if (-e $authorFile) {
|
||||||
$author = 'anonymous';
|
$author = 'anonymous';
|
||||||
}
|
}
|
||||||
|
|
||||||
open (DATA, $dataFile) || die "can't open $dataFile : $!";
|
open(DATA, $dataFile) || die "can't open $dataFile : $!";
|
||||||
while(my $line = <DATA>) {
|
while (my $line = <DATA>) {
|
||||||
my @data = split('\\|', $line);
|
my @data = split('\\|', $line);
|
||||||
$cards{$data[0]}{$data[1]} = \@data;
|
$cards{$data[0]}{$data[1]}{$data[2]} = \@data;
|
||||||
}
|
}
|
||||||
close(DATA);
|
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>) {
|
||||||
my @data = split('\\|', $line);
|
my @data = split('\\|', $line);
|
||||||
$sets{$data[0]}= $data[1];
|
$sets{$data[0]} = $data[1];
|
||||||
#print "$data[0]--$data[1]\n"
|
#print "$data[0]--$data[1]\n"
|
||||||
}
|
}
|
||||||
close(DATA);
|
close(DATA);
|
||||||
|
|
||||||
open (DATA, $knownSetsFile) || die "can't open $knownSetsFile : $!";
|
open(DATA, $knownSetsFile) || die "can't open $knownSetsFile : $!";
|
||||||
while(my $line = <DATA>) {
|
while (my $line = <DATA>) {
|
||||||
my @data = split('\\|', $line);
|
my @data = split('\\|', $line);
|
||||||
$knownSets{$data[0]}= $data[1];
|
$knownSets{$data[0]} = $data[1];
|
||||||
}
|
}
|
||||||
close(DATA);
|
close(DATA);
|
||||||
|
|
||||||
open (DATA, $keywordsFile) || die "can't open $keywordsFile : $!";
|
open(DATA, $keywordsFile) || die "can't open $keywordsFile : $!";
|
||||||
while(my $line = <DATA>) {
|
while (my $line = <DATA>) {
|
||||||
my @data = split('\\|', $line);
|
my @data = split('\\|', $line);
|
||||||
$keywords{toCamelCase($data[0])}= $data[1];
|
$keywords{toCamelCase($data[0])} = $data[1];
|
||||||
}
|
}
|
||||||
close(DATA);
|
close(DATA);
|
||||||
|
|
||||||
|
|
@ -97,12 +96,11 @@ if (!$cardName) {
|
||||||
chomp $cardName;
|
chomp $cardName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!exists $cards{$cardName}) {
|
if (!exists $cards{$cardName}) {
|
||||||
my $possible;
|
my $possible;
|
||||||
foreach $possible (sort keys (%cards)) {
|
foreach $possible (sort keys(%cards)) {
|
||||||
if ($possible =~ m/$cardName/img && $cardName =~ m/..../) {
|
if ($possible =~ m/$cardName/img && $cardName =~ m/..../) {
|
||||||
print ("Did you mean $possible?\n");
|
print("Did you mean $possible?\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
die "Card name doesn't exist: $cardName\n";
|
die "Card name doesn't exist: $cardName\n";
|
||||||
|
|
@ -123,8 +121,8 @@ if (index($cardName, $splitDelimiter) != -1) {
|
||||||
|
|
||||||
|
|
||||||
# Check if card is already implemented
|
# Check if card is already implemented
|
||||||
my $fileName = "../Mage.Sets/src/mage/cards/".lc(substr($cardName, 0, 1))."/".toCamelCase($cardName).".java";
|
my $fileName = "../Mage.Sets/src/mage/cards/" . lc(substr($cardName, 0, 1)) . "/" . toCamelCase($cardName) . ".java";
|
||||||
if(-e $fileName) {
|
if (-e $fileName) {
|
||||||
die "$cardName is already implemented.\n$fileName\n";
|
die "$cardName is already implemented.\n$fileName\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,9 +133,18 @@ $vars{'cardNameFirstLetter'} = lc substr($cardName, 0, 1);
|
||||||
my @card;
|
my @card;
|
||||||
|
|
||||||
foreach my $setName (keys %{$cards{$originalName}}) {
|
foreach my $setName (keys %{$cards{$originalName}}) {
|
||||||
my $setFileName = "../Mage.Sets/src/mage/sets/".$knownSets{$setName}.".java";
|
my $keyCount = keys %{$cards{$originalName}{$setName}};
|
||||||
@card = @{${cards{$originalName}{$setName}}};
|
my $printingString;
|
||||||
my $line = " cards.add(new SetCardInfo(\"".$card[0]."\", ".$card[2].", Rarity.".$raritiesConversion{$card[3]}.", mage.cards.".$vars{'cardNameFirstLetter'}.".".$vars{'className'}.".class));\n";
|
if (($keyCount) > 1) {
|
||||||
|
$printingString = ", NON_FULL_USE_VARIOUS";
|
||||||
|
} else {
|
||||||
|
$printingString = "";
|
||||||
|
}
|
||||||
|
foreach my $cardNumber (sort keys %{$cards{$originalName}{$setName}}) {
|
||||||
|
my $setFileName = "../Mage.Sets/src/mage/sets/" . $knownSets{$setName} . ".java";
|
||||||
|
@card = @{${cards {$originalName}{ $setName }{$cardNumber}}};
|
||||||
|
my $line = " cards.add(new SetCardInfo(\"" . $card[0] . "\", " . $card[2] . ", Rarity." . $raritiesConversion{$card[3]} . ", mage.cards." . $vars{'cardNameFirstLetter'} . "." . $vars{'className'} . ".class" . $printingString . "));\n";
|
||||||
|
print $line;
|
||||||
@ARGV = ($setFileName);
|
@ARGV = ($setFileName);
|
||||||
$^I = '.bak';
|
$^I = '.bak';
|
||||||
my $last;
|
my $last;
|
||||||
|
|
@ -167,13 +174,14 @@ foreach my $setName (keys %{$cards{$originalName}}) {
|
||||||
print $line;
|
print $line;
|
||||||
}
|
}
|
||||||
# print card line in the middle
|
# print card line in the middle
|
||||||
if (defined($lastName) && defined($currName) && ($cardName cmp $lastName) > 0 && ($currName cmp $cardName) > 0) {
|
if (defined($lastName) && defined($currName) && ($cardName cmp $lastName) > -1 && ($currName cmp $cardName) > 0) {
|
||||||
print $line;
|
print $line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unlink $setFileName.".bak";
|
unlink $setFileName . ".bak";
|
||||||
print "$setFileName\n";
|
print "$setFileName\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate the card
|
# Generate the card
|
||||||
|
|
@ -282,8 +290,8 @@ foreach my $ability (@abilities) {
|
||||||
if ($1 =~ m/(^.*\s.*)/g) {
|
if ($1 =~ m/(^.*\s.*)/g) {
|
||||||
$vars{'abilities'} .= "\n TargetPermanent auraTarget = new TargetPermanent(filter);";
|
$vars{'abilities'} .= "\n TargetPermanent auraTarget = new TargetPermanent(filter);";
|
||||||
} else {
|
} else {
|
||||||
$vars{'abilities'} .= "\n TargetPermanent auraTarget = new Target". toCamelCase($1) . "Permanent();";
|
$vars{'abilities'} .= "\n TargetPermanent auraTarget = new Target" . toCamelCase($1) . "Permanent();";
|
||||||
$vars{'abilitiesImports'} .= "\nimport mage.target.common.Target". toCamelCase($1) . "Permanent;";
|
$vars{'abilitiesImports'} .= "\nimport mage.target.common.Target" . toCamelCase($1) . "Permanent;";
|
||||||
}
|
}
|
||||||
$vars{'abilities'} .= "\n this.getSpellAbility().addTarget(auraTarget);";
|
$vars{'abilities'} .= "\n this.getSpellAbility().addTarget(auraTarget);";
|
||||||
$vars{'abilities'} .= "\n this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));";
|
$vars{'abilities'} .= "\n this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue