GameController

Extends\CController

GameController implements the {@link https://en.wikipedia.org/wiki/Hangman_(game) Hangman game}.

author

Qiang Xue qiang.xue@gmail.com

version

$Id: CController.php 131 2008-11-02 01:32:57Z qiang.xue $

package

demos.hangman

since 1.0

Methods

The 'guess' action.

actionGiveup()

This action is invoked when the user gives up the game.

The 'guess' action.

actionGuess()

This action is invoked each time when the user makes a guess.

The 'play' action.

actionPlay()

In this action, users are asked to choose a difficulty level of the game.

Generates a word to be guessed.

generateWord(): string

Response

string

the word to be guessed

getGuessWord

getGuessWord(): string

Response

string

the word being guessed. This value is persistent during the whole game session.

getLevel

getLevel(): integer

Response

integer

the difficulty level. This value is persistent during the whole game session.

getMisses

getMisses(): integer

Response

integer

the number of misses. This value is persistent during the whole game session.

getWord

getWord(): string

Response

string

the word to be guessed. This value is persistent during the whole game session.

Checks to see if a letter is guessed correctly.

guess( $letter): mixed

Arguments

$letter

Response

mixed

true if the word is guessed correctly, false if the user has used up all guesses and the word is guessed incorrectly, and null if the letter is guessed correctly but the whole word is guessed correctly yet.

Checks to see if a letter is already guessed.

isGuessed( $letter): boolean

Arguments

$letter

Response

boolean

whether the letter is already guessed.

setGuessWord

setGuessWord( $value)

Arguments

$value

setLevel

setLevel( $value)

Arguments

$value

setMisses

setMisses( $value)

Arguments

$value

setWord

setWord( $value)

Arguments

$value

Properties

sets the default action to be 'play'

defaultAction :string
var

sets the default action to be 'play'

Type(s)

string