From 01a47fc34eb773db9e96f67d4431c945d92ef554 Mon Sep 17 00:00:00 2001 From: Loki Date: Sat, 18 Dec 2010 12:26:01 +0200 Subject: [PATCH] card class generator now correctly (i hope) detects cards colors --- Utils/cardclass.tmpl | 3 +-- Utils/gen-card.pl | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Utils/cardclass.tmpl b/Utils/cardclass.tmpl index 6ad0603110..fb7812681d 100644 --- a/Utils/cardclass.tmpl +++ b/Utils/cardclass.tmpl @@ -44,8 +44,7 @@ public class [=$classname=] extends CardImpl<[=$classname=]> { public [=$classname=] (UUID ownerId) { super(ownerId, [=$collector=], "[=$name=]", Rarity.[=$rarity=], new CardType[]{}, "[=$manacost=]"); this.expansionSetCode = "[=$setcode=]"; - this.subtype.add(""); - this.color.setCOLOR(true); + this.subtype.add("");[= $colors=] [=if (defined($power)) { $OUT .= "this.power = new MageInt($power);"; }=] diff --git a/Utils/gen-card.pl b/Utils/gen-card.pl index 0a01f99137..fc87e0d1bb 100755 --- a/Utils/gen-card.pl +++ b/Utils/gen-card.pl @@ -2,8 +2,8 @@ use WWW::Mechanize; use HTML::TreeBuilder; -use Parse::RecDescent; use Text::Template; +use Data::Dumper; use strict; my $datafile = "mtg-cards-data.txt"; @@ -210,6 +210,7 @@ $knownSets{'CON'} = 'conflux'; $knownSets{'M10'} = 'magic2010'; $knownSets{'M11'} = 'magic2011'; $knownSets{'HOP'} = 'planechase'; +$knownSets{'RAV'} = 'ravnika'; $knownSets{'ROE'} = 'riseoftheeldrazi'; $knownSets{'ALA'} = 'shardsofalara'; $knownSets{'10E'} = 'tenth'; @@ -236,8 +237,12 @@ $mana{'Black or Green'} = 'B\\\\G'; $mana{'Black or Red'} = 'B\\\\R'; $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; @@ -299,6 +304,7 @@ foreach my $div (@divs) { } } if ($id =~m/manaRow/) { + my $findedcolors; foreach my $sub ($div->look_down('_tag', 'img')) { if (defined($sub->attr('alt'))) { my $m = $sub->attr('alt'); @@ -307,11 +313,14 @@ foreach my $div (@divs) { } else { die "unknown manacost: " . $m unless defined $mana{$m}; $manacost .= $mana{$m}; + $findedcolors .= "\n" . $manatocolor{$m}; } } } $manacost =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/; - $vars{'manacost'} = $manacost; + $vars{'manacost'} = $manacost; + $vars{'colors'} = $findedcolors; + print Dumper(%vars); } if ($id =~/ptRow/) { foreach my $sub ($div->look_down('_tag', 'div')) {