mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Script for generating existing cards for a specific set.
This commit is contained in:
parent
965a047c28
commit
614a8098ef
4 changed files with 284 additions and 0 deletions
52
Utils/cardExtendedClass.tmpl
Normal file
52
Utils/cardExtendedClass.tmpl
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* 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 North
|
||||||
|
*/
|
||||||
|
public class [=$className=] extends mage.sets.[=$baseSet=].[=$baseClassName=] {
|
||||||
|
|
||||||
|
public [=$className=](UUID ownerId) {
|
||||||
|
super(ownerId);
|
||||||
|
this.cardNumber = [=$cardNumber=];
|
||||||
|
this.expansionSetCode = "[=$expansionSetCode=]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public [=$className=](final [=$className=] card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public [=$className=] copy() {
|
||||||
|
return new [=$className=](this);
|
||||||
|
}
|
||||||
|
}
|
103
Utils/gen-existing-cards-by-set.pl
Normal file
103
Utils/gen-existing-cards-by-set.pl
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
use Text::Template;
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
my $dataFile = "mtg-cards-data.txt";
|
||||||
|
my $setsFile = "mtg-sets-data.txt";
|
||||||
|
my $knownSetsFile = "known-sets.txt";
|
||||||
|
|
||||||
|
my %cards;
|
||||||
|
my %sets;
|
||||||
|
my %knownSets;
|
||||||
|
my @setCards;
|
||||||
|
|
||||||
|
print "Enter a set name: ";
|
||||||
|
my $setName = <STDIN>;
|
||||||
|
chomp $setName;
|
||||||
|
|
||||||
|
my $template = Text::Template->new(SOURCE => 'cardExtendedClass.tmpl', DELIMITERS => [ '[=', '=]' ]);
|
||||||
|
|
||||||
|
sub getClassName {
|
||||||
|
my $string = $_[0];
|
||||||
|
$string =~ s/\b(\w+)\b/ucfirst($1)/ge;
|
||||||
|
$string =~ s/[, ]//g;
|
||||||
|
$string;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub getOldClassName {
|
||||||
|
my $string = $_[0];
|
||||||
|
$string =~ s/[, ]//g;
|
||||||
|
$string;
|
||||||
|
}
|
||||||
|
|
||||||
|
open (DATA, $dataFile) || die "can't open $dataFile";
|
||||||
|
while(my $line = <DATA>) {
|
||||||
|
my @cardData = split('\\|', $line);
|
||||||
|
|
||||||
|
$cards{$cardData[1]}{$cardData[2]} = \@cardData;
|
||||||
|
|
||||||
|
if ($cardData[2] eq $setName) {
|
||||||
|
push(@setCards, $cardData[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close(DATA);
|
||||||
|
|
||||||
|
open (DATA, $setsFile) || die "can't open $setsFile";
|
||||||
|
while(my $line = <DATA>) {
|
||||||
|
my @setData = split('\\|', $line);
|
||||||
|
$sets{$setData[0]}= \@setData;
|
||||||
|
}
|
||||||
|
close(DATA);
|
||||||
|
|
||||||
|
open (DATA, $knownSetsFile) || die "can't open $knownSetsFile";
|
||||||
|
while(my $line = <DATA>) {
|
||||||
|
my @setData = split('\\|', $line);
|
||||||
|
$knownSets{$setData[0]}= $setData[2];
|
||||||
|
}
|
||||||
|
close(DATA);
|
||||||
|
|
||||||
|
|
||||||
|
my %vars;
|
||||||
|
$vars{'set'} = $knownSets{$setName};
|
||||||
|
$vars{'expansionSetCode'} = $sets{$setName}[1];
|
||||||
|
|
||||||
|
foreach my $cardName (@setCards) {
|
||||||
|
my $className = getClassName($cardName);
|
||||||
|
my $currentFileName = "../Mage.Sets/src/mage/sets/" . $knownSets{$setName} . "/" . $className . ".java";
|
||||||
|
|
||||||
|
if(! -e $currentFileName) {
|
||||||
|
$vars{'className'} = $className;
|
||||||
|
$vars{'cardNumber'} = $cards{$cardName}{$setName}[5];
|
||||||
|
|
||||||
|
my $found = 0;
|
||||||
|
foreach my $key (keys %{$cards{$cardName}}) {
|
||||||
|
if (exists $knownSets{$key} && $found eq 0) {
|
||||||
|
my $fileName = "../Mage.Sets/src/mage/sets/" . $knownSets{$key} . "/" . $className . ".java";
|
||||||
|
if(-e $fileName) {
|
||||||
|
open (DATA, $fileName);
|
||||||
|
while(my $line = <DATA>) {
|
||||||
|
if ($line =~ /extends CardImpl<(\w+?)>/) {
|
||||||
|
$vars{'baseClassName'} = $1;
|
||||||
|
$vars{'baseSet'} = $knownSets{$key};
|
||||||
|
$found = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(DATA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($found eq 1) {
|
||||||
|
#print $vars{'set'} . "|" . $vars{'baseSet'} . "|" . $vars{'className'} . "|" . $vars{'baseClassName'} . "|" . $vars{'expansionSetCode'} . "\n";
|
||||||
|
my $result = $template->fill_in(HASH => \%vars);
|
||||||
|
if (defined($result)) {
|
||||||
|
#print $result;
|
||||||
|
open CARD, "> $currentFileName";
|
||||||
|
print CARD $result;
|
||||||
|
close CARD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
Utils/known-sets.txt
Normal file
24
Utils/known-sets.txt
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
Alara Reborn|ARB|alarareborn|
|
||||||
|
Apocalypse|APC|apocalypse|
|
||||||
|
Conflux|CON|conflux|
|
||||||
|
Darksteel|DST|darksteel|
|
||||||
|
Eventide|EVE|eventide|
|
||||||
|
Magic 2010|M10|magic2010|
|
||||||
|
Magic 2011|M11|magic2011|
|
||||||
|
Magic 2012|M12|magic2012|
|
||||||
|
Planechase|HOP|planechase|
|
||||||
|
Ravnica: City of Guilds|RAV|ravnika|
|
||||||
|
Rise of the Eldrazi|ROE|riseoftheeldrazi|
|
||||||
|
Shards of Alara|ALA|shardsofalara|
|
||||||
|
Tenth Edition|10E|tenth|
|
||||||
|
Worldwake|WWK|worldwake|
|
||||||
|
Zendikar|ZEN|zendikar|
|
||||||
|
Scars of Mirrodin|SOM|scarsofmirrodin|
|
||||||
|
Guildpact|GPT|guildpact|
|
||||||
|
Dissension|DIS|dissension|
|
||||||
|
Mirrodin|MRD|mirrodin|
|
||||||
|
Duel Decks: Elspeth vs. Tezzeret|DDF|elspethvstezzeret|
|
||||||
|
Mirrodin Besieged|MBS|mirrodinbesieged|
|
||||||
|
New Phyrexia|NPH|newphyrexia|
|
||||||
|
Tempest|TMP|tempest|
|
||||||
|
Champions of Kamigawa|CHK|championsofkamigawa|
|
105
Utils/mtg-sets-data.txt
Normal file
105
Utils/mtg-sets-data.txt
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
Tenth Edition|10E|
|
||||||
|
Unlimited Edition|2ED|
|
||||||
|
Revised Edition|3ED|
|
||||||
|
Fourth Edition|4ED|
|
||||||
|
Fifth Dawn|5DN|
|
||||||
|
Fifth Edition|5ED|
|
||||||
|
Classic Sixth Edition|6ED|
|
||||||
|
Seventh Edition|7ED|
|
||||||
|
Eighth Edition|8ED|
|
||||||
|
Alliances|ALL|
|
||||||
|
Apocalypse|APC|
|
||||||
|
Alara Reborn|ARB|
|
||||||
|
Arabian Nights|ARN|
|
||||||
|
Anthologies|ATH|
|
||||||
|
Antiquities|ATQ|
|
||||||
|
Betrayers of Kamigawa|BOK|
|
||||||
|
Battle Royale Box Set|BRB|
|
||||||
|
Beatdown Box Set|BTD|
|
||||||
|
Champions of Kamigawa|CHK|
|
||||||
|
Chronicles|CHR|
|
||||||
|
Conflux|CON|
|
||||||
|
Coldsnap|CSP|
|
||||||
|
Darksteel|DST|
|
||||||
|
Dissension|DIS|
|
||||||
|
Deckmasters|DKM|
|
||||||
|
The Dark|DRK|
|
||||||
|
Duel Decks: Divine vs. Demonic|DVD|
|
||||||
|
Duel Decks: Elves vs. Goblins|EVG|
|
||||||
|
Duel Decks: Garruk vs. Liliana|GVL|
|
||||||
|
Duel Decks: Jace vs. Chandra|JVC|
|
||||||
|
Duel Decks: Phyrexia vs. the Coalition|PVC|
|
||||||
|
Eventide|EVE|
|
||||||
|
Exodus|EXO|
|
||||||
|
Fallen Empires|FEM|
|
||||||
|
Future Sight|FUT|
|
||||||
|
From the Vault: Dragons|FVD|
|
||||||
|
From the Vault: Exiled|FVE|
|
||||||
|
Guildpact|GPT|
|
||||||
|
Homelands|HML|
|
||||||
|
Planechase|HOP|
|
||||||
|
Ice Age|ICE|
|
||||||
|
Invasion|INV|
|
||||||
|
Judgment|JUD|
|
||||||
|
Limited Edition Alpha|LEA|
|
||||||
|
Limited Edition Beta|LEB|
|
||||||
|
Legends|LEG|
|
||||||
|
Legions|LGN|
|
||||||
|
Lorwyn|LRW|
|
||||||
|
Magic 2010|M10|
|
||||||
|
Magic 2011|M11|
|
||||||
|
Magic 2012|M12|
|
||||||
|
Masters Edition II|ME2|
|
||||||
|
Masters Edition III|ME3|
|
||||||
|
Masters Edition IV|ME4|
|
||||||
|
Masters Edition|MED|
|
||||||
|
Mirage|MIR|
|
||||||
|
Mercadian Masques|MMQ|
|
||||||
|
Morningtide|MOR|
|
||||||
|
Mirrodin|MRD|
|
||||||
|
Ninth Edition|9ED|
|
||||||
|
Nemesis|NEM|
|
||||||
|
Odyssey|ODY|
|
||||||
|
Onslaught|ONS|
|
||||||
|
Portal Second Age|PO2|
|
||||||
|
Prophecy|PCY|
|
||||||
|
Planar Chaos|PLC|
|
||||||
|
Planeshift|PLS|
|
||||||
|
Portal|POR|
|
||||||
|
Portal Three Kingdoms|PTK|
|
||||||
|
Premium Deck Series: Fire and Lightning|PD2|
|
||||||
|
Premium Deck Series: Slivers|PDS|
|
||||||
|
Ravnica: City of Guilds|RAV|
|
||||||
|
Rise of the Eldrazi|ROE|
|
||||||
|
Starter 2000|S00|
|
||||||
|
Starter 1999|S99|
|
||||||
|
Scourge|SCG|
|
||||||
|
Shadowmoor|SHM|
|
||||||
|
Shards of Alara|ALA|
|
||||||
|
Saviors of Kamigawa|SOK|
|
||||||
|
Stronghold|STH|
|
||||||
|
Tempest|TMP|
|
||||||
|
Torment|TOR|
|
||||||
|
Time Spiral "Timeshifted"|TSB|
|
||||||
|
Time Spiral|TSP|
|
||||||
|
Urza's Destiny|UDS|
|
||||||
|
Unglued|UGL|
|
||||||
|
Urza's Legacy|ULG|
|
||||||
|
Unhinged|UNH|
|
||||||
|
Urza's Saga|USG|
|
||||||
|
Vanguard Set 1|VG1|
|
||||||
|
Vanguard Set 2|VG2|
|
||||||
|
Vanguard Set 3|VG3|
|
||||||
|
Vanguard Set 4|VG4|
|
||||||
|
MTGO Vanguard|VGO|
|
||||||
|
Visions|VIS|
|
||||||
|
Weatherlight|WTH|
|
||||||
|
Worldwake|WWK|
|
||||||
|
Zendikar|ZEN|
|
||||||
|
Archenemy|ARC|
|
||||||
|
Scars of Mirrodin|SOM|
|
||||||
|
From the Vault: Relics|FVR|
|
||||||
|
Duel Decks: Elspeth vs. Tezzeret|DDF|
|
||||||
|
Mirrodin Besieged|MBS|
|
||||||
|
New Phyrexia|NPH|
|
||||||
|
Magic: The Gathering-Commander|CMD|
|
Loading…
Reference in a new issue