Games::Baseball::Scorecard 0.03 review

Download
by rbytes.net on

Games::Baseball::Scorecard is a Perl module. SYNOPSIS my $score = Games::Baseball::Scorecard->new($dir, $name, {

License: GPL (GNU General Public License)
File size: 339K
Developer: Chris Nandor
0 stars award from rbytes.net

Games::Baseball::Scorecard is a Perl module.

SYNOPSIS

my $score = Games::Baseball::Scorecard->new($dir, $name, {
color => [ .4, .4, .4 ], # grey
fonts => [ # Myriad Condensed regular/bold
[ myriadrcrrl => 9 ],
[ myriadrcbrl => 14 ],
[ myriadrcrrl => 14 ],
[ myriadrcbrl => 22 ],
],
});

# fill initial scorecard out
$s->init({
scorer => 'Pudge',
date => '2004-10-24, 20:05-23:25',
at => 'Fenway Park, Boston',
temp => '48 clear',
wind => '7 to RF',
att => '35,001',
home => {
team => 'Boston Red Sox',
starter => 38, # jersey number
lineup => [
# [ num, position ],
[ 18, 8 ], # Damon, starting at CF
# ...
],
roster => {
# num => name
18 => 'Damon, Johnny',
38 => 'Schilling, Curt',
# ...
},
},
away => {
team => 'St. Louis Cardinals',
# ...
}
});

# draw the game
$s->inn; # new inning / end of last inning

$s->ab; # new at-bat
# works to full count
$s->pitches(qw(s b s b b f));
# struck out looking
$s->out('!K');

$s->ab;
# home run to left-center
$s->hit(4, 'lc');

# calculate/draw stats
$self->totals;

# finish the job
$s->generate;

# open final PDF
$s->pdfopen;

Games::Baseball::Scorecard is a frontend to a PDF scorecard written in Metapost by Christopher Swingley (http://www.frontier.iarc.uaf.edu/~cswingle/baseball/scorecards.php). That scorecard is drawn out, and has a nice API for actually drawing out the elements of the game: all the ball, strikes, outs, etc.

Being Metapost, it is laborious to do all this. So this module provides a nice frontend, that also keeps track of balls and strikes and hits and runs and outs and more, making input of the game quite simple and efficient.

This module does not include the entire API, but most of it. Patches and ideas welcome. Feel free to call output directly if you want to generate Metapost on your own, or to modify the $SCORECARD variable (which contains the base Metapost code), or the $TEX (single page) and $TEXD (duplex) TeX files.

I won't give a tutorial on scoring baseball games, or on Metapost, below. Seek other resources (Swingley's URL above has a nice tutorial on scoring baseball games, using the scorecard he designed, which is what we're using here).

Games::Baseball::Scorecard 0.03 keywords