Games::Wumpus::Cave - Cave used for Hunt the Wumpus
my $cave = Games::Wumpus::Cave -> new -> init; $survivor = $cave -> move ($location); @hazards = $cave -> shoot (@path);
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
The following methods are implemented:
Class method returning an unintialized object.
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.
Accessor returning all rooms in the cave system.
Accessor returning room with the given name (small, non-negative integer).
Accessor returning a random room from the cave system.
Accessor returning the current location (room) of the player.
Accessor setting the current location of the player.
Accessor returning the location of the Wumpus.
Accessor setting the location of the Wumpus.
Accessor returning the start location of the player.
Describes the location the player is currently in, including outgoing tunnels, and nearby hazards. The description is returned as a string.
Takes a location as argument. Returns true if there's a tunnel from the players current location to the given location, false otherwise.
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
$PIT; all other elements must be
Shoot an arrow from the players current location following the given path. Returns false if not hitting anything; the object hit (
$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.
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.
Configuration of the game should be possible.
The current sources of this module are found on github, git://github.com/Abigail/Games--Wumpus.git.
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.
To install this module, run, after unpacking the tar-ball, the following commands:
perl Makefile.PL make make test make install