NAME
Games::Die - a die; you can roll it!
VERSION
version 0.07.01
$Id: Die.pm,v 1.5 2004/10/19 03:52:28 rjbs Exp $
SYNOPSIS
$six_sided = new Games::Die(6);
$twenty_sided = new Games::Die();
$twenty_sided->sides(20);
$result = $six_sided->roll() + $twenty_sided->roll();
DESCRIPTION
Games::Die provides an object-oriented implementation of a die. The die may contain any number of sides, not just those for which a physical implementation is possible/feasible. You can create a 7-, 29-, or 341-sided die if the mood strikes you. There is no limit to the number of sides.
METHODS
new($sides)
This method creates and returns a new Die. The number of sides must be a non-negative integer.
sides
If called without an argument, returns the number of sides the current die has. If called with a numerical argument, sets the number of sides.
roll
Rolls the die and returns the number that came up.
TODO
more extensive validation of parameters
improved access to members of a Dice set
return results as a Results object; last results cached on the Dice
THANKS
...to Dave Ranney, for finding the stupid minus-one bug in roll() in 0.03
...to Thomas R. Sibley, for pointing out the poor roll() implementation in 0.02
AUTHORS
Andrew Burke <burke@bitflood.org
>
Jeremy Muhlich <jmuhlich@bitflood.org
>
Ricardo SIGNES <rjbs@cpan.org
>
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.