| 1 | package Game::Schnapsen::Error; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 24 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 24 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 24 | ▶ | use Object::Proto::Sugar -types; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 24 | our $VERSION = '0.03'; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 24 | my %MESSAGE = ( | |||||||||||||||||||
| 11 | bad_variant => 'that is not a game this engine plays', | ||||||||||||||||||||
| 12 | no_seed => 'a deal needs a seed', | ||||||||||||||||||||
| 13 | bad_deal => 'a deal number counts from one', | ||||||||||||||||||||
| 14 | deal_over => 'the deal is over', | ||||||||||||||||||||
| 15 | game_over => 'the match is over', | ||||||||||||||||||||
| 16 | not_your_turn => 'it is not your turn', | ||||||||||||||||||||
| 17 | not_legal => 'the rules do not offer that', | ||||||||||||||||||||
| 18 | not_held => 'that card is not in your hand', | ||||||||||||||||||||
| 19 | must_follow => 'you must follow suit, and beat the card led if you can', | ||||||||||||||||||||
| 20 | must_lead => 'you must lead one of the two cards you married', | ||||||||||||||||||||
| 21 | no_marriage => 'you do not hold that marriage', | ||||||||||||||||||||
| 22 | no_exchange => 'you cannot exchange for the trump card now', | ||||||||||||||||||||
| 23 | cannot_close => 'the talon cannot be closed now', | ||||||||||||||||||||
| 24 | cannot_claim => 'you may only claim just after taking a trick or declaring a marriage', | ||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 24 | has code => (is => 'ro', isa => Str); | |||||||||||||||||||
| 28 | 24 | has message => (is => 'ro', isa => Str); | |||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 41 | ▶ | sub new_code { | ||||||||||||||||||
|
Subroutine
new_code: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||
| 31 | 41 | my ($class, $code) = @_; | |||||||||||||||||||
| 32 | return $class->new( | ||||||||||||||||||||
| 33 | code => $code, | ||||||||||||||||||||
| 34 | 41 | ▶ | message => $MESSAGE{$code} // $code, | ||||||||||||||||||
|
Condition33%1/3
$MESSAGE{$code} // $code
MC/DC0%0/2
$MESSAGE{$code} // $code
$MESSAGE{$code}
$code
Truth table33%1/3
A // B
A= $MESSAGE{$code}B= $code
| |||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | ▶ | sub codes { return sort keys %MESSAGE } | ||||||||||||||||||
|
Subroutine
codes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 24 | 1; | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | __END__ | ||||||||||||||||||||