mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
Added rarity to generated extended cards. (fixes issue 181)
This commit is contained in:
parent
85ff6ed2a3
commit
a38d978ee6
3 changed files with 34 additions and 17 deletions
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
package mage.sets.[=$set=];
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.UUID;[= if ($rarityExtended) {$OUT .= "\nimport mage.Constants.Rarity;"}=]
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -38,7 +38,7 @@ public class [=$className=] extends mage.sets.[=$baseSet=].[=$baseClassName=] {
|
|||
public [=$className=](UUID ownerId) {
|
||||
super(ownerId);
|
||||
this.cardNumber = [=$cardNumber=];
|
||||
this.expansionSetCode = "[=$expansionSetCode=]";
|
||||
this.expansionSetCode = "[=$expansionSetCode=]";[=$rarityExtended=]
|
||||
}
|
||||
|
||||
public [=$className=](final [=$className=] card) {
|
||||
|
|
|
@ -98,19 +98,20 @@ $vars{'name'} = $cardName;
|
|||
$vars{'className'} = getClassName($cardName);
|
||||
|
||||
print "Files generated:\n";
|
||||
my $baseSet = '';
|
||||
my $baseRarity = '';
|
||||
foreach my $setName (keys %{$cards{$cardName}}) {
|
||||
if (exists $knownSets{$setName}) {
|
||||
my $fileName = "../Mage.Sets/src/mage/sets/" . $knownSets{$setName} . "/" . getClassName($cardName) . ".java";
|
||||
my $result;
|
||||
|
||||
|
||||
$vars{'set'} = $knownSets{$setName};
|
||||
$vars{'expansionSetCode'} = $sets{$setName};
|
||||
$vars{'cardNumber'} = $cards{$cardName}{$setName}[2];
|
||||
$vars{'rarity'} = $raritiesConversion{$cards{$cardName}{$setName}[3]};
|
||||
|
||||
if (!$baseSet) {
|
||||
$baseSet = $knownSets{$setName};
|
||||
|
||||
if (!$baseRarity) {
|
||||
$baseRarity = $cards{$cardName}{$setName}[3];
|
||||
|
||||
$vars{'manaCost'} = $cards{$cardName}{$setName}[4];
|
||||
$vars{'power'} = $cards{$cardName}{$setName}[6];
|
||||
$vars{'toughness'} = $cards{$cardName}{$setName}[7];
|
||||
|
@ -140,18 +141,23 @@ foreach my $setName (keys %{$cards{$cardName}}) {
|
|||
foreach my $color (keys %colors) {
|
||||
$vars{'colors'} .= "\n this.color.set$color(true);";
|
||||
}
|
||||
|
||||
|
||||
$vars{'baseSet'} = $vars{'set'};
|
||||
$vars{'baseClassName'} = $vars{'className'};
|
||||
|
||||
$result = $template->fill_in(HASH => \%vars);
|
||||
} else {
|
||||
$vars{'rarityExtended'} = '';
|
||||
if ($baseRarity ne $cards{$cardName}{$setName}[3]) {
|
||||
$vars{'rarityExtended'} = "\n this.rarity = Rarity.$raritiesConversion{$cards{$cardName}{$setName}[3]};\n";
|
||||
}
|
||||
$result = $templateExtended->fill_in(HASH => \%vars);
|
||||
}
|
||||
|
||||
open CARD, "> $fileName";
|
||||
print CARD $result;
|
||||
close CARD;
|
||||
|
||||
|
||||
print "$fileName\n";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ open (DATA, $dataFile) || die "can't open $dataFile";
|
|||
while(my $line = <DATA>) {
|
||||
my @data = split('\\|', $line);
|
||||
$cards{$data[0]}{$data[1]} = \@data;
|
||||
|
||||
|
||||
if ($data[1] eq $setName) {
|
||||
push(@setCards, $data[0]);
|
||||
}
|
||||
|
@ -62,6 +62,12 @@ while(my $line = <DATA>) {
|
|||
}
|
||||
close(DATA);
|
||||
|
||||
my %raritiesConversion;
|
||||
$raritiesConversion{'C'} = 'COMMON';
|
||||
$raritiesConversion{'U'} = 'UNCOMMON';
|
||||
$raritiesConversion{'R'} = 'RARE';
|
||||
$raritiesConversion{'M'} = 'MYTHIC';
|
||||
|
||||
# Generate the cards
|
||||
|
||||
my %vars;
|
||||
|
@ -73,21 +79,26 @@ print "Files generated:\n";
|
|||
foreach my $cardName (@setCards) {
|
||||
my $className = getClassName($cardName);
|
||||
my $currentFileName = "../Mage.Sets/src/mage/sets/" . $knownSets{$setName} . "/" . $className . ".java";
|
||||
|
||||
|
||||
if(! -e $currentFileName) {
|
||||
$vars{'className'} = $className;
|
||||
$vars{'cardNumber'} = $cards{$cardName}{$setName}[2];
|
||||
|
||||
|
||||
my $found = 0;
|
||||
foreach my $key (keys %{$cards{$cardName}}) {
|
||||
if (exists $knownSets{$key} && $found eq 0) {
|
||||
my $fileName = "../Mage.Sets/src/mage/sets/" . $knownSets{$key} . "/" . $className . ".java";
|
||||
foreach my $keySet (keys %{$cards{$cardName}}) {
|
||||
if (exists $knownSets{$keySet} && $found eq 0) {
|
||||
my $fileName = "../Mage.Sets/src/mage/sets/" . $knownSets{$keySet} . "/" . $className . ".java";
|
||||
if(-e $fileName) {
|
||||
open (DATA, $fileName);
|
||||
while(my $line = <DATA>) {
|
||||
if ($line =~ /extends CardImpl<(\w+?)>/) {
|
||||
$vars{'baseClassName'} = $1;
|
||||
$vars{'baseSet'} = $knownSets{$key};
|
||||
$vars{'baseSet'} = $knownSets{$keySet};
|
||||
|
||||
$vars{'rarityExtended'} = '';
|
||||
if ($cards{$cardName}{$setName}[3] ne $cards{$cardName}{$keySet}[3]) {
|
||||
$vars{'rarityExtended'} = "\n this.rarity = Rarity.$raritiesConversion{$cards{$cardName}{$setName}[3]};\n";
|
||||
}
|
||||
$found = 1;
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +106,7 @@ foreach my $cardName (@setCards) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($found eq 1) {
|
||||
my $result = $template->fill_in(HASH => \%vars);
|
||||
if (defined($result)) {
|
||||
|
|
Loading…
Reference in a new issue