mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
spjspj - example command - gen-existing-cards-by-set.pl "Commander 2016"
This commit is contained in:
parent
2366f4788f
commit
00acba11d1
1 changed files with 64 additions and 68 deletions
|
@ -46,15 +46,15 @@ if (-e $authorFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $cardsFound = 0;
|
my $cardsFound = 0;
|
||||||
|
print ("Opening $dataFile\n");
|
||||||
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;
|
||||||
|
|
||||||
if ($data[1] eq $setName) {
|
if ($data[1] eq $setName) {
|
||||||
my $cardInfo = {$data[0] ,$data[2]};
|
my $cardInfo = "$data[0],,,$data[2]";
|
||||||
my $ref_cardInfo = \$cardInfo;
|
push(@setCards, $cardInfo);
|
||||||
push(@setCards, $ref_cardInfo);
|
|
||||||
$cardsFound = $cardsFound + 1;
|
$cardsFound = $cardsFound + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,17 @@ $raritiesConversion{'R'} = 'RARE';
|
||||||
$raritiesConversion{'M'} = 'MYTHIC';
|
$raritiesConversion{'M'} = 'MYTHIC';
|
||||||
$raritiesConversion{'Special'} = 'SPECIAL';
|
$raritiesConversion{'Special'} = 'SPECIAL';
|
||||||
$raritiesConversion{'Bonus'} = 'BONUS';
|
$raritiesConversion{'Bonus'} = 'BONUS';
|
||||||
|
sub getRarity
|
||||||
|
{
|
||||||
|
my $val = $_ [0];
|
||||||
|
if (exists ($raritiesConversion {$val}))
|
||||||
|
{
|
||||||
|
return $raritiesConversion {$val};
|
||||||
|
}
|
||||||
|
print ("JSKLDFJSLKDFJLSKJDF --- $val,,,$_[1]\n");
|
||||||
|
sleep (10);
|
||||||
|
return "WHOKNOWS";
|
||||||
|
}
|
||||||
|
|
||||||
# Generate the cards
|
# Generate the cards
|
||||||
|
|
||||||
|
@ -97,94 +108,79 @@ my $landSwamp = 0;
|
||||||
my $landPlains = 0;
|
my $landPlains = 0;
|
||||||
my $landIsland = 0;
|
my $landIsland = 0;
|
||||||
|
|
||||||
print "Extended cards generated:\n";
|
print ("Reading in existing cards in set\n");
|
||||||
|
open (SET_FILE, "../../mage/Mage.Sets/src/mage/sets/$knownSets{$setName}.java") || die "can't open $dataFile";
|
||||||
|
my %alreadyIn;
|
||||||
|
while (<SET_FILE>) {
|
||||||
|
my $line = $_;
|
||||||
|
if ($line =~ m/SetCardInfo.*\("(.*)", (\d+).*/)
|
||||||
|
{
|
||||||
|
$alreadyIn {$2} = $1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close SET_FILE;
|
||||||
|
|
||||||
while ( my ($key, $value) = each(@setCards) ) {
|
my $name_collectorid;
|
||||||
while ( my ($cardName, $cardNr) = each($$value) ) {
|
my %implemented;
|
||||||
|
my %implementedButNotInSetYet;
|
||||||
|
my %unimplemented;
|
||||||
|
|
||||||
|
foreach $name_collectorid (sort @setCards)
|
||||||
|
{
|
||||||
|
my $cardName;
|
||||||
|
my $cardNr;
|
||||||
|
$name_collectorid =~ m/^(.*),,,(.*)$/;
|
||||||
|
$cardName = $1;
|
||||||
|
$cardNr = $2;
|
||||||
|
{
|
||||||
if($cardName eq "Forest" || $cardName eq "Island" || $cardName eq "Plains" || $cardName eq "Swamp" || $cardName eq "Mountain") {
|
if($cardName eq "Forest" || $cardName eq "Island" || $cardName eq "Plains" || $cardName eq "Swamp" || $cardName eq "Mountain") {
|
||||||
my $found = 0;
|
my $found = 0;
|
||||||
my $landNr = "";
|
|
||||||
if ($cardName eq "Forest") {
|
if ($cardName eq "Forest") {
|
||||||
$landForest++;
|
$landForest++;
|
||||||
$landNr = $landForest;
|
|
||||||
}
|
}
|
||||||
if ($cardName eq "Mountain") {
|
if ($cardName eq "Mountain") {
|
||||||
$landMountain++;
|
$landMountain++;
|
||||||
$landNr = $landMountain;
|
|
||||||
}
|
}
|
||||||
if ($cardName eq "Swamp") {
|
if ($cardName eq "Swamp") {
|
||||||
$landSwamp++;
|
$landSwamp++;
|
||||||
$landNr = $landSwamp;
|
|
||||||
}
|
}
|
||||||
if ($cardName eq "Plains") {
|
if ($cardName eq "Plains") {
|
||||||
$landPlains++;
|
$landPlains++;
|
||||||
$landNr = $landPlains;
|
|
||||||
}
|
}
|
||||||
if ($cardName eq "Island") {
|
if ($cardName eq "Island") {
|
||||||
$landIsland++;
|
$landIsland++;
|
||||||
$landNr = $landIsland;
|
|
||||||
}
|
}
|
||||||
if(!($landNr eq "")) {
|
if (!exists ($alreadyIn{$cardNr})) {
|
||||||
$vars{'landNr'} = $landNr;
|
print (" cards.add(new SetCardInfo(\"$cardName\", $cardNr, Rarity.LAND, mage.cards.basiclands.$cardName.class, new CardGraphicInfo(null, true)));\n");
|
||||||
my $className = toCamelCase($cardName) . $landNr;
|
|
||||||
my $currentFileName = "../Mage.Sets/src/mage/sets/" . $knownSets{$setName} . "/" . $className . ".java";
|
|
||||||
|
|
||||||
if(! -e $currentFileName) {
|
|
||||||
|
|
||||||
$vars{'className'} = toCamelCase($cardName);
|
|
||||||
$vars{'cardNumber'} = $cardNr;
|
|
||||||
|
|
||||||
my $result = $templateBasicLand->fill_in(HASH => \%vars);
|
|
||||||
if (defined($result)) {
|
|
||||||
print $vars{'set'} . "." . $vars{'className'} . " cardNr = " . $cardNr . "\n";
|
|
||||||
open CARD, "> $currentFileName";
|
|
||||||
print CARD $result;
|
|
||||||
close CARD;
|
|
||||||
} else {
|
|
||||||
print "Error while creating " . $vars{'className'} ."\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
my $className = toCamelCase($cardName);
|
my $className = toCamelCase($cardName);
|
||||||
my $currentFileName = "../Mage.Sets/src/mage/sets/" . $knownSets{$setName} . "/" . $className . ".java";
|
my $setId = lc($cardName);
|
||||||
if(! -e $currentFileName) {
|
$setId =~ s/^(.).*/$1/;
|
||||||
$vars{'className'} = $className;
|
my $fn = "..\\Mage.Sets\\src\\mage\\cards\\$setId\\$className.java";
|
||||||
$vars{'cardNumber'} = $cards{$cardName}{$setName}[2];
|
my $str = " cards.add(new SetCardInfo(\"$cardName\", $cardNr, Rarity." . getRarity ($cards{$cardName}{$setName}[3], $cardName) . ", mage.cards.$setId.$className.class));\n";
|
||||||
|
if (!exists ($alreadyIn{$cardNr})) {
|
||||||
my $found = 0;
|
# Go Looking for the existing implementation..
|
||||||
foreach my $keySet (keys %{$cards{$cardName}}) {
|
if (-e $fn) {
|
||||||
if (exists $knownSets{$keySet} && $found eq 0) {
|
$implemented {$str} = 1;
|
||||||
my $fileName = "../Mage.Sets/src/mage/sets/" . $knownSets{$keySet} . "/" . $className . ".java";
|
} else {
|
||||||
if(-e $fileName) {
|
$unimplemented {"$str"} = 1;
|
||||||
open (DATA, $fileName);
|
|
||||||
while(my $line = <DATA>) {
|
|
||||||
if ($line =~ /extends CardImpl / || $line =~ /extends LevelerCard /) {
|
|
||||||
$vars{'baseClassName'} = $1;
|
|
||||||
$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]};";
|
|
||||||
}
|
|
||||||
$found = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close(DATA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if($found eq 1) {
|
} else {
|
||||||
my $result = $template->fill_in(HASH => \%vars);
|
if (-e $fn) {
|
||||||
if (defined($result)) {
|
$implementedButNotInSetYet {$str} = 1;
|
||||||
print $vars{'set'} . "." . $vars{'className'} . "\n";
|
} else {
|
||||||
open CARD, "> $currentFileName";
|
$unimplemented {$str} = 1;
|
||||||
print CARD $result;
|
|
||||||
close CARD;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print "Implemented cards:\n";
|
||||||
|
print (join ("", sort keys (%implemented)));
|
||||||
|
print "\n\n\nImplemented but-not-yet-added-to-set cards:\n";
|
||||||
|
print (join ("", sort keys (%implementedButNotInSetYet)));
|
||||||
|
print "\n\n\nUnimplemented cards:\n";
|
||||||
|
print (join ("", sort keys (%unimplemented)));
|
||||||
|
|
Loading…
Reference in a new issue