Games::Quake::Stats - Perl module for compiling basic Quake game statistics
use Games::Quake::Stats;
use strict; use Games::Quake::Stats; # NOTE: # # This example supposes you want to use this module in a CGI setting. # # # If you configure your quake-server to write a fraglog in the directory # where the quake-server is run, you can create a symbolic link from the # fraglog file to the file: /var/www/cgi-bin/fraglog.log (if that is where this # CGI application will reside). This code will then read the statistics data # from the *actual* file, while the quake-server deals only with a symbolically # linked file. # my $quake_stats = Stats->new(_frag_log => "/var/www/cgi-bin/fraglog.log", _stats_graph => "/var/www/html/stats/chart.jpg", _skill_graph => "/var/www/html/stats/skill.jpg"); # number of times player 'player1' has been scored against my $player1_fragged = $stats->times_fragged("player1"); # number of times player 'player1' has scored against 'player2' my $player_total = $stats->total_frags("player1", "player2"); # total frags player 'player1' has scored my $player_total = $stats->total_frags("player1"); # skill level of player 'player1' (total_scored/times_scored_against); my $player_skill = $stats->skill_level("player1"); # create graphs $quake_stats->generate_stats_graph(); # or, generate_stats_graph("/var/www/html/stats/stats.jpg"); $quake_stats->generate_skill_graph(); # If you are using this code as a CGI response: print "Content-type: text/html\r\n\r\n"; # Usually create graphs before calling this (as this example did above) $quake_stats->generate_html("http://www.youraddress.net/stats/"); exit (0);
This module provides simple mechanisms for collecting and displaying game statisitics for the Quake, Quake2, Quake2world, and Quake 3 games. It works by reading the fraglog file created by Quake servers.
You can specify the fraglog file when the object is constructed, the module compiles statistics for each player that appears in the log.
The Games::Quake::Stats module can create simple bar charts showing the relative statistics of each player, and can generate textual and pre-formed HTML output (HTML output shows the graphs created).
my $stats = Games::Quake::Stats->new(_frag_log => "/var/www/cgi-bin/fraglog.log", _stats_graph => "/var/www/html/stats/chart.jpg", _skill_graph => "/var/www/html/stats/skill.jpg");
$stats->initialize($log_filename);
Initializes the Stats object with a frag log filename.
$stats->generate_skills_graph($graph_filename);
Generate JPG graph file displaying player statistics.
Generate JPG graph file displaying player skill levels.
$stats->generate_html($base_url);
Generate HTML output using $base_url as the base URL for any images (such as the graphs you create with generate_stats_graph() and generate_skills_graph().
Generate textual statistics output.
my $skill_level = skill_level($player_name);
Returns the skill level of the player. Skill level is defined as (total frags)/(times fragged).
my $total_frags = total_frags($player_name);
Returns the number of frags a player has scored.
my $times_fragged = times_fragged($player_name); my $times_fragged = times_fragged($player_name1, $player_name2);
Returns the number of times a player has been fragged, or if a second player is provided, the number of times the first player has been fragged by the second.
At the moment the JPG graph generation can only accomodate about 10 or so players, due to a limitation on the number of colors for the bars in the chart. This will hopefully be addressed in a future release.
Test::More, Games::Quake::Player, GD::Graph::hbars, GD::Graph::colour
None by default.
The Quake2World game website, mantained by developer jdolan: www.quake2world.net. Or if you use IRC, try the #quetoo channel on irc.freenode.net.
Matthias Beebe, <matthiasbeebe@gmail.com>
Copyright (C) 2009 by Matthias Beebe
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.
To install Games::Quake::Stats, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Games::Quake::Stats
CPAN shell
perl -MCPAN -e shell install Games::Quake::Stats
For more information on module installation, please visit the detailed CPAN module installation guide.