mirror of
https://github.com/correl/mage.git
synced 2024-12-27 03:00:13 +00:00
60 lines
No EOL
1.4 KiB
Perl
60 lines
No EOL
1.4 KiB
Perl
#!/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}";
|
|
} |