mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
add card class generator script
This commit is contained in:
parent
9fbb6d2738
commit
ea3c40743b
7 changed files with 19525 additions and 6 deletions
|
@ -1,9 +1,9 @@
|
|||
server-name=localhost
|
||||
port=17171
|
||||
remote-server=mage-server
|
||||
cards-resource-path=C:\\Program Files (x86)\\Wizards of the Coast\\Magic Online III\\Graphics\\Cards\\
|
||||
symbols-resource-path=C:\\Program Files (x86)\\Wizards of the Coast\\Magic Online III\\Graphics\\Chat\\chat_graphic_typingicon_
|
||||
resource-path=C:\\Program Files (x86)\\Wizards of the Coast\\Magic Online III\\Graphics\\Cards\\Pics\\
|
||||
remote-server=mage-server
|
||||
cards-resource-path=/home/loki/.wine/drive_c/Program Files/Wizards of the Coast/Magic Online/Graphics/Cards/
|
||||
symbols-resource-path=/home/loki/.wine/drive_c/Program Files/Wizards of the Coast/Magic Online/Graphics/Chat/chat_graphic_typingicon_
|
||||
resource-path=/home/loki/.wine/drive_c/Program Files/Wizards of the Coast/Magic Online/Graphics/Cards/Pics/
|
||||
#cards-resource-path=resources/images/cards/
|
||||
#symbols-resource-path=resources/images/symbols/
|
||||
#resource-path=resources/images/
|
||||
|
@ -13,4 +13,4 @@ card-scaling-factor=0.4
|
|||
default-deck-path=C:\\Projects\\Mage\\Mage.Client\\release\\sample-decks\\WhiteTokens.dck
|
||||
# 0: Human, 1: Computer - default, 2: Computer - minimax, 3: Computer - minimax hybrid
|
||||
default-other-player-index=1
|
||||
default-computer-name=computer
|
||||
default-computer-name=computer
|
||||
|
|
Binary file not shown.
|
@ -22,6 +22,10 @@
|
|||
<fileSet>
|
||||
<directory>release/</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
</fileSet>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>plugins/*.jar</directory>
|
||||
<outputDirectory>plugins/</outputDirectory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
||||
|
|
70
Utils/cardclass.tmpl
Normal file
70
Utils/cardclass.tmpl
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* 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.[=$longset=];
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;[= if (defined($power)) {$OUT .= "\nimport mage.MageInt";}=]
|
||||
import mage.cards.CardImpl;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Loki
|
||||
*/
|
||||
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);
|
||||
[=if (defined($power)) {
|
||||
$OUT .= "this.power = new MageInt($power);";
|
||||
}=]
|
||||
[=if (defined($toughness)) {
|
||||
$OUT .= "this.toughness = new MageInt($toughness);";
|
||||
}=]
|
||||
}
|
||||
|
||||
public [=$classname=] (final [=$classname=] card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public [=$classname=] copy() {
|
||||
return new [=$classname=](this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArt() {
|
||||
return "[=$artwork=]";
|
||||
}
|
||||
}
|
362
Utils/gen-card.pl
Executable file
362
Utils/gen-card.pl
Executable file
|
@ -0,0 +1,362 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
use WWW::Mechanize;
|
||||
use HTML::TreeBuilder;
|
||||
use Text::Template;
|
||||
use strict;
|
||||
|
||||
my $datafile = "mtg-cards-data.txt";
|
||||
|
||||
my @sets;
|
||||
my @collector;
|
||||
my %rarities;
|
||||
my %collectors;
|
||||
my @multiverses;
|
||||
|
||||
my $manacost = "";
|
||||
my $loyality = -1;
|
||||
my $power = -1;
|
||||
my $toughness = -1;
|
||||
my @texts;
|
||||
my @types;
|
||||
|
||||
my %fulltoshort;
|
||||
|
||||
$fulltoshort{'Tenth Edition'} = '10E';
|
||||
$fulltoshort{'Unlimited Edition'} = '2ED';
|
||||
$fulltoshort{'Revised Edition'} = '3ED';
|
||||
$fulltoshort{'Fourth Edition'} = '4ED';
|
||||
$fulltoshort{'Fifth Dawn'} = '5DN';
|
||||
$fulltoshort{'Fifth Edition'} = '5ED';
|
||||
$fulltoshort{'Classic Sixth Edition'} = '6ED';
|
||||
$fulltoshort{'Seventh Edition'} = '7ED';
|
||||
$fulltoshort{'Eighth Edition'} = '8ED';
|
||||
$fulltoshort{'Alliances'} = 'ALL';
|
||||
$fulltoshort{'Apocalypse'} = 'APC';
|
||||
$fulltoshort{'Alara Reborn'} = 'ARB';
|
||||
$fulltoshort{'Arabian Nights'} = 'ARN';
|
||||
$fulltoshort{'Anthologies'} = 'ATH';
|
||||
$fulltoshort{'Antiquities'} = 'ATQ';
|
||||
$fulltoshort{'Betrayers of Kamigawa'} = 'BOK';
|
||||
$fulltoshort{'Battle Royale Box Set'} = 'BRB';
|
||||
$fulltoshort{'Beatdown Box Set'} = 'BTD';
|
||||
$fulltoshort{'Champions of Kamigawa'} = 'CHK';
|
||||
$fulltoshort{'Chronicles'} = 'CHR';
|
||||
$fulltoshort{'Conflux'} = 'CON';
|
||||
$fulltoshort{'Coldsnap'} = 'CSP';
|
||||
$fulltoshort{'Darksteel'} = 'DST';
|
||||
$fulltoshort{'Dissension'} = 'DIS';
|
||||
$fulltoshort{'Deckmasters'} = 'DKM';
|
||||
$fulltoshort{'The Dark'} = 'DRK';
|
||||
$fulltoshort{'Darksteel'} = 'DST';
|
||||
$fulltoshort{'Duel Decks: Divine vs. Demonic'} = 'DVD';
|
||||
$fulltoshort{'Duel Decks: Elves vs. Goblins'} = 'EVG';
|
||||
$fulltoshort{'Duel Decks: Garruk vs. Liliana'} = 'GVL';
|
||||
$fulltoshort{'Duel Decks: Jace vs. Chandra'} = 'JVC';
|
||||
$fulltoshort{'Duel Decks: Phyrexia vs. the Coalition'} = 'PVC';
|
||||
$fulltoshort{'Eventide'} = 'EVE';
|
||||
$fulltoshort{'Exodus'} = 'EXO';
|
||||
$fulltoshort{'Fallen Empires'} = 'FEM';
|
||||
$fulltoshort{'Future Sight'} = 'FUT';
|
||||
$fulltoshort{'From the Vault: Dragons'} = 'FVD';
|
||||
$fulltoshort{'From the Vault: Exiled'} = 'FVE';
|
||||
$fulltoshort{'Guildpact'} = 'GPT';
|
||||
$fulltoshort{'Homelands'} = 'HML';
|
||||
$fulltoshort{'Planechase'} = 'HOP';
|
||||
$fulltoshort{'Ice Age'} = 'ICE';
|
||||
$fulltoshort{'Invasion'} = 'INV';
|
||||
$fulltoshort{'Judgment'} = 'JUD';
|
||||
$fulltoshort{'Limited Edition Alpha'} = 'LEA';
|
||||
$fulltoshort{'Limited Edition Beta'} = 'LEB';
|
||||
$fulltoshort{'Legends'} = 'LEG';
|
||||
$fulltoshort{'Legions'} = 'LGN';
|
||||
$fulltoshort{'Lorwyn'} = 'LRW';
|
||||
$fulltoshort{'Magic 2010'} = 'M10';
|
||||
$fulltoshort{'Magic 2011'} = 'M11';
|
||||
$fulltoshort{'Masters Edition II'} = 'ME2';
|
||||
$fulltoshort{'Masters Edition III'} = 'ME3';
|
||||
$fulltoshort{'Masters Edition'} = 'MED';
|
||||
$fulltoshort{'Mirage'} = 'MIR';
|
||||
$fulltoshort{'Mercadian Masques'} = 'MMQ';
|
||||
$fulltoshort{'Morningtide'} = 'MOR';
|
||||
$fulltoshort{'Mirrodin'} = 'MRD';
|
||||
$fulltoshort{'Ninth Edition'} = '9ED';
|
||||
$fulltoshort{'Nemesis'} = 'NEM';
|
||||
$fulltoshort{'Odyssey'} = 'ODY';
|
||||
$fulltoshort{'Onslaught'} = 'ONS';
|
||||
$fulltoshort{'Portal Second Age'} = 'PO2';
|
||||
$fulltoshort{'Prophecy'} = 'PCY';
|
||||
$fulltoshort{'Planar Chaos'} = 'PLC';
|
||||
$fulltoshort{'Planeshift'} = 'PLS';
|
||||
$fulltoshort{'Portal'} = 'POR';
|
||||
$fulltoshort{'Portal Three Kingdoms'} = 'PTK';
|
||||
$fulltoshort{'Premium Deck Series: Slivers'} = 'PDS';
|
||||
$fulltoshort{'Ravnica: City of Guilds'} = 'RAV';
|
||||
$fulltoshort{'Rise of the Eldrazi'} = 'ROE';
|
||||
$fulltoshort{'Starter 2000'} = 'S00';
|
||||
$fulltoshort{'Starter 1999'} = 'S99';
|
||||
$fulltoshort{'Scourge'} = 'SCG';
|
||||
$fulltoshort{'Shadowmoor'} = 'SHM';
|
||||
$fulltoshort{'Shards of Alara'} = 'ALA';
|
||||
$fulltoshort{'Saviors of Kamigawa'} = 'SOK';
|
||||
$fulltoshort{'Stronghold'} = 'STH';
|
||||
$fulltoshort{'Tempest'} = 'TMP';
|
||||
$fulltoshort{'Torment'} = 'TOR';
|
||||
$fulltoshort{'Time Spiral "Timeshifted"'} = 'TSB';
|
||||
$fulltoshort{'Time Spiral'} = 'TSP';
|
||||
$fulltoshort{'Urza\'s Destiny'} = 'UDS';
|
||||
$fulltoshort{'Unglued'} = 'UGL';
|
||||
$fulltoshort{'Urza\'s Legacy'} = 'ULG';
|
||||
$fulltoshort{'Unhinged'} = 'UNH';
|
||||
$fulltoshort{'Urza\'s Saga'} = 'USG';
|
||||
$fulltoshort{'Vanguard Set 1'} = 'VG1';
|
||||
$fulltoshort{'Vanguard Set 2'} = 'VG2';
|
||||
$fulltoshort{'Vanguard Set 3'} = 'VG3';
|
||||
$fulltoshort{'Vanguard Set 4'} = 'VG4';
|
||||
$fulltoshort{'MTGO Vanguard'} = 'VGO';
|
||||
$fulltoshort{'Visions'} = 'VIS';
|
||||
$fulltoshort{'Weatherlight'} = 'WTH';
|
||||
$fulltoshort{'Worldwake'} = 'WWK';
|
||||
$fulltoshort{'Zendikar'} = 'ZEN';
|
||||
$fulltoshort{'Archenemy'} = 'ARC';
|
||||
|
||||
my %wizardstous;
|
||||
$wizardstous{'6E'} = '6ED';
|
||||
$wizardstous{'7E'} = '7ED';
|
||||
$wizardstous{'8ED'} = '8ED';
|
||||
$wizardstous{'9ED'} = '9ED';
|
||||
$wizardstous{'10E'} = '10E';
|
||||
$wizardstous{'BD'} = 'BTD';
|
||||
$wizardstous{'DDD'} = 'GVL';
|
||||
$wizardstous{'CG'} = 'UDS';
|
||||
$wizardstous{'ST'} = 'STH';
|
||||
$wizardstous{'ONS'} = 'ONS';
|
||||
$wizardstous{'P3'} = 'S99';
|
||||
$wizardstous{'P4'} = 'S00';
|
||||
$wizardstous{'OD'} = 'ODY';
|
||||
$wizardstous{'M10'} = 'M10';
|
||||
$wizardstous{'M11'} = 'M11';
|
||||
$wizardstous{'LRW'} = 'LRW';
|
||||
$wizardstous{'DD2'} = 'JVC';
|
||||
$wizardstous{'TSB'} = 'TSB';
|
||||
$wizardstous{'ZEN'} = 'ZEN';
|
||||
$wizardstous{'5E'} = '5ED';
|
||||
$wizardstous{'IA'} = 'ICE';
|
||||
$wizardstous{'4E'} = '4ED';
|
||||
$wizardstous{'3E'} = '3ED';
|
||||
$wizardstous{'2U'} = '2ED';
|
||||
$wizardstous{'2E'} = 'LEB';
|
||||
$wizardstous{'1E'} = 'LEA';
|
||||
$wizardstous{'EVG'} = 'EVG';
|
||||
$wizardstous{'BR'} = 'BRB';
|
||||
$wizardstous{'ME2'} = 'ME2';
|
||||
$wizardstous{'ME3'} = 'ME3';
|
||||
$wizardstous{'HOP'} = 'HOP';
|
||||
$wizardstous{'PO'} = 'POR';
|
||||
$wizardstous{'P2'} = 'PO2';
|
||||
$wizardstous{'PK'} = 'PTK';
|
||||
$wizardstous{'MED'} = 'MED';
|
||||
$wizardstous{'EVE'} = 'EVE';
|
||||
$wizardstous{'MOR'} = 'MOR';
|
||||
$wizardstous{'RAV'} = 'RAV';
|
||||
$wizardstous{'SHM'} = 'SHM';
|
||||
$wizardstous{'MI'} = 'MIR';
|
||||
$wizardstous{'ARB'} = 'ARB';
|
||||
$wizardstous{'VI'} = 'VIS';
|
||||
$wizardstous{'DST'} = 'DST';
|
||||
$wizardstous{'TOR'} = 'TOR';
|
||||
$wizardstous{'DDC'} = 'DVD';
|
||||
$wizardstous{'AP'} = 'APC';
|
||||
$wizardstous{'CON'} = 'CON';
|
||||
$wizardstous{'ALA'} = 'ALA';
|
||||
$wizardstous{'DDE'} = 'PVC';
|
||||
$wizardstous{'JUD'} = 'JUD';
|
||||
$wizardstous{'WL'} = 'WTH';
|
||||
$wizardstous{'MRD'} = 'MRD';
|
||||
$wizardstous{'TE'} = 'TMP';
|
||||
$wizardstous{'DRB'} = 'FVD';
|
||||
$wizardstous{'PR'} = 'PCY';
|
||||
$wizardstous{'UZ'} = 'USG';
|
||||
$wizardstous{'IN'} = 'INV';
|
||||
$wizardstous{'FUT'} = 'FUT';
|
||||
$wizardstous{'TSP'} = 'TSP';
|
||||
$wizardstous{'CHK'} = 'CHK';
|
||||
$wizardstous{'EX'} = 'EXO';
|
||||
$wizardstous{'FE'} = 'FEM';
|
||||
$wizardstous{'PLC'} = 'PLC';
|
||||
$wizardstous{'CHK'} = 'CHK';
|
||||
$wizardstous{'ROE'} = 'ROE';
|
||||
$wizardstous{'5DN'} = '5DN';
|
||||
$wizardstous{'LE'} = 'LEG';
|
||||
$wizardstous{'CH'} = 'CHR';
|
||||
$wizardstous{'H09'} = 'PDS';
|
||||
$wizardstous{'MM'} = 'MMQ';
|
||||
$wizardstous{'GPT'} = 'GPT';
|
||||
$wizardstous{'GU'} = 'ULG';
|
||||
$wizardstous{'ARC'} = 'ARC';
|
||||
$wizardstous{'DIS'} = 'DIS';
|
||||
$wizardstous{'NE'} = 'NEM';
|
||||
$wizardstous{'PS'} = 'PLS';
|
||||
$wizardstous{'LGN'} = 'LGN';
|
||||
$wizardstous{'AN'} = 'ARN';
|
||||
$wizardstous{'WWK'} = 'WWK';
|
||||
|
||||
my %knownSets;
|
||||
$knownSets{'ARB'} = 'alarareborn';
|
||||
$knownSets{'CON'} = 'conflux';
|
||||
$knownSets{'M10'} = 'magic2010';
|
||||
$knownSets{'M11'} = 'magic2011';
|
||||
$knownSets{'HOP'} = 'planechase';
|
||||
$knownSets{'ROE'} = 'riseoftheeldrazi';
|
||||
$knownSets{'ALA'} = 'shardsofalara';
|
||||
$knownSets{'10E'} = 'tenth';
|
||||
$knownSets{'WWK'} = 'worldwake';
|
||||
$knownSets{'ZEN'} = 'zendikar';
|
||||
|
||||
my %raritiesConversion;
|
||||
$raritiesConversion{'C'} = 'COMMON';
|
||||
$raritiesConversion{'U'} = 'UNCOMMON';
|
||||
$raritiesConversion{'R'} = 'RARE';
|
||||
$raritiesConversion{'M'} = 'MYTHIC';
|
||||
|
||||
my %mana;
|
||||
$mana{'Black'} = '{B}';
|
||||
$mana{'Blue'} = '{U}';
|
||||
$mana{'Green'} = '{G}';
|
||||
$mana{'Red'} = '{R}';
|
||||
$mana{'White'} = '{W}';
|
||||
$mana{'Variable Colorless'} = '{X}';
|
||||
$mana{'White or Black'} = 'W\\\\B';
|
||||
$mana{'Green or White'} = 'G\\\\W';
|
||||
$mana{'Black or Green'} = 'B\\\\G';
|
||||
$mana{'Black or Red'} = 'B\\\\R';
|
||||
$mana{'Red or Green'} = 'R\\\\G';
|
||||
|
||||
my %normalid;
|
||||
|
||||
print "Enter a card name: ";
|
||||
my $cardname = <STDIN>;
|
||||
chomp $cardname;
|
||||
my $finded = 0;
|
||||
|
||||
open DATA, "< $datafile" or die "Can't open datafile: $!";
|
||||
while (<DATA>) {
|
||||
my $str = $_;
|
||||
my (undef, $name, $set, $rarity, $multiverse, $collector) = split("\\|");
|
||||
if ($cardname eq $name) {
|
||||
die "can't find set: $set" unless defined $fulltoshort{$set};
|
||||
push(@sets, $fulltoshort{$set});
|
||||
$rarities{$fulltoshort{$set}} = $rarity;
|
||||
$collectors{$fulltoshort{$set}} = $collector;
|
||||
push(@multiverses, $multiverse);
|
||||
$finded = 1;
|
||||
}
|
||||
}
|
||||
|
||||
die "card not found" unless $finded;
|
||||
|
||||
my $mech = WWW::Mechanize->new( autocheck => 1 );
|
||||
my $parser = HTML::TreeBuilder->new();
|
||||
|
||||
$mech->get("http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=" . $multiverses[0] );
|
||||
print "card fetched\n";
|
||||
|
||||
my $template = Text::Template->new(SOURCE => 'cardclass.tmpl', DELIMITERS => [ '[=', '=]' ]);
|
||||
my %vars;
|
||||
$vars{'name'} = $cardname;
|
||||
$cardname =~ s/[-\s\']//g;
|
||||
$vars{'classname'} = $cardname;
|
||||
|
||||
|
||||
$parser->parse($mech->content());
|
||||
my @divs = $parser->look_down('_tag', 'div');
|
||||
foreach my $div (@divs) {
|
||||
if (defined($div->attr('id'))) {
|
||||
my $id = $div->attr('id');
|
||||
if ($id =~m/textRow/) {
|
||||
foreach my $sub ($div->look_down('_tag', 'div')) {
|
||||
if (defined($sub->attr('class')) && $sub->attr('class') eq 'cardtextbox') {
|
||||
push(@texts, $sub->as_text());
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($id =~m/typeRow/) {
|
||||
foreach my $sub ($div->look_down('_tag', 'div')) {
|
||||
if (defined($sub->attr('class')) && $sub->attr('class') eq 'value') {
|
||||
my $type = $sub->as_text();
|
||||
chomp $type;
|
||||
while ( $type =~ m/([a-zA-z]+)( )*/g ) {
|
||||
push @types, $1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($id =~m/manaRow/) {
|
||||
foreach my $sub ($div->look_down('_tag', 'img')) {
|
||||
if (defined($sub->attr('alt'))) {
|
||||
my $m = $sub->attr('alt');
|
||||
if ($m =~ /^-?\d/) {
|
||||
$manacost .= "{" . $m . "}";
|
||||
} else {
|
||||
die "unknown manacost: " . $m unless defined $mana{$m};
|
||||
$manacost .= $mana{$m};
|
||||
}
|
||||
}
|
||||
}
|
||||
$manacost =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/;
|
||||
$vars{'manacost'} = $manacost;
|
||||
}
|
||||
if ($id =~/ptRow/) {
|
||||
foreach my $sub ($div->look_down('_tag', 'div')) {
|
||||
if (defined($sub->attr('class')) && $sub->attr('class') eq 'value') {
|
||||
my $str = $sub->as_text();
|
||||
$str =~s/\s//;
|
||||
$str =~m/(.+)\/(.+)/;
|
||||
$vars{'power'} = $1;
|
||||
$vars{'toughness'} = $2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($id =~m/currentSetSymbol/) {
|
||||
my ($imgurl) = $div->look_down('_tag', 'img');
|
||||
$imgurl->attr('src') =~m/set=(\w+)\&.*rarity=(\w+)/;
|
||||
my $multiverseid = $multiverses[0];
|
||||
die "can't find set conversion for $1, multiverse: $multiverseid" unless defined $wizardstous{$1};
|
||||
my $set = $wizardstous{$1};
|
||||
$normalid{$set} = $multiverseid;
|
||||
}
|
||||
if ($id =~m/otherSetsValue/) {
|
||||
foreach my $sub ($div->look_down('_tag', 'a')) {
|
||||
my $link = $sub->attr('href');
|
||||
$link =~m/multiverseid\=(\d+)/;
|
||||
my $multiverseid = $1;
|
||||
my ($imgurl) = $sub->look_down('_tag', 'img');
|
||||
$imgurl->attr('src') =~m/set=(\w+)\&.*rarity=(\w+)/;
|
||||
die "can't find set conversion for $1, multiverse: $multiverseid" unless defined $wizardstous{$1};
|
||||
my $set = $wizardstous{$1};
|
||||
$normalid{$set} = $multiverseid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for my $set (@sets) {
|
||||
if (exists($knownSets{$set})) {
|
||||
$vars{'longset'} = $knownSets{$set};
|
||||
$vars{'rarity'} = $raritiesConversion{$rarities{$set}};
|
||||
$vars{'collector'} = $collectors{$set};
|
||||
$vars{'setcode'} = $set;
|
||||
my $result = $template->fill_in(HASH => \%vars);
|
||||
if (defined($result)) {
|
||||
my $filename = "../Mage.Sets/src/mage/sets/". $knownSets{$set} . "/" . $vars{'classname'} . ".java";
|
||||
if (-e $filename ) {
|
||||
print "WARNING $filename already exists!\n";
|
||||
} else {
|
||||
open CARD, "> $filename";
|
||||
print CARD $result;
|
||||
close CARD;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
26
Utils/gen-mtg-data.php
Normal file
26
Utils/gen-mtg-data.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
$filename = 'all.htm';
|
||||
$file = fopen($filename, 'r');
|
||||
$data = fread($file, filesize($filename));
|
||||
fclose($file);
|
||||
preg_match_all("/<td\r?\n? \r?\n?class=\"number\">(\d*?)<\/td>(.*?)Details.aspx\?multiverseid=(\d+)\"(.*?);\">(.*?)<\/a>(.*?)<td\r?\n? \r?\n?class=\"rarity\">(.{1})<\/td><td\r?\n? \r?\n?class=\"set\">(.*?)<\/td>/s", $data, $matches);
|
||||
preg_match_all("/Details.aspx?\?multiverseid=(\d+)/", $data, $ids);
|
||||
$filename = 'mtg-cards-data.txt';
|
||||
$file = fopen($filename, 'w');
|
||||
$data = array();
|
||||
$i = 0;
|
||||
foreach($matches[3] as $id){
|
||||
$data[$i] = array(str_replace("\r\n", '', $matches[5][$i]), str_replace("\r\n", '', $matches[8][$i]), $matches[7][$i], $matches[3][$i], $matches[1][$i]);
|
||||
@fwrite($file, "|".$data[$i][0]."|".$data[$i][1]."|".$data[$i][2]."|".$data[$i][3]."|".$data[$i][4]."|\n");
|
||||
$i++;
|
||||
$found = array_search($id, $ids[1]);
|
||||
if($found === FALSE)
|
||||
echo ''.$id."\n";
|
||||
else
|
||||
unset($ids[1][$found]);
|
||||
|
||||
}
|
||||
fclose($file);
|
||||
|
||||
print_r($ids[1]);
|
||||
?>
|
19057
Utils/mtg-cards-data.txt
Normal file
19057
Utils/mtg-cards-data.txt
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue