NAME

Games::Wumpus::Cave - Cave used for Hunt the Wumpus

SYNOPSIS

my $cave = Games::Wumpus::Cave -> new -> init;

$survivor = $cave -> move  ($location);
@hazards  = $cave -> shoot (@path);

DESCRIPTION

Games::Wumpus::Cave is used to keep track of the cave system of Hunt the Wumpus. It's used by Games::Wumpus and should most likely not be used outside of Games::Wumpus.

The following methods are implemented:

new

Class method returning an unintialized object.

init

Initializes the cave system. Creates layout mimicing a dodecahedron: vertices are rooms, and edged are tunnels. After creating the layout, hazards (Wumpus, bats, pits) are randomly placed in the cave system. Then a start location is picked. The start location is garanteed not to contain a hazard.

rooms

Accessor returning all rooms in the cave system.

room

Accessor returning room with the given name (small, non-negative integer).

random_room

Accessor returning a random room from the cave system.

location

Accessor returning the current location (room) of the player.

set_location

Accessor setting the current location of the player.

wumpus

Accessor returning the location of the Wumpus.

set_wumpus

Accessor setting the location of the Wumpus.

start

Accessor returning the start location of the player.

describe

Describes the location the player is currently in, including outgoing tunnels, and nearby hazards. The description is returned as a string.

can_move_to

Takes a location as argument. Returns true if there's a tunnel from the players current location to the given location, false otherwise.

move

Move the player to the location given as argument. If the new location contains a bat, the player is dropped in a random location elsewhere in the cave system. Returns a (possibly empty) list of hazards encountered. If the list is non-empty, the last element of the list is either $WUMPUS or $PIT; all other elements must be $BAT.

shoot

Shoot an arrow from the players current location following the given path. Returns false if not hitting anything; the object hit ($WUMPUS or $PLAYER) otherwise. If the path contains a room which cannot be reached using a tunnel from the arrows current location, a random tunnel will be choosen.

stir_wumpus

Poke the Wumpus. With a certain chance ($WUMPUS_MOVES), the Wumpus picks a random tunnel and moves to the room at the other end. Returns true if the Wumpus moved, false otherwise.

BUGS

None known.

TODO

Configuration of the game should be possible.

SEE ALSO

Games::Wumpus, Games::Wumpus::Room, Games::Wumpus::Constants

DEVELOPMENT

The current sources of this module are found on github, git://github.com/Abigail/Games--Wumpus.git.

AUTHOR

Abigail, mailto:wumpus@abigail.be.

COPYRIGHT and LICENSE

Copyright (C) 2009 by Abigail.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

INSTALLATION

To install this module, run, after unpacking the tar-ball, the following commands:

perl Makefile.PL
make
make test
make install