NAME

Games::Bowling::Scorecard::Frame - one frame on a scorecard

VERSION

version 0.106

DESCRIPTION

A frame is one attempt to knock down all ten pins -- unless it's the tenth frame, in which case it's so goofy that you need to use a different class, Games::Bowling::Scorecard::Frame::TenPinTenth. A frame is done when you've bowled twice or knocked down all the pins, and it's pending until its score can be definitively be stated.

PERL VERSION

This module should work on any version of perl still receiving updates from the Perl 5 Porters. This means it should work on any version of perl released in the last two to three years. (That is, if the most recently released version is v5.40, then this module should work on both v5.40 and v5.38.)

Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.

METHODS

new

This method returns a new frame object.

record

$frame->record($ball, \%arg);

This method records a single ball against the frame. This method is used for both the current frame and for pending frames. It updates the frame's score and whether the frame is done or pending.

The only valid argument in %arg is split. If true, it indicates the pins are split. This can only be passed on the first ball of a frame.

roll_ok

$frame->roll_ok($ball);

This method asserts that given value is an acceptable number to score next in this frame. It checks that:

* the frame is not already done
* $ball is defined, an integer, and between 0 and 10
* $ball would not bring the total number of pins downed above 10

score

This method returns the current score for the frame, even if the frame is not done or is pending further balls.

is_pending

This method returns true if the frame is pending more balls -- that is, it returns true for strikes or spares which have not yet recorded the results of subsequent balls.

is_done

This method returns true if the frame is done.

balls

This method returns the balls recorded against the frame, each ball returned as the number of pins it knocked down. In scalar context, it returns the number of balls recoded against the frame.

AUTHOR

Ricardo SIGNES <cpan@semiotic.systems>

COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by Ricardo SIGNES.

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