| 1 | package Game::Oware; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 20 | ▶ | use strict; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 20 | ▶ | use warnings; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 20 | ▶ | use Object::Proto::Sugar -types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 20 | ▶ | use Carp (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 20 | ▶ | use Game::Oware::Board; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 20 | ▶ | use Game::Oware::Move; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 20 | ▶ | use Game::Oware::Error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 20 | ▶ | use Game::Oware::Rules; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 20 | ▶ | use Game::Oware::Scoring; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 20 | ▶ | use Game::Oware::Notation; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 20 | ▶ | use Game::Oware::Result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 20 | ▶ | use Game::Oware::Variant (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 20 | our $VERSION = '0.04'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | has variant => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | is => 'ro', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | isa => Str, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | default => 'abapa' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | has board => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | is => 'rw', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | isa => ArrayRef | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 20 | has turn => (is => 'rw'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | has status => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | is => 'rw', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | isa => Str, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | default => 'active' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 20 | has [qw/ winner result /] => (is => 'rw'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | has log => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | is => 'rw', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | isa => ArrayRef, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | default => [] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | has no_capture => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | is => 'rw', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | isa => Int, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | default => 0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | has seen => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | is => 'rw', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | isa => HashRef, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | default => {} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | has _held_seed => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | is => 'ro', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | init_arg => 'seed', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | private => 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 175 | ▶ | sub BUILD { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=4 SCAR=13.9
Pod
undocumented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 175 | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 175 | Game::Oware::Variant::check_variant($self->variant); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 175 | ▶ | $self->board(Game::Oware::Board->opening) unless $self->board; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | Carp::croak('Game::Oware: a board is fourteen cells') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 175 | ▶ | unless @{ $self->board } == Game::Oware::Board->CELLS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 175 | ▶ | $self->turn('p1') unless defined $self->turn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | $self->_emit('sys', 'start', { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | variant => $self->variant, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | first => $self->turn, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 175 | board => join(',', @{ $self->board }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 175 | $self->_remember; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 175 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 21 | ▶ | sub seats { return qw/ p1 p2 / } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seats: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 50 | ▶ | sub events { return [ @{ $_[0]->log } ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
events: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 5530 | ▶ | sub other { return Game::Oware::Board->other($_[1]) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
other: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 97 | ▶ | sub captured { return Game::Oware::Scoring->captured($_[0]->board) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
captured: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | ▶ | sub score { return Game::Oware::Scoring->score($_[0]->board, $_[0]->status) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
score: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | ▶ | sub scores { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scores: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | my $captured = $self->captured; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | return { map { $_ => { current => $captured->{$_} } } $self->seats }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | ▶ | sub places { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
places: called CC=2 SCAR=8.1
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | ▶ | return undef unless $self->status eq 'finished'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | return $self->result->places; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 23 | ▶ | sub seed { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seed: called CC=2 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 23 | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 23 | ▶ | return undef unless $self->status eq 'finished'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 10 | return $self->_held_seed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 15211 | ▶ | sub legal { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
legal: called CC=4 SCAR=13.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 15211 | my ($self, $seat) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 15211 | ▶ | return [] unless $self->status eq 'active'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 15195 | ▶ | return [] unless defined $seat && $seat eq $self->turn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $seat and $seat eq $self->turn
MC/DC50%1/2
defined $seat and $seat eq $self->turn
defined $seat
$seat eq $self->turn
Truth table66%2/3
A and B
A= defined $seatB= $seat eq $self->turn
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 15183 | return [ Game::Oware::Rules->legal_moves($self->board, $seat, $self->variant) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 3478 | ▶ | sub waiting_on { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
waiting_on: called CC=2 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 3478 | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 3478 | ▶ | return () unless $self->status eq 'active'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 3466 | return ($self->turn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 5493 | ▶ | sub play { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
play: called CC=10 SCAR=23.1
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 5493 | my ($self, $seat, $house) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 5493 | ▶ | return Game::Oware::Error->throw('game_over') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | unless $self->status eq 'active'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 5491 | ▶ | return Game::Oware::Error->throw('not_your_turn') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
defined $seat and $seat eq "p1" || $seat eq "p2" and $seat eq $self->turn
defined $seat and $seat eq "p1" || $seat eq "p2"
$seat eq "p1" or $seat eq "p2"
MC/DC25%1/4
defined $seat and $seat eq "p1" || $seat eq "p2" and $seat eq $self->turn
defined $seat
$seat eq "p1"
$seat eq "p2"
$seat eq $self->turn
Truth table50%3/6
A and B or C and D
A= defined $seatB= $seat eq "p1"C= $seat eq "p2"D= $seat eq $self->turn
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | unless defined $seat && ($seat eq 'p1' || $seat eq 'p2') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | && $seat eq $self->turn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 5489 | Game::Oware::Board->assert_house($house); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 5488 | ▶ | return Game::Oware::Error->throw('not_your_house') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | unless Game::Oware::Board->owner_of($house) eq $seat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 5486 | ▶ | return Game::Oware::Error->throw('empty_house') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | unless $self->board->[$house]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 5485 | my $legal = $self->legal($seat); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | return Game::Oware::Error->throw('must_feed', legal => [ @$legal ]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 5485 | ▶ | unless grep { $_ == $house } @$legal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 5482 | my ($next, $move) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | Game::Oware::Rules->resolve($self->board, $house, $seat, $self->variant); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 5482 | $self->board($next); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 5482 | ▶ | if ($move->taken) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 430 | $self->no_capture(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 430 | $self->seen({}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 5052 | $self->no_capture($self->no_capture + 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | $self->_emit($seat, 'sow', { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | house => $house, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 5482 | captured => [ @{ $move->captured } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | taken => $move->taken, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | slammed => $move->slammed, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 5482 | forfeited => [ @{ $move->forfeited } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 5482 | $self->_after($move); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 5482 | return $move; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 6 | ▶ | sub timeout { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
timeout: called CC=5 SCAR=17.8
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 6 | my ($self, $seat) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 6 | ▶ | return Game::Oware::Error->throw('game_over') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | unless $self->status eq 'active'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 6 | ▶ | Carp::croak('Game::Oware: a seat is p1 or p2') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $seat and $seat eq "p1" || $seat eq "p2"
$seat eq "p1" or $seat eq "p2"
MC/DC0%0/3
defined $seat and $seat eq "p1" || $seat eq "p2"
defined $seat
$seat eq "p1"
$seat eq "p2"
Truth table50%2/4
A and B or C
A= defined $seatB= $seat eq "p1"C= $seat eq "p2"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | unless defined $seat && ($seat eq 'p1' || $seat eq 'p2'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 6 | $self->_emit('sys', 'timeout', { p => $seat }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 6 | return $self->_finish($self->other($seat), 'timeout', 'timeout'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 4 | ▶ | sub abandon { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
abandon: called CC=2 SCAR=7.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 4 | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 4 | ▶ | return Game::Oware::Error->throw('game_over') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | unless $self->status eq 'active'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 4 | $self->_emit('sys', 'abandon', {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 4 | return $self->_finish(undef, 'abandoned', 'abandon'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 13 | ▶ | sub resign { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resign: called CC=5 SCAR=17.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 13 | my ($self, $seat) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 13 | ▶ | return Game::Oware::Error->throw('game_over') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | unless $self->status eq 'active'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 12 | ▶ | Carp::croak('Game::Oware: a seat is p1 or p2') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $seat and $seat eq "p1" || $seat eq "p2"
$seat eq "p1" or $seat eq "p2"
MC/DC0%0/3
defined $seat and $seat eq "p1" || $seat eq "p2"
defined $seat
$seat eq "p1"
$seat eq "p2"
Truth table50%2/4
A and B or C
A= defined $seatB= $seat eq "p1"C= $seat eq "p2"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | unless defined $seat && ($seat eq 'p1' || $seat eq 'p2'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 12 | $self->_emit($seat, 'resign', {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 12 | return $self->_finish($self->other($seat), 'resign', 'resign'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 11 | ▶ | sub clone { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 11 | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 11 | my $copy = Object::Proto::clone($self); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 11 | $copy->board([ @{ $self->board } ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 11 | $copy->log([ map { { %$_, payload => { %{ $_->{payload} } } } } @{ $self->log } ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 11 | $copy->seen({ %{ $self->seen } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 11 | return $copy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 485 | ▶ | sub to_text { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_text: called CC=12 SCAR=24.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 485 | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 485 | my $start = $self->log->[0]{payload}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 485 | my @line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 485 | ▶ | push @line, 'variant ' . $self->variant if $self->variant ne 'abapa'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 485 | ▶ | push @line, 'first ' . $start->{first} if $start->{first} ne 'p1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | push @line, 'board ' . $start->{board} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 485 | ▶ | if $start->{board} ne join ',', @{ Game::Oware::Board->opening }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 485 | ▶ | if (defined(my $seed = $self->_held_seed)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 482 | ▶ | utf8::encode($seed) if utf8::is_utf8($seed); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 482 | push @line, 'seed ' . unpack 'H*', $seed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | my $transcript = Game::Oware::Notation->render( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 485 | [ map { $_->{payload}{house} } grep { $_->{kind} eq 'sow' } @{ $self->log } ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 485 | ▶ | push @line, $transcript if length $transcript || @line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
length $transcript or @line
MC/DC0%0/2
length $transcript or @line
length $transcript
@line
Truth table66%2/3
A or B
A= length $transcriptB= @line
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 485 | for my $event (@{ $self->log }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 16139 | ▶ | push @line, "resign $event->{actor}" if $event->{kind} eq 'resign'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 16139 | ▶ | push @line, "timeout $event->{payload}{p}" if $event->{kind} eq 'timeout'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 16139 | ▶ | push @line, 'abandon' if $event->{kind} eq 'abandon'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 485 | return join "\n", @line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 38 | ▶ | sub from_text { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_text: called CC=31 SCAR=35.3
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 38 | my ($class, $text, %options) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 38 | ▶ | Carp::croak('Game::Oware: a transcript is a string') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $text and not ref $text
MC/DC0%0/2
defined $text and not ref $text
defined $text
not ref $text
Truth table33%1/3
A and not(B)
A= defined $textB= not ref $text
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | unless defined $text && !ref $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 38 | my (%setting, @ending, $letters); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 38 | for my $line (split /\n/, $text) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 79 | ▶ | next unless $line =~ /\S/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 79 | $line =~ s/^\s+|\s+$//g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 79 | my ($word, $value) = $line =~ /^(variant|first|board|seed|resign|timeout|abandon)\b\s*(.*)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 79 | ▶ | if (!defined $word) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 30 | ▶ | Carp::croak('Game::Oware: the transcript has moves after its ending') if @ending; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 29 | $letters .= $line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 29 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 49 | ▶ | if ($word eq 'resign' || $word eq 'timeout' || $word eq 'abandon') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$word eq "resign" or $word eq "timeout" or $word eq "abandon"
$word eq "resign" or $word eq "timeout"
MC/DC100%3/3
$word eq "resign" or $word eq "timeout" or $word eq "abandon"
$word eq "resign"
$word eq "timeout"
$word eq "abandon"
Truth table100%4/4
A or B or C
A= $word eq "resign"B= $word eq "timeout"C= $word eq "abandon"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 10 | ▶ | Carp::croak("Game::Oware: the transcript has a second ending, '$line'") if @ending; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 10 | ▶ | Carp::croak("Game::Oware: '$line' does not name a seat, p1 or p2") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | unless $word eq 'abandon' ? $value eq '' : $value =~ /^p[12]$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 9 | @ending = ($word, $value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 9 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | Carp::croak("Game::Oware: the transcript says $word twice") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 39 | ▶ | if exists $setting{$word}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 39 | ▶ | Carp::croak("Game::Oware: the transcript names its $word after its moves") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $letters or @ending
MC/DC0%0/2
defined $letters or @ending
defined $letters
@ending
Truth table33%1/3
A or B
A= defined $lettersB= @ending
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | if defined $letters || @ending; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 39 | ▶ | if ($word eq 'first') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 2 | ▶ | Carp::croak("Game::Oware: the first seat is p1 or p2, not '$value'") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | unless $value =~ /^p[12]$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | $setting{turn} = $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | elsif ($word eq 'board') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 2 | ▶ | Carp::croak("Game::Oware: a board is fourteen counts of seeds, not '$value'") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | unless $value =~ /^\d+(?:,\d+){13}$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 2 | $setting{board} = [ map { $_ + 0 } split /,/, $value ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | elsif ($word eq 'seed') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 32 | ▶ | Carp::croak("Game::Oware: a seed is written in hexadecimal, not '$value'") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | unless $value =~ /^(?:[0-9a-f]{2})*$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 31 | $setting{seed} = pack 'H*', $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 3 | ▶ | Carp::croak("Game::Oware: there is no variant '$value'") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | unless Game::Oware::Variant::is_variant($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 2 | $setting{variant} = $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 34 | my $game = $class->new(%options, %setting); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 34 | ▶ | for my $house (@{ Game::Oware::Notation->parse($letters // '', $game->turn) }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$letters // ""
MC/DC100%1/1
$letters // ""
$letters
Truth table100%2/2
A
A= $letters
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 1861 | my $out = $game->play($game->turn, $house); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 1861 | ▶ | Carp::croak('Game::Oware: the transcript does not play: ' . $out->stringify) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $out and $out->isa("Game::Oware::Error")
MC/DC0%0/2
ref $out and $out->isa("Game::Oware::Error")
ref $out
$out->isa("Game::Oware::Error")
Truth table33%1/3
A and B
A= ref $outB= $out->isa("Game::Oware::Error")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | if ref $out && $out->isa('Game::Oware::Error'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 33 | ▶ | if (@ending) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 8 | my ($word, $seat) = @ending; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 8 | ▶ | my $out = $word eq 'abandon' ? $game->abandon : $game->$word($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 8 | ▶ | Carp::croak("Game::Oware: the transcript ends by $word, but the moves already end the game") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $out and $out->isa("Game::Oware::Error")
MC/DC50%1/2
ref $out and $out->isa("Game::Oware::Error")
ref $out
$out->isa("Game::Oware::Error")
Truth table66%2/3
A and B
A= ref $outB= $out->isa("Game::Oware::Error")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | if ref $out && $out->isa('Game::Oware::Error'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 32 | return $game; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 11 | ▶ | sub replay { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replay: called CC=22 SCAR=31.7
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 11 | my ($self, $log) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 11 | ▶ | Carp::croak('Game::Oware: a log is an arrayref of events') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | unless ref $log eq 'ARRAY'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | Carp::croak('Game::Oware: replay wants a game that has not been played') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 11 | ▶ | unless @{ $self->log } == 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 10 | my @events = @$log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 10 | my $start = shift @events; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | Carp::croak('Game::Oware: the log does not open with a start') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | unless $start && ($start->{actor} // '') eq 'sys' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 10 | ▶ | && ($start->{kind} // '') eq 'start'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%6/10
$start and ($start->{"actor"} // "") eq "sys" and ($start->{"kind"} // "") eq "start"
$start and ($start->{"actor"} // "") eq "sys"
$start->{"actor"} // ""
$start->{"kind"} // ""
MC/DC0%0/3
$start and ($start->{"actor"} // "") eq "sys" and ($start->{"kind"} // "") eq "start"
$start
$start->{"actor"}
$start->{"kind"}
Truth table25%1/4
A and B and C
A= $startB= $start->{"actor"}C= $start->{"kind"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | Carp::croak('Game::Oware: the log was made under a different variant') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 9 | ▶ | unless ($start->{payload}{variant} // '') eq $self->variant; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$start->{"payload"}{"variant"} // ""
MC/DC0%0/1
$start->{"payload"}{"variant"} // ""
$start->{"payload"}{"variant"}
Truth table50%1/2
A
A= $start->{"payload"}{"variant"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 8 | my $began = join ',', @{ $self->board }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 8 | my $logged = $start->{payload}{board}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 8 | ▶ | Carp::croak('Game::Oware: the log began from a different position') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $logged and $logged ne $began
MC/DC50%1/2
defined $logged and $logged ne $began
defined $logged
$logged ne $began
Truth table66%2/3
A and B
A= defined $loggedB= $logged ne $began
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | if defined($logged) && $logged ne $began; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 7 | for my $event (@events) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 153 | ▶ | my $actor = $event->{actor} // ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$event->{"actor"} // ""
MC/DC0%0/1
$event->{"actor"} // ""
$event->{"actor"}
Truth table50%1/2
A
A= $event->{"actor"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 153 | ▶ | my $kind = $event->{kind} // ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$event->{"kind"} // ""
MC/DC0%0/1
$event->{"kind"} // ""
$event->{"kind"}
Truth table50%1/2
A
A= $event->{"kind"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 153 | ▶ | if ($actor eq 'sys') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 6 | ▶ | $self->timeout($event->{payload}{p}) if $kind eq 'timeout'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 6 | ▶ | $self->abandon if $kind eq 'abandon'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 6 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | my $out = $kind eq 'resign' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | ? $self->resign($actor) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 147 | ▶ | : $self->play($actor, $event->{payload}{house}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 147 | ▶ | Carp::croak('Game::Oware: the log does not replay: ' . $out->stringify) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $out and $out->isa("Game::Oware::Error")
MC/DC50%1/2
ref $out and $out->isa("Game::Oware::Error")
ref $out
$out->isa("Game::Oware::Error")
Truth table66%2/3
A and B
A= ref $outB= $out->isa("Game::Oware::Error")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | if ref $out && $out->isa('Game::Oware::Error'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 6 | my $ours = join '|', map { _signature($_) } @{ $self->log }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 6 | my $theirs = join '|', map { _signature($_) } @$log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 6 | ▶ | Carp::croak('Game::Oware: the log does not replay to itself, so it records ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | . 'something this game would not have produced') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | unless $ours eq $theirs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 3 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 5764 | ▶ | sub _emit { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_emit: called CC=2 SCAR=7.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 5764 | my ($self, $actor, $kind, $payload) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 5764 | ▶ | push @{ $self->log }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$payload || {}
MC/DC0%0/1
$payload || {}
$payload
Truth table50%1/2
A
A= $payload
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | { actor => $actor, kind => $kind, payload => $payload || {} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 5764 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 5636 | ▶ | sub _key { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_key: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 5636 | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 5636 | return join(',', @{ $self->board }) . ':' . $self->turn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 5636 | ▶ | sub _remember { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remember: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 5636 | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 5636 | my $seen = $self->seen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 5636 | return ++$seen->{ $self->_key }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 5482 | ▶ | sub _after { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_after: called CC=6 SCAR=17.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 5482 | my ($self, $move) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 5482 | my $target = Game::Oware::Scoring->target_reached($self->board); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 5482 | ▶ | return $self->_finish($target, 'score', 'target') if $target; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 5462 | ▶ | return $self->_finish(undef, 'draw', 'even') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | if Game::Oware::Scoring->is_draw($self->board); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 5461 | my $limit = Game::Oware::Variant::plies_without_capture($self->variant); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 5461 | ▶ | if ($self->no_capture >= $limit) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 1 | $self->board(Game::Oware::Scoring->sweep_split($self->board)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 1 | $self->_emit('sys', 'cycle', { why => 'plies', plies => $self->no_capture }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 1 | return $self->_settle('cycle'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 5460 | $self->turn($self->other($move->seat)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 5460 | my $repeats = $self->_remember; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 5460 | ▶ | if ($repeats >= Game::Oware::Variant::repetition_limit($self->variant)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 11 | $self->board(Game::Oware::Scoring->sweep_split($self->board)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 11 | $self->_emit('sys', 'cycle', { why => 'repetition', times => $repeats }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 11 | return $self->_settle('cycle'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 5449 | ▶ | unless (@{ $self->legal($self->turn) }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 9 | my $swept = $self->turn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 9 | $self->board(Game::Oware::Scoring->sweep_to($self->board, $swept)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 9 | $self->_emit('sys', 'sweep', { p => $swept, why => 'no_feed' }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 9 | return $self->_settle('no_feed'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 5440 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 21 | ▶ | sub _settle { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_settle: called CC=3 SCAR=11.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 21 | my ($self, $reason) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 21 | my $captured = $self->captured; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | return $self->_finish(undef, 'draw', $reason) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 21 | ▶ | if $captured->{p1} == $captured->{p2}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 14 | ▶ | my $winner = $captured->{p1} > $captured->{p2} ? 'p1' : 'p2'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 14 | return $self->_finish($winner, 'score', $reason); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 64 | ▶ | sub _finish { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finish: called CC=4 SCAR=13.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 64 | my ($self, $winner, $result, $reason) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 64 | $self->status('finished'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 64 | $self->winner($winner); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 64 | my $captured = $self->captured; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 64 | ▶ | my $natural = $result eq 'score' || $result eq 'draw'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$result eq 'score' || $result eq 'draw'
MC/DC100%2/2
$result eq 'score' || $result eq 'draw'
$result eq 'score'
$result eq 'draw'
Truth table100%3/3
A || B
A= $result eq 'score'B= $result eq 'draw'
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 64 | ▶ | my %places = defined $winner | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | ? ($winner => 1, $self->other($winner) => 2) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | : (p1 => 1, p2 => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 64 | ▶ | my $done = Game::Oware::Result->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | winner => $winner, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | result => $result, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | reason => $reason, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | captured => $captured, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | ($natural ? (score => $captured) : ()), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | places => \%places, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 64 | $self->result($done); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 64 | $self->_emit('sys', 'game_end', { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | winner => $winner, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | result => $result, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | reason => $reason, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | captured => $captured, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 64 | return $done; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 292 | ▶ | sub _signature { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_signature: called CC=9 SCAR=22.8
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 292 | my ($event) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 292 | ▶ | my $payload = $event->{payload} || {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$event->{'payload'} || {}
MC/DC0%0/1
$event->{'payload'} || {}
$event->{'payload'}
Truth table50%1/2
A
A= $event->{'payload'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 292 | my @pairs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 292 | for my $key (sort keys %$payload) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 1406 | my $value = $payload->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 1406 | ▶ | $value = join '.', @$value if ref $value eq 'ARRAY'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 1406 | ▶ | $value = join ';', map { "$_=" . ($value->{$_} // '') } sort keys %$value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$value->{$_} // ""
MC/DC0%0/1
$value->{$_} // ""
$value->{$_}
Truth table50%1/2
A
A= $value->{$_}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | if ref $value eq 'HASH'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 1406 | ▶ | push @pairs, $key . '=' . (defined $value ? $value : ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 292 | ▶ | return ($event->{actor} // '') . ':' . ($event->{kind} // '') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$event->{"actor"} // ""
$event->{"kind"} // ""
MC/DC0%0/1
$event->{"actor"} // ""
$event->{"actor"}
MC/DC0%0/1
$event->{"kind"} // ""
$event->{"kind"}
Truth table50%1/2
A
A= $event->{"actor"}
Truth table50%1/2
A
A= $event->{"kind"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | . ':' . join(',', @pairs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 20 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | __END__ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||