Next:
Net::StarezServer::HTTPClient
Previous:
Net::StarezServer::Files
 [Table of Contents]

Net::StarezServer::Games



NAME

Net::StarezServer::Games - Serve Starez game lists

DESCRIPTION

Net::StarezServer::Games is the module that takes care of the Starez game lists. When a request for one of these game lists arrives, Client.pm just gives it on to Games.pm, which takes it from the database and returns it nicely formatted into a Perl variable hierarchy.

SQL TABLES REQUIRED

Games.pm saves the user data in the database using Database.pm. It assumes the database is MySQL (in SQL syntax) and that a table with the name 'games' exists with at least these elements:

gamename - The (short) name of the game.
gamecat (SET type) - Category names. Multiple categories can be devided by a '|', for example, 'action|racing'.
Additional elements are required by other modules:
gameid (INT PRIMARY KEY AUTO_INCREMENT) - Used to identify this game easily
gameabout (TEXT) - A short (one-line?) description of the game.
gamedescr (LONGTEXT) - A long, complete description of the game.
gamestatus (ENUM) - Status of the game: 'planned', 'alpha', 'private-beta', 'beta', 'released' or 'abandoned'.
gameversion (VARCHAR) - The latest version of the game (must be in 'versions' table)
Next to that, a table 'versions' must exist, with these elements:
gameid (INT INDEX) - Version belongs to this game
gameversion (VARCHAR) - Name of the version (0.5-starez0.3~0.72)
gamefileid (INT) - File ID of the game file for this version of this game

FILTER SYNTAX

TODO TODO TODO TODO

This module uses game filters, criteria to which a game does or doesn't match. Multiple filters can be given by dividing them by two '|' characters:

   filter||filter||filter||filter

A filter consists of a type name, such as 'name', 'description' or 'version', and then a '/' character, followed by search statement, followed by another '/'. A search statement is as in SQL (or MySQL) syntax. See http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html for more information. (This includes '%' and '_' as wildcards).

   version/1.0.0/     # All games which have version 1.0.0
   name/stratego/      # All games whose name is 'stratego'
   description/science fiction/
                        # All games that have 'science fiction' in their description
   author/Hylke Donker/ # All games made by Hylke Donker

A game matches to a filter consisting of multiple filters (using ||), if it matches to all subfilters. For example, a game by Hylke Donker of version 1.0.0 matches to

   author/Hylke Donker/||version/1.0.0/

but it does not match to

   author/Sjors Gielen/||version/1.0.0/

(eventhough the version is the same).

Note, also, that a user might cause the client to send '||' inside the regex. If so, make sure they are properly escaped (\|\|) - this does not only count for '|', make sure any metacharacter is properly escaped if you don't want it to function as a metacharacter in the query.

METHODS

getGameList ($filter, $return, $server)

This method gets a list of games from the database, checks them against the filter, and returns the ones that matched. It then calls the return subroutine with a list of games that matched.

For Database.pm, this method also wants the main server alias as the last argument.

getGameVersion ($gameid, $versionid, $return, $server)

This method wants a game and a version ID. It will get the version information from the server and then call the return subroutine with the result.

If the version wasn't found, the return subroutine will be called with an empty @_, if an error occured the first element will be undef and the second argument will be the error that the database returned. If all went as planned, @_ will contain a hashref as the first argument, with elements from the 'version' table (gameid, versionid and gamefileid).

For Database.pm, this method also wants the main server alias as the last argument.

testFilter ($game, $filter)

This method takes a game entry and a filter and returns 1 or 0 depending on if the game entry matched or not.

INTERNAL METHODS

queryComplete ($name, $data, $callback)

See the Net::StarezServer::BaseSQLModule documentation.

SEE ALSO

Net::StarezServer::BaseSQLModule

AUTHOR

Written by Sjors Gielen <dazjorz@starez.org>


[Top] Generated by Marek::Pod::HTML 0.49 on Wed Jun 25 20:02:24 2008