#! /usr/bin/perl -w # # Run as: crawl-glyphs mon-data.h > out.html use strict; # Use two rows for each glyph instead of just one. our $USE_TWO_ROWS = 1; our %COLOURS = ( BLACK => 0, BLUE => 1, GREEN => 2, CYAN => 3, RED => 4, MAGENTA => 5, BROWN => 6, LIGHTGRAY => 7, LIGHTGREY => 7, DARKGRAY => 8, DARKGREY => 8, LIGHTBLUE => 9, LIGHTGREEN => 10, LIGHTCYAN => 11, LIGHTRED => 12, LIGHTMAGENTA => 13, YELLOW => 14, WHITE => 15 ); our @COLNAMES = qw( black blue green cyan red magenta brown lightgrey darkgrey lightblue lightgreen lightcyan lightred lightmagenta yellow white elemental ); sub colcode($) { my $c=shift; return $COLOURS{uc($c)} || 16 } sub colname($) { my $c=shift; return $COLNAMES[$c] || "unknown"; } my %mons; while (<>) { chomp; next unless /MONS_.*'(.)', ([^,]*), "([^"]*)"/; my ($glyph, $colour, $name) = ($1,$2,$3); push @{$mons{$glyph}{colcode($colour)}}, $name; } print < EOF for my $c (1..16) { print ""; print "" if ($USE_TWO_ROWS and $c == 8); } print "\n"; for my $g (sort keys %mons) { my $g_h = $g; $g_h =~ s/\&/\&/g; printf "%s", ($USE_TWO_ROWS ? ' rowspan="2"' : ""), $g; for my $c (1..16) { printf ""; print "" if ($USE_TWO_ROWS and $c == 8); } print "" } print < EOF
" . colname($c) . "
", $c; if (exists $mons{$g}{$c}) { print join("
", @{$mons{$g}{$c}}) } else { print " "; } print "