Games::Cards::Bridge::Contract - Bridge (card game) contract and scoring class
Version 0.01
This module provides a class for creating Bridge contract objects, including the results and both duplicate and rubber scoring.
This is example is for the contract of 4S by North, not vulnerable, redoubled, and taking 11 tricks.
my $contract = Games::Cards::Bridge::Contract->new( declarer=>'N', trump=>'S', bid=>4, made=>5, vul=>0, penalty=>2); my $pts = $contract->duplicate_score; my ( $declarer_above_line, $declarer_below_line, $defense_above_line ) = $contract->rubber_score;
Requires named parameters trump, declarer, bid, made, down (only one of made or down can be set). Optional named parameters of vul, penalty. See each of the ATTRIBUTES for the allowed values/defaults. Croaks if validation fails.
Boolean -- true iff the contract is Clubs or Diamonds
Boolean -- true iff the contract is Hearts or Spades
Boolean -- true iff the contract is No Trump
Boolean -- true iff the contract was a passout
Boolean -- true iff contract was at the slam (small or grand) level
Boolean -- true iff contract was a small slam (bid 6)
Boolean -- true iff contract was a grand slam (bid 7)
If contract made, this is the number of overtrcks (made-bid). undef if contract was defeated.
Boolean -- true iff the given number of tricks (defaults to number bid) would constitute the game level (or higher).
Returns an array of ( declarer_above, declarer_below, defense_above ) for the current contract/result.
Note that honors, game bonus, and rubber bonus need to be handled externally. (See Games::Cards::Bridge::Rubber)
Returns the declarer's score for this contract/result. Postive if declarer made it, negative if he went down.
Internal-use method that does the actual score calculation. Returns a hashref w/the following keys:
undertricks
tricks
overtricks
partscore
game
slam
insult
each representing part of the total score. For scoring references/details, see
http://www.acbl.org/learn/scoreRubber.html
http://www.acbl.org/learn/scoreDuplicate.html
These all have accessors provided by Class::Accessor.
Must be one of: N E S W for North, East, South, West.
Must be one of: C D H S N P for Clubs, Diamonds, Hearts, Spades, Notrump, Passout.
Boolean (gets casted into 1 or 0)
Must be 1 if the contract is doubled, 2 if it is redoubled, and 0 otherwise.
The level of the contract. Must be between 1 and 7, inclusive.
If the contract made, this should be the level that was made, which must be between bid and 7, inclusive. e.g. If bid 4 and took 12 tricks, then made is 6. Must be undef/unspecified if the contract went down.
If the contract was defeated, then this is number of tricks it went down, which must be between 1 and bid, inclusive. e.g. If bid 4 and took 8 tricks, then down is 2. Must be undef/unspecified if the contract made.
Class::Accessor
Carp
David Westbrook, <dwestbrook at gmail.com>
<dwestbrook at gmail.com>
Games::Cards::Bridge::Rubber
Honors & game/rubber bonus for Rubber bridge. (See Games::Cards::Bridge::Rubber)
Release a Games::Cards::Bridge module
Please report any bugs or feature requests to bug-games-cards-bridge at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Games-Cards-Bridge-Contract. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-games-cards-bridge at rt.cpan.org
I'm also available by email or via '/msg davidrw' on http://perlmonks.org.
You can find documentation for this module with the perldoc command.
perldoc Games::Cards::Bridge::Contract
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Games-Cards-Bridge-Contract
CPAN Ratings
http://cpanratings.perl.org/d/Games-Cards-Bridge-Contract
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Games-Cards-Bridge-Contract
Search CPAN
http://search.cpan.org/dist/Games-Cards-Bridge-Contract
Copyright 2006 David Westbrook, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Games::Cards::Bridge::Contract, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Games::Cards::Bridge::Contract
CPAN shell
perl -MCPAN -e shell install Games::Cards::Bridge::Contract
For more information on module installation, please visit the detailed CPAN module installation guide.