NAME

Games::Dice::Result - what you get when you roll some dice

VERSION

version 0.99_01

$Id: Result.pm,v 1.1 2004/10/19 03:52:28 rjbs Exp $

SYNOPSIS

my $dice = Games::Dice->new("3d6");

# get a sorted list of 6 results
my @results = sort { $b->value <=> $a->value }
              map  { $dice->roll }
              (1 .. 6);

print "best roll: ",  join(' ', sort $results[0]->rolls), "\n";
print "worst roll: ", join(' ', sort $results[9]->rolls), "\n";

DESCRIPTION

Result objects are returned when the roll method is called on a Game::Dice set.

METHODS

Games::Dice::Result->new()

This method creates a new result. You shouldn't need to use it outside of Games::Dice classes.

It takes a rolls parameter, an arrayref of die values; an adjust parameter, an integer to add to the total or coderef to call on it; and a top parameter, the number of results to return (choosing the highest results first).

rolls

This returns a list of the die results.

all_rolls

This returns a list of the result of each die rolled, in the order the results were given to the constructor.

total

This returns the total of the rolls, plus the adjustment.

value

In list context, this calls rolls; otherwise, it calls total.

AUTHOR

Ricardo SIGNES, <rjbs@cpan.org>

BUGS

Please report any bugs or feature requests to bug-games-dice@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT

Copyright 2005, Ricardo SIGNES.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.