| Next: Net::StarezServer::HTTPClient | Previous: Net::StarezServer::Files | [Table of Contents] |
Net::StarezServer::Games - Serve Starez game lists
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.
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:
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.
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.
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.
This method takes a game entry and a filter and returns 1 or 0 depending on if the game entry matched or not.
See the Net::StarezServer::BaseSQLModule documentation.
Net::StarezServer::BaseSQLModule
Written by Sjors Gielen <dazjorz@starez.org>