From 8be7a1c582bc9d046adf3b0036cf76ac67878ddc Mon Sep 17 00:00:00 2001 From: North Date: Sun, 17 Jul 2011 15:55:28 +0300 Subject: [PATCH] Fixed cost generation for multicolored mana. --- Utils/gen-card.pl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Utils/gen-card.pl b/Utils/gen-card.pl index 1d638b1294..c9e37a9981 100755 --- a/Utils/gen-card.pl +++ b/Utils/gen-card.pl @@ -25,6 +25,12 @@ sub toCamelCase { $string; } +sub fixCost { + my $string = $_[0]; + $string =~ s/{([BUGRW])([BUGRW])}/{$1\/$2}/g; + $string; +} + my $author; if (-e $authorFile) { open (DATA, $authorFile); @@ -133,7 +139,7 @@ foreach my $setName (keys %{$cards{$cardName}}) { if (!$baseRarity) { $baseRarity = $cards{$cardName}{$setName}[3]; - $vars{'manaCost'} = $cards{$cardName}{$setName}[4]; + $vars{'manaCost'} = fixCost($cards{$cardName}{$setName}[4]); $vars{'power'} = $cards{$cardName}{$setName}[6]; $vars{'toughness'} = $cards{$cardName}{$setName}[7]; @@ -195,7 +201,7 @@ foreach my $setName (keys %{$cards{$cardName}}) { $vars{'abilities'} .= "\n this.addAbility(new " . $kw . 'Ability(' . $1 . '));'; } elsif ($keywords{$kw} eq 'cost') { $ability =~ m/({.*})/g; - $vars{'abilities'} .= "\n this.addAbility(new " . $kw . 'Ability(new ManaCostsImpl("' . $1 . '")));'; + $vars{'abilities'} .= "\n this.addAbility(new " . $kw . 'Ability(new ManaCostsImpl("' . fixCost($1) . '")));'; $vars{'abilitiesImports'} .= "\nimport mage.abilities.costs.mana.ManaCostsImpl;"; } @@ -234,7 +240,7 @@ foreach my $setName (keys %{$cards{$cardName}}) { } open CARD, "> $fileName"; - print CARD $result; + print CARD $result; close CARD; print "$vars{'set'}.$vars{'className'}\n";