Mercurial > hg > batmud > misc
changeset 19:3f5b8222255c misc
Add generation of reverse alloy table.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 16 Apr 2009 20:02:39 +0000 |
parents | f9376ab3b366 |
children | 82d447306f36 |
files | parsealloys.pl |
diffstat | 1 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/parsealloys.pl Thu Apr 16 17:05:32 2009 +0000 +++ b/parsealloys.pl Thu Apr 16 20:02:39 2009 +0000 @@ -100,6 +100,35 @@ print "),\n"; } + print ");\n\n"; + + # Create 'reverse' alloy table + my %restab = (); + foreach my $res (@alloyNameTable) { + foreach my $min1 (keys %final) { + foreach my $min2 (keys %{$final{$min1}}) { + if ($final{$min1}{$min2} eq $res && !defined($restab{$res}{$min1}{$min2}) && !defined($restab{$res}{$min2}{$min1})) { + $restab{$res}{$min1}{$min2} = 1; + } + } + } + } + + print "\$alloyRevTable = array(\n"; + foreach my $res (sort { $a cmp $b } keys %restab) { + print " \"$res\" => array(\n"; + foreach my $min1 (sort { $a cmp $b } keys %{$restab{$res}}) { + if (scalar keys %{$restab{$res}{$min1}} > 0) { + print " \"$min1\" => array("; + foreach my $min2 (sort { $a cmp $b } keys %{$restab{$res}{$min1}}) { + print "\"$min2\","; + } + print "),\n"; + } + } + print " ),\n"; + } + print ");\n\n". "?>"; } else {