NAME
Game::Cribbage::Play::Score - score object for a single card play
VERSION
Version 0.12
SYNOPSIS
use Game::Cribbage::Play::Score;
my $score = Game::Cribbage::Play::Score->new(
player => 'player1',
card => $card,
);
# after calculate_pair / calculate_run / calculate_hits are called:
print $score->score; # total points earned by this play
print $score->pair; # 1=pair, 2=three-of-a-kind, 3=four-of-a-kind
print $score->run; # 1=run-of-3, 2=run-of-4, 3=run-of-5 ...
print $score->fifteen; # 1 if running total is exactly 15
print $score->pegged; # 1 if running total is exactly 31
PROPERTIES
scores
Readonly hashref holding the point values for each scoring category. Built automatically; do not set manually.
$score->scores;
# {
# run => [3, 4, 5, 6, 7], # indexed by (run_length - 3)
# pair => [2, 6, 12], # indexed by (matches - 1)
# fifteen => 2,
# go => 1,
# pegged => 1,
# flipped => 1,
# }
total_score
Read/write integer property caching the last computed total score. Populated by score().
$score->total_score;
pair
Read/write integer encoding the pair/prials result: 1 = one pair, 2 = three of a kind, 3 = four of a kind. undef/0 means no pair.
$score->pair;
run
Read/write integer encoding a run: 1 = run of three, 2 = run of four, 3 = run of five, etc. undef/0 means no run.
$score->run;
fifteen
Read/write integer flag; set to 1 when the running total equals exactly 15.
$score->fifteen;
pegged
Read/write integer flag; set to 1 when the running total equals exactly 31.
$score->pegged;
go
Read/write integer flag; set to 1 on a go (31 reached or last card played).
$score->go;
flipped
Read/write integer flag; set to 1 when the starter card is a Jack (nobs).
$score->flipped;
player
Readonly property holding the player string or object that earned this score.
$score->player;
card
Readonly property holding the Game::Cribbage::Deck::Card that triggered this score.
$score->card;
FUNCTIONS
score
Computes and returns the total points earned by this play action, summing all active scoring categories according to the scores table. Also stores the result in total_score.
my $points = $score->score;
AUTHOR
LNATION, <email at lnation.org>
BUGS
Please report any bugs or feature requests to bug-game-cribbage at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Game-Cribbage. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Game::Cribbage
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
This software is Copyright (c) 2024 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)