mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
add script
This commit is contained in:
parent
3b1696d8f0
commit
621223634c
1 changed files with 60 additions and 0 deletions
60
Utils/gen-collector-to-mtgo.pl
Normal file
60
Utils/gen-collector-to-mtgo.pl
Normal file
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
|
||||
opendir SETS, "sets/";
|
||||
|
||||
my $out;
|
||||
|
||||
open $out, "> ImagesMapping.java";
|
||||
|
||||
print_header();
|
||||
|
||||
while (readdir SETS) {
|
||||
my $filename = $_;
|
||||
if ($filename =~m/s?(.+).txt/) {
|
||||
my $set = uc($1);
|
||||
print "processing $set\n";
|
||||
print_set_start($set);
|
||||
open FILE, "< sets/$filename";
|
||||
my $lastcollector = -1;
|
||||
my $lastimage = -1;
|
||||
while (<FILE>) {
|
||||
if (m/image:(\d+)/) {
|
||||
$lastimage = $1;
|
||||
} elsif (m/card No:(\d+)/) {
|
||||
$lastcollector = $1;
|
||||
} elsif (m/------------------------------/) {
|
||||
if ($lastcollector != -1) {
|
||||
print_card($lastcollector, $lastimage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print_footer();
|
||||
close $out;
|
||||
|
||||
sub print_header {
|
||||
print $out "// WARNING! THIS FILE ARE GENERATED BY A SCRIPT\n";
|
||||
print $out "package mage.client.cards;\n\n";
|
||||
print $out "import java.util.HashMap;\n";
|
||||
print $out "public class ImagesMapping {\n";
|
||||
print $out "\tpublic final static HashMap<String, HashMap<Integer, String>> mapping = new HashMap<String, HashMap<Integer, String>>();\n\n";
|
||||
print $out "\tstatic {\n\t\tHashMap<Integer, String> set;\n";
|
||||
}
|
||||
|
||||
sub print_set_start {
|
||||
my ($set) = @_;
|
||||
print $out "\t\tset = new HashMap<Integer, String>();\n\t\tmapping.put(\"$set\", set);\n";
|
||||
}
|
||||
|
||||
sub print_card {
|
||||
my ($cid, $mtgo) = @_;
|
||||
print $out "\t\tset.put($cid, \"" . $mtgo . "_typ_reg_sty_010.jpg\");\n";
|
||||
}
|
||||
|
||||
sub print_footer {
|
||||
print $out "\t}\n}";
|
||||
}
|
Loading…
Reference in a new issue