mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Added to the perl script "gen-existing-cards-by-set.pl" the generation of basic lands.
This commit is contained in:
parent
b724d7fe13
commit
bd7c08562d
2 changed files with 147 additions and 32 deletions
53
Utils/cardExtendedLandClass.tmpl
Normal file
53
Utils/cardExtendedLandClass.tmpl
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.sets.[=$set=];
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author [=$author=]
|
||||
*/
|
||||
|
||||
|
||||
public class [=$className=][=$landNr=] extends mage.cards.basiclands.[=$className=] {
|
||||
|
||||
public [=$className=][=$landNr=](UUID ownerId) {
|
||||
super(ownerId, [=$cardNumber=]);
|
||||
this.expansionSetCode = "[=$expansionSetCode=]";
|
||||
}
|
||||
|
||||
public [=$className=][=$landNr=](final [=$className=][=$landNr=] card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public [=$className=][=$landNr=] copy() {
|
||||
return new [=$className=][=$landNr=](this);
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ if(!$setName) {
|
|||
}
|
||||
|
||||
my $template = Text::Template->new(TYPE => 'FILE', SOURCE => 'cardExtendedClass.tmpl', DELIMITERS => [ '[=', '=]' ]);
|
||||
my $templateBasicLand = Text::Template->new(TYPE => 'FILE', SOURCE => 'cardExtendedLandClass.tmpl', DELIMITERS => [ '[=', '=]' ]);
|
||||
|
||||
sub toCamelCase {
|
||||
my $string = $_[0];
|
||||
|
@ -44,18 +45,24 @@ if (-e $authorFile) {
|
|||
$author = 'anonymous';
|
||||
}
|
||||
|
||||
my $cardsFound = 0;
|
||||
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]);
|
||||
my $cardInfo = {$data[0] ,$data[2]};
|
||||
my $ref_cardInfo = \$cardInfo;
|
||||
push(@setCards, $ref_cardInfo);
|
||||
$cardsFound = $cardsFound + 1;
|
||||
}
|
||||
}
|
||||
close(DATA);
|
||||
print "Number of cards found for set " . $setName . ": " . $cardsFound . "\n";
|
||||
|
||||
open (DATA, $setsFile) || die "can't open $setsFile";
|
||||
|
||||
while(my $line = <DATA>) {
|
||||
my @data = split('\\|', $line);
|
||||
$sets{$data[0]}= $data[1];
|
||||
|
@ -82,11 +89,63 @@ $vars{'author'} = $author;
|
|||
$vars{'set'} = $knownSets{$setName};
|
||||
$vars{'expansionSetCode'} = $sets{$setName};
|
||||
|
||||
my $landForest = 0;
|
||||
my $landMountain = 0;
|
||||
my $landSwamp = 0;
|
||||
my $landPlains = 0;
|
||||
my $landIsland = 0;
|
||||
|
||||
print "Extended cards generated:\n";
|
||||
foreach my $cardName (@setCards) {
|
||||
my $className = toCamelCase($cardName);
|
||||
|
||||
while ( my ($key, $value) = each(@setCards) ) {
|
||||
while ( my ($cardName, $cardNr) = each($$value) ) {
|
||||
if($cardName eq "Forest" || $cardName eq "Island" || $cardName eq "Plains" || $cardName eq "Swamp" || $cardName eq "Mountain") {
|
||||
my $found = 0;
|
||||
my $landNr = "";
|
||||
if ($cardName eq "Forest") {
|
||||
$landForest++;
|
||||
$landNr = $landForest;
|
||||
}
|
||||
if ($cardName eq "Mountain") {
|
||||
$landMountain++;
|
||||
$landNr = $landMountain;
|
||||
}
|
||||
if ($cardName eq "Swamp") {
|
||||
$landSwamp++;
|
||||
$landNr = $landSwamp;
|
||||
}
|
||||
if ($cardName eq "Plains") {
|
||||
$landPlains++;
|
||||
$landNr = $landPlains;
|
||||
}
|
||||
if ($cardName eq "Island") {
|
||||
$landIsland++;
|
||||
$landNr = $landIsland;
|
||||
}
|
||||
if($landNr != "") {
|
||||
$vars{'landNr'} = $landNr;
|
||||
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 {
|
||||
my $className = toCamelCase($cardName);
|
||||
my $currentFileName = "../Mage.Sets/src/mage/sets/" . $knownSets{$setName} . "/" . $className . ".java";
|
||||
if(! -e $currentFileName) {
|
||||
$vars{'className'} = $className;
|
||||
$vars{'cardNumber'} = $cards{$cardName}{$setName}[2];
|
||||
|
@ -98,7 +157,7 @@ foreach my $cardName (@setCards) {
|
|||
if(-e $fileName) {
|
||||
open (DATA, $fileName);
|
||||
while(my $line = <DATA>) {
|
||||
if ($line =~ /extends CardImpl<(\w+?)>/) {
|
||||
if ($line =~ /extends CardImpl<(\w+?)>/ || $line =~ /extends LevelerCard<(\w+?)>/) {
|
||||
$vars{'baseClassName'} = $1;
|
||||
$vars{'baseSet'} = $knownSets{$keySet};
|
||||
|
||||
|
@ -125,3 +184,6 @@ foreach my $cardName (@setCards) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue