NAME

Game::Lawn - Lawn

SYNOPSIS

Nah...

PROPERTIES

width

width

Default: 0

height

height coordinate

Default: 0

rhGrid

Hash ref with left->top->object hash ref tree.

Default: {}

oUI

Game::UI object, used to display the Lawn and stuff on it.

Default: undef

oController

Game::Controller object used to steer the game, or undef if there is no app.

Default: undef

rhPrize

Hash ref with (key: object string, value: Game::Object::Prize object). These are the Prizes the Lawn knows about.

Default: {}

METHODS

new([$width = 0, $height = 0])

Create new Lawn

oPlaceWorm($left, $top)

Place a new Worm on the Lawn, at the location $left/$top.

Return the new Game::Object::Worm object on success, else undef.

oPlacePrize($oLocation, $value)

Place a new Prize on the Lawn, at the location $left/$top.

Return the new Game::Object::Prize object on success, else undef.

prizeWasClaimedBy($oPrize, $oObject)

The $oPrize was claimed by $oObject. Remove the $oPrize. Notify the App and the UI.

Return 1 on success, else 0.

placeObjectAt($oObject)

Place a $oObject on the Lawn, at the object's oLocation().

Return 1 on success, else undef.

objectHasMoved($oObject)

Notify the Lawn that $oObject has moved to a new location on the Lawn, indicated by it's oLocation().

Check collisions and report to colliding objects.

Return 1 on success, else undef.

removeObject($oObject)

Remove the object from the Lawn.

Return 1 on success, else 0.

isObjectAt($oObject, $left, $top)

Is the $oObject on the Lawn, at the location $left/$top?

Return 1 if it is, else 0.

isAnythingAt($oLocation)

Is there an object on the Lawn, at the Location?

Return 1 if it is, else 0.

isAnythingBlockingAt($oLocation)

Is there a blocking object on the Lawn, at the Location?

Return 1 if it is, else 0.

oLocationRandom()

Return Game::Location object with a random Location on the Lawn.

isLocationOnLawn($oLocation)

Is the Location on the Lawn?

Return 1 if it is, else 0.

isLocationValidForMove($oObject, $oLocation)

Is the $oLocation a valid location for $oObject to move to?

Ignore the movement/speed/whatever of $oObject, the only concern is the validity of the Location in itself (whether it's occupied by something important).

Return 1 if it is, else 0.

isLocationValidForPlacement($oLocation)

Is the $oLocation a valid location for $oObject to be place at?

Ignore the movement/speed/whatever of $oObject, the only concern is the validity of the Location in itself (whether it's occupied by something).

Return 1 if it is, else 0.

isObjectLocationValidForPlacement($oObject)

Is the raBodyLocation of the $oObject valid for placement on the Lawn. The entire raBodyLocation of $oObject must be valid.

Return 1 if it is, else 0.

oDirectionToPrize($oLocation)

Is there any Prize located in a straight line from $oLocation? If so, return a Game::Direction object with the direction to the prize.

If there are many applicable Prizes, pick any.

Return the Game::Direction object on success, else undef.

placeObjectBodyPartAt($oObject, $oLocation, $char)

Put the $char of $oObject at $oLocation on the Lawn.

Return 1 on success, else 0.

removeObjectBodyPartAt($oObject, $oLocation)

Remove the $oObject at $oLocation on the Lawn.

Return 1 on success, else 0.

wormHasCrashed($oObject)

The worm $oObject has crashed.

Notify the UI.

Return 1 on success, else 0.