| 1 | package VANAMBURG::BCS; | ||
| 2 | 3 | ▶ | use v5.10; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 3 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 3 | extends 'VANAMBURG::Packet'; | |
| 5 | 3 | with 'VANAMBURG::SHoCkeDOrder'; | |
| 6 | 3 | ▶ | use VANAMBURG::StackCard; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 3 | ▶ | use VANAMBURG::FaceValueSingleton; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 3 | ▶ | use VANAMBURG::SuitSingletonSHoCkeD; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | =head1 VANAMBURG::BCS | ||
| 11 | |||
| 12 | Models Richard Osterlinds Breakthrough Card System for the purpose | ||
| 13 | of providing a training system and trick simulations. | ||
| 14 | |||
| 15 | You can get a number of printed and DVD resources for learning the BCS | ||
| 16 | system, as well as shortcuts and routines, at Richard Osterlinds web site: | ||
| 17 | http://osterlindmysteries.com/store/ | ||
| 18 | |||
| 19 | This class has all the methods inherited from: | ||
| 20 | L<VANAMBURG::SHoCkeDOrder> | ||
| 21 | L<VANAMBURG::Packet> | ||
| 22 | =cut | ||
| 23 | |||
| 24 | |||
| 25 | =head2 BUILD | ||
| 26 | |||
| 27 | Initialize the BCS order in this packet of cards. | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | 2 | ▶ | sub BUILD { |
|
Subroutine
BUILD: called CC=2 SCAR=6.9
Pod
documented
| |||
| 32 | 2 | my $self = shift; | |
| 33 | |||
| 34 | 2 | my $fvs = VANAMBURG::FaceValueSingleton->instance; | |
| 35 | 2 | my $sss = VANAMBURG::SuitSingletonSHoCkeD->instance; | |
| 36 | |||
| 37 | 2 | my $first_card = VANAMBURG::StackCard->new( | |
| 38 | value => $fvs->ace, | ||
| 39 | suit => $sss->spade, | ||
| 40 | stack_number => 1 | ||
| 41 | ); | ||
| 42 | 2 | $self->add_card($first_card); | |
| 43 | 2 | my $last_card = $first_card; | |
| 44 | 2 | for ( 2 .. 52 ) { | |
| 45 | 102 | $last_card = $self->card_after($last_card); | |
| 46 | 102 | $self->add_card($last_card); | |
| 47 | } | ||
| 48 | |||
| 49 | } | ||
| 50 | |||
| 51 | =head2 calc_suit | ||
| 52 | |||
| 53 | The suit of the next card is dependent upon the value | ||
| 54 | of the next card and the suit of the previous card. Given | ||
| 55 | both of those pieces of information, this method | ||
| 56 | returns the suit for the next card in the BCS system. | ||
| 57 | |||
| 58 | =cut | ||
| 59 | |||
| 60 | 102 | ▶ | sub calc_suit { |
|
Subroutine
calc_suit: called CC=1 SCAR=0.0
Pod
documented
| |||
| 61 | 102 | my ( $self, $prev_card, $new_value ) = @_; | |
| 62 | 102 | given ( $new_value->value ) { | |
| 63 | 102 | when ( [ 1, 2, 3 ] ) { return $prev_card->suit; } | |
| 64 | 80 | when ( [ 4, 5, 6 ] ) { | |
| 65 | 24 | return $self->opposite_suit( $prev_card->suit ); | |
| 66 | } | ||
| 67 | 56 | when ( [ 7, 8, 9 ] ) { | |
| 68 | 24 | return $self->previous_suit( $prev_card->suit ); | |
| 69 | } | ||
| 70 | 32 | when ( [ 10, 11, 12, 13 ] ) { | |
| 71 | 32 | return $self->next_suit( $prev_card->suit ); | |
| 72 | } | ||
| 73 | } | ||
| 74 | } | ||
| 75 | |||
| 76 | =head2 card_after | ||
| 77 | |||
| 78 | Given a card, and instance of L<VANAMBURG::StackCard>, this method returns the next card in the system. | ||
| 79 | |||
| 80 | Returns an instance of L<VANAMBURG::StackCard> | ||
| 81 | |||
| 82 | =cut | ||
| 83 | |||
| 84 | 102 | ▶ | sub card_after { |
|
Subroutine
card_after: called CC=1 SCAR=0.0
Pod
documented
| |||
| 85 | 102 | my ( $self, $card ) = @_; | |
| 86 | |||
| 87 | 102 | my $next_val_index = | |
| 88 | ( ( ( ( $card->value->value * 2 ) % 13 ) + $card->suit->value ) % 13 ) - | ||
| 89 | 1; | ||
| 90 | 102 | my $next_value = | |
| 91 | VANAMBURG::FaceValueSingleton->instance->default_value_cycle->[$next_val_index]; | ||
| 92 | 102 | my $next_suit = $self->calc_suit( $card, $next_value ); | |
| 93 | 102 | VANAMBURG::StackCard->new( | |
| 94 | value => $next_value, | ||
| 95 | suit => $next_suit, | ||
| 96 | stack_number => $card->stack_number + 1, | ||
| 97 | ); | ||
| 98 | } | ||
| 99 | |||
| 100 | 3 | 1; | |