|
Games::WordGuess - a class for creating word-guessing game |
process_guess()in_progress()get_chances()get_score()init_mystery()
Games::WordGuess - a class for creating word-guessing game
use Games::WordGuess;
$game = new Games::WordGuess;
$game = new Games::WordGuess("/usr/games/lib/fortunes/startrek");
Games::WordGuess is a module for word-guessing game. Scoring is calculated from the number of chances left for each mystery word.
Specify the full path to the file containing words to be played at the
new() method, for example:
$game = new Games::WordGuess("/usr/games/lib/fortunes/startrek");
otherwise, Games::WordGuess uses some internal Indonesian words as the
default.
Look at examples/cmdln script on example of using command_interface().
process_guess()This is the core method. Passed a character, process_guess will return
undef if there's no matched character in the current mystery word. If it is
passed a previous matched character, it returns undef as well. On success,
it returns 0, or 1 if the mystery word has already revealed.
in_progress()Returns the mystery word in current player's progress. Initially, after a
Game::WordGuess object is created, this will return the mystery word
covered with asterisks. On each matched guess, the corresponding asterisk
will be substituted by the real character.
get_chances()Returns the remaining chances left for current player.
get_score()Returns total score for current player.
init_mystery()Provides a new mystery word to current player. Call to this method is required to continue the game after successful guess of one complete word.
process_guess() now returns undef on missed guess. Added in_progress() method.
Added documentation, and a CGI script example using Apache::Session.
Edwin Pratomo <ed.pratomo@computer.org>
Copyright (c) 1999 Edwin Pratomo <ed.pratomo@computer.org>.
All rights reserved. This is a free code; you can redistribute it and/or modify it under the same terms as Perl itself.
|
Games::WordGuess - a class for creating word-guessing game |