| 1 | package Games::TF2::Demo::StateReader; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use v5.26; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use feature 'signatures'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 11 | ▶ | no warnings 'experimental::signatures'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 11 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 11 | ▶ | use Object::Pad 0.800; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | role Games::TF2::Demo::StateReader { | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 11 | ▶ | use Games::TF2::Demo::Entity; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 11 | ▶ | use Games::TF2::Demo::Error; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 11 | ▶ | use Games::TF2::Demo::GameState; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 11 | ▶ | use Games::TF2::Demo::Player; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 11 | ▶ | use Games::TF2::Demo::ServerInfo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 11 | ▶ | use Games::TF2::Demo::StringTable; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | # The XS handle whose state the methods read: a Games::TF2::Demo::_Parser | ||||||||||||||||||||||||||||||||||||||||||
| 21 | # or a Games::TF2::Server::_Connection. | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 11 | method _state_handle; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | # The start of this binding's own error messages, such as | ||||||||||||||||||||||||||||||||||||||||||
| 25 | # 'Games::TF2::Demo'. | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 11 | method _error_prefix; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | method entity ($index) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
entity: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | $self->_check_index( entity => $index ); | |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my $fields = $self->_state_handle->entity($index); | |||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | return undef unless $fields; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | return Games::TF2::Demo::Entity->new( $fields->%* ); | |||||||||||||||||||||||||||||||||||||||||
| 33 | 11 | } | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | method game_state () { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
game_state: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | return Games::TF2::Demo::GameState->from_fields( $self->_state_handle->game_state ); | |||||||||||||||||||||||||||||||||||||||||
| 37 | 11 | } | |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | method player_by_entity ($index) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
player_by_entity: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | $self->_check_index( player_by_entity => $index ); | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my $fields = $self->_state_handle->player_by_entity($index); | |||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | return $fields ? Games::TF2::Demo::Player->new( $fields->%* ) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 11 | } | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | method player_by_user_id ($user_id) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
player_by_user_id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $self->_check_index( player_by_user_id => $user_id ); | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my $fields = $self->_state_handle->player_by_user_id($user_id); | |||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | return $fields ? Games::TF2::Demo::Player->new( $fields->%* ) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 11 | } | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | method players () { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
players: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | return map { Games::TF2::Demo::Player->new( $_->%* ) } $self->_state_handle->players; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 11 | } | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | method string_tables () { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
string_tables: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return $self->_state_handle->string_table_names; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 11 | } | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | method string_table ($name) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
string_table: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $self->_state_argument_error('string_table needs a table name') unless defined $name && !ref $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $name and not ref $name
MC/DC0%0/2
defined $name and not ref $name
defined $name
not ref $name
Truth table0%0/3
A and not(B)
A= defined $nameB= not ref $name
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $fields = $self->_state_handle->string_table($name); | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | return $fields ? Games::TF2::Demo::StringTable->new( $fields->%* ) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 11 | } | |||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | method server_info () { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
server_info: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $fields = $self->_state_handle->server_info; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | return $fields ? Games::TF2::Demo::ServerInfo->new( $fields->%* ) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 11 | } | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | method _state_argument_error ($message) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_state_argument_error: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | Games::TF2::Demo::Error::Argument->throw( message => $self->_error_prefix . ": $message" ); | |||||||||||||||||||||||||||||||||||||||||
| 72 | 11 | } | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | method _check_index ( $method, $number ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_index: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | return if defined $number && !ref $number && $number =~ /\A[0-9]+\z/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $number and not ref $number and $number =~ /\A[0-9]+\z/u
defined $number and not ref $number
MC/DC0%0/3
defined $number and not ref $number and $number =~ /\A[0-9]+\z/u
defined $number
not ref $number
$number =~ /\A[0-9]+\z/u
Truth table0%0/4
A and not(B) and C
A= defined $numberB= not ref $numberC= $number =~ /\A[0-9]+\z/u
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $self->_state_argument_error("$method needs a non-negative integer"); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 11 | } | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | __END__ | ||||||||||||||||||||||||||||||||||||||||||