| Games-Cards-Bridge-Contract documentation | view source | Contained in the Games-Cards-Bridge-Contract distribution. |
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:
each representing part of the total score. For scoring references/details, see
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.
David Westbrook, <dwestbrook at gmail.com>
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.
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:
http://rt.cpan.org/NoAuth/Bugs.html?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.
| Games-Cards-Bridge-Contract documentation | view source | Contained in the Games-Cards-Bridge-Contract distribution. |