From 621223634c2cbe4935fee16de48fe0ac226f9af5 Mon Sep 17 00:00:00 2001 From: Loki Date: Fri, 26 Nov 2010 05:56:24 +0000 Subject: [PATCH] add script --- Utils/gen-collector-to-mtgo.pl | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Utils/gen-collector-to-mtgo.pl diff --git a/Utils/gen-collector-to-mtgo.pl b/Utils/gen-collector-to-mtgo.pl new file mode 100644 index 0000000000..425ff2b954 --- /dev/null +++ b/Utils/gen-collector-to-mtgo.pl @@ -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 () { + 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> mapping = new HashMap>();\n\n"; + print $out "\tstatic {\n\t\tHashMap set;\n"; +} + +sub print_set_start { + my ($set) = @_; + print $out "\t\tset = new HashMap();\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}"; +} \ No newline at end of file