The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Games::Cards::Bridge::Rubber - Object for Bridge (card game) Rubber scoring

VERSION

Version 0.01

SYNOPSIS

This module provides a class for creating Bridge rubber objects, including the results and scoring and current state of the rubber.

  use Games::Cards::Bridge::Rubber;
  sub show_score {
    my $rubber = shift;
    printf "Totals (above/below): We = %d/%d \t They = %d/%d\n", $rubber->we_above, $rubber->we_below, $rubber->they_above, $rubber->they_below; 
    printf "  Legs:  We = %d \t They = %d\n", $rubber->we_leg, $rubber->they_leg;
    printf "  Vul:  We = %d \t They = %d\n", $rubber->we_vul, $rubber->they_vul;
    printf "==COMPLETE==\n\tWe: %d\tThey: %d\n", $rubber->we_score, $rubber->they_score if $rubber->complete;
  }
  my $rubber = Games::Cards::Bridge::Rubber->new;

  show_score($rubber);
  foreach my $opts (
    { direction => 'we', trump => 'H', bid => '2', made => '4' },
    { direction => 'they', trump => 'S', bid => '4', down => '2', dbl => 1 },
    { direction => 'they', trump => 'N', bid => '3', made => '4' },
    { direction => 'they', trump => 'S', bid => '3', made => '3' },
    { direction => 'they', trump => 'D', bid => '2', down => '2'  },
    { direction => 'we', trump => 'H', bid => '6', made => '7', dbl => 1 },
    { direction => 'they', trump => 'N', bid => '1', made => '2' },
    { direction => 'we', trump => 'C', bid => '3', made => '3' },
    { direction => 'they', trump => 'H', bid => '3', made => '3' },
  ){
    $rubber->contract( %$opts );
    show_score($rubber);
  }

METHODS

new

No parameters needed.

contract

Add a contract to the rubber. This needs the same arguments as Games::Cards::Bridge::Contract's constructor, as well as a direction parameter of 'we' or 'they' (and the declarer parameter is not used). This method is also responsible for internally updating the attributes. See also http://www.acbl.org/learn/scoreRubber.html

we_score

Gives the current total 'We' score.

they_score

Gives the current total 'They' score.

both_vul

Alias to returns true iff ->we_vul() and ->they_vul().

ATTRIBUTES

These are all auto-calculated/maintained; their current values are available from the accessor method provided by Class::Accessor.

contracts

Array ref holding all the contracts added by the contract() method.

we_above

Current above-the-line score for 'We'.

we_below

Current below-the-line score for 'We'.

we_leg

The current "leg" for 'We'.

they_leg

The current "leg" for 'They'.

they_above

Current above-the-line score for 'They'.

they_below

Current below-the-line score for 'They'.

we_vul

Returns true if the 'We' side is vulnerable (has one "game").

they_vul

Returns true if the 'They' side is vulnerable (has one "game").

complete

Returns true if the rubber has concluded (one side got two "games").

PREREQUISITES

TODO

  • Handle honors bonuses

AUTHOR

David Westbrook, <dwestbrook at gmail.com>

BUGS & SUPPORT

See Games::Cards::Bridge::Contract

COPYRIGHT & LICENSE

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.