Mercurial > hg > batmud > misc
changeset 84:c3554f46ca49 misc
Add some CSS formatting flavour for output.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 24 Apr 2010 22:54:31 +0000 |
parents | e12c03b40e61 |
children | 9aa648df2366 |
files | magestats.pl |
diffstat | 1 files changed, 91 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/magestats.pl Sat Apr 24 17:35:26 2010 +0000 +++ b/magestats.pl Sat Apr 24 22:54:31 2010 +0000 @@ -45,8 +45,10 @@ ### ### Print out help if no arguments given ### +my $prog_name = "Magestats"; +my $prog_version = "0.5"; my $opt_mode = shift or die( -"Magestats v0.5 - BatMUD Mage guild statistics generator +"$prog_name v$prog_version - BatMUD Mage guild statistics generator Developed by Matti Hamalainen (Ggr \@ bat), <ccr\@tnsp.org> (C) Copyright 2010 Tecnic Software productions (TNSP) @@ -256,15 +258,83 @@ mlog(1, "Outputting stats HTML to '$filename'"); print OUT qq| -<html> +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <meta name="Generator" content="$prog_name version $prog_version" /> <title>Mage statistics</title> + <style type="text/css"> +body { + margin: 1em; + background-color: #353; + color: #cdc; +} + +body, p, ul, td, th { + font-family: Verdana, Arial, helvetica, sans-serif; + font-size: 10pt; +} + +a, a:visited, a:active { + text-decoration: underline; + color: #fc0; +} + +a:hover { + text-decoration: none; + background-color: black; + color: white; +} + +.icenter { + text-align: center; +} + +.noborder { + border: none; + padding: 0pt; +} + +h1, h2, h3 { + font-family: Arial, sans-serif; + font-weight: normal; + color: #efe; + background: #575; + padding: 4px; + padding-bottom: 8px; + text-shadow: 2px 2px 2px #000; + border-bottom: 2px solid #242; +} + +th { + padding: 2px; + margin: 2px; + background: #575; + color: #fc0; + text-align: center; +} + +td { + padding: 4px; + margin: 2px; + background: #242; +} + +table.blasts { + background: #464; +} + + </style> </head> <body> <h1>Mage statistics</h1> - -<table border=\"1\"> +<p> +Generated with $prog_name v$prog_version by Matti Hämäläinen aka Ggr Pupunen. +</p> +<table class="info"> <tr> <th>Type</th> <th>Blasts</th> @@ -284,21 +354,21 @@ my $b_s = $spells->{$s_s}{"blasts"}; my $b_a = $spells->{$s_a}{"blasts"}; - $major_blasts += $b_s + $b_a; + my $total_blasts = $b_s + $b_a; + $major_blasts += $total_blasts; print OUT "<tr><td>$type</td><td> - <table border=\"1\"><th></th><th>Single</th><th>Area</th></tr> + <table class=\"blasts\"><th></th><th>Single</th><th>Area</th></tr> <tr><th>Name</th><td>$s_s</td><td>$s_a</td></tr> <tr><th>Blasts</th><td>".$b_s."</td><td>".$b_a."</td></tr> - </table>"; + <tr><th>Total</th><td colspan=\"2\">".$total_blasts."</td></tr>"; foreach my $crit (@crit_types) { - print OUT "$crit: <b>".$spells->{$type}{"crits"}{$crit}."</b><br />\n"; + print OUT "<tr><th>$crit</th><td colspan=\"2\">".$spells->{$type}{"crits"}{$crit}."</td></tr>\n"; } - my $total_blasts = $b_s + $b_a; - printf OUT "</td><td><b>%d</b> (%1.2f %%)</td><td>%d</td><td>", + printf OUT "</table></td><td><b>%d</b> (%1.2f %%)</td><td>%d</td><td>", $spells->{$type}{"reagents"}, ($total_blasts > 0) ? ($spells->{$type}{"reagents"} * 100.0) / $total_blasts : 0.0, $spells->{$type}{"essence"}{"increase"}; @@ -318,7 +388,13 @@ <p> Total major blasts: <b>".$major_blasts."</b><br /> Total blasts: <b>".$spells->{"total"}{"blasts"}."</b> (including minor)<br /> -Total reagents saved: <b>".$spells->{"total"}{"reagents"}."</b><br /> +Total reagents saved: <b>".$spells->{"total"}{"reagents"}."</b>"; + +if ($spells->{"total"}{"reagents"} > 0) { + printf OUT " (<b>%1.2f%%</b> of blasts)", ($spells->{"total"}{"reagents"} * 100.0) / $major_blasts; +} + +print OUT "<br /> Total essence gained: <b>".$spells->{"total"}{"essence"}."</b><br /> </p> @@ -336,22 +412,23 @@ $graph->set( y_label => 'Blasts', x_label => 'Essence gained', + show_values => 1, + transparent => 0, + bgclr => 'white', ); my @titles = (); - my @total = (); for (my $i = 1; $i <= $spells->{$type}{"essence"}{"increase"}; $i++) { push(@titles, "+".$i); } + my @total = (); for (my $i = 0; $i < $spells->{$type}{"essence"}{"increase"}; $i++) { push(@total, $spells->{$type}{"essence"}{"blasts"}{"single"}[$i] + $spells->{$type}{"essence"}{"blasts"}{"area"}[$i]); } my @data = ( \@titles, - $spells->{$type}{"essence"}{"blasts"}{"single"}, - $spells->{$type}{"essence"}{"blasts"}{"area"}, \@total, );