card class generator now correctly (i hope) detects cards colors

This commit is contained in:
Loki 2010-12-18 12:26:01 +02:00
parent 23b40c6321
commit 01a47fc34e
2 changed files with 14 additions and 6 deletions

View file

@ -44,8 +44,7 @@ public class [=$classname=] extends CardImpl<[=$classname=]> {
public [=$classname=] (UUID ownerId) { public [=$classname=] (UUID ownerId) {
super(ownerId, [=$collector=], "[=$name=]", Rarity.[=$rarity=], new CardType[]{}, "[=$manacost=]"); super(ownerId, [=$collector=], "[=$name=]", Rarity.[=$rarity=], new CardType[]{}, "[=$manacost=]");
this.expansionSetCode = "[=$setcode=]"; this.expansionSetCode = "[=$setcode=]";
this.subtype.add(""); this.subtype.add("");[= $colors=]
this.color.setCOLOR(true);
[=if (defined($power)) { [=if (defined($power)) {
$OUT .= "this.power = new MageInt($power);"; $OUT .= "this.power = new MageInt($power);";
}=] }=]

View file

@ -2,8 +2,8 @@
use WWW::Mechanize; use WWW::Mechanize;
use HTML::TreeBuilder; use HTML::TreeBuilder;
use Parse::RecDescent;
use Text::Template; use Text::Template;
use Data::Dumper;
use strict; use strict;
my $datafile = "mtg-cards-data.txt"; my $datafile = "mtg-cards-data.txt";
@ -210,6 +210,7 @@ $knownSets{'CON'} = 'conflux';
$knownSets{'M10'} = 'magic2010'; $knownSets{'M10'} = 'magic2010';
$knownSets{'M11'} = 'magic2011'; $knownSets{'M11'} = 'magic2011';
$knownSets{'HOP'} = 'planechase'; $knownSets{'HOP'} = 'planechase';
$knownSets{'RAV'} = 'ravnika';
$knownSets{'ROE'} = 'riseoftheeldrazi'; $knownSets{'ROE'} = 'riseoftheeldrazi';
$knownSets{'ALA'} = 'shardsofalara'; $knownSets{'ALA'} = 'shardsofalara';
$knownSets{'10E'} = 'tenth'; $knownSets{'10E'} = 'tenth';
@ -236,8 +237,12 @@ $mana{'Black or Green'} = 'B\\\\G';
$mana{'Black or Red'} = 'B\\\\R'; $mana{'Black or Red'} = 'B\\\\R';
$mana{'Red or Green'} = 'R\\\\G'; $mana{'Red or Green'} = 'R\\\\G';
my $parser = new Parse::RecDescent(q{ my %manatocolor;
}); $manatocolor{'Black'} = " creature.color.setBlack(true);";
$manatocolor{'Blue'} = " creature.color.setBlue(true);";
$manatocolor{'Green'} = " creature.color.setGreen(true);";
$manatocolor{'Red'} = " creature.color.setRed(true);";
$manatocolor{'White'} = " creature.color.setWhite(true);";
my %normalid; my %normalid;
@ -299,6 +304,7 @@ foreach my $div (@divs) {
} }
} }
if ($id =~m/manaRow/) { if ($id =~m/manaRow/) {
my $findedcolors;
foreach my $sub ($div->look_down('_tag', 'img')) { foreach my $sub ($div->look_down('_tag', 'img')) {
if (defined($sub->attr('alt'))) { if (defined($sub->attr('alt'))) {
my $m = $sub->attr('alt'); my $m = $sub->attr('alt');
@ -307,11 +313,14 @@ foreach my $div (@divs) {
} else { } else {
die "unknown manacost: " . $m unless defined $mana{$m}; die "unknown manacost: " . $m unless defined $mana{$m};
$manacost .= $mana{$m}; $manacost .= $mana{$m};
$findedcolors .= "\n" . $manatocolor{$m};
} }
} }
} }
$manacost =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/; $manacost =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/;
$vars{'manacost'} = $manacost; $vars{'manacost'} = $manacost;
$vars{'colors'} = $findedcolors;
print Dumper(%vars);
} }
if ($id =~/ptRow/) { if ($id =~/ptRow/) {
foreach my $sub ($div->look_down('_tag', 'div')) { foreach my $sub ($div->look_down('_tag', 'div')) {