mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +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,7 +98,7 @@ $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";
|
||||
|
@ -109,8 +109,9 @@ foreach my $setName (keys %{$cards{$cardName}}) {
|
|||
$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];
|
||||
|
@ -146,8 +147,13 @@ foreach my $setName (keys %{$cards{$cardName}}) {
|
|||
|
||||
$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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -79,15 +85,20 @@ foreach my $cardName (@setCards) {
|
|||
$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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue