| 1 | package Games::TF2::Demo::Names; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 12 | ▶ | use v5.26; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 12 | ▶ | use feature 'signatures'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 12 | ▶ | no warnings 'experimental::signatures'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 12 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 12 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 12 | ▶ | use Readonly; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 12 | our @EXPORT_OK = qw(team_name player_class_name building_kind_name projectile_kind_name); | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | # The names the tfdemo tool gives the numbers of the C API (to_string of | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # tf-demo-parser-cpp's src/match.cpp and src/gamestate.cpp). | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 12 | Readonly my @TEAMS => qw(unassigned spectator red blue); | |||||||||||||||||||||||||||||||||||||||||
| 18 | 12 | Readonly my @PLAYER_CLASSES => qw(unknown scout sniper soldier demoman medic heavy pyro spy engineer); | |||||||||||||||||||||||||||||||||||||||||
| 19 | 12 | Readonly my @BUILDING_KINDS => qw(sentry dispenser teleporter_entrance teleporter_exit); | |||||||||||||||||||||||||||||||||||||||||
| 20 | 12 | Readonly my @PROJECTILE_KINDS => qw(rocket sentry_rocket pipe sticky loose_cannon flare arrow healing_bolt jar cleaver ball other); | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 34 | ▶ | sub _name_in ( $names, $number, $fallback ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_name_in: called CC=4 SCAR=14.9
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 34 | ▶ | return $fallback unless defined $number && $number =~ /\A[0-9]+\z/ && $number < @$names; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $number and $number =~ /\A[0-9]+\z/u and $number < @$names
defined $number and $number =~ /\A[0-9]+\z/u
MC/DC33%1/3
defined $number and $number =~ /\A[0-9]+\z/u and $number < @$names
defined $number
$number =~ /\A[0-9]+\z/u
$number < @$names
Truth table50%2/4
A and B and C
A= defined $numberB= $number =~ /\A[0-9]+\z/uC= $number < @$names
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 30 | return $names->[$number]; | |||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 5 | ▶ | sub team_name ($team) { return _name_in( \@TEAMS, $team, 'unassigned' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
team_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 11 | ▶ | sub player_class_name ($player_class) { return _name_in( \@PLAYER_CLASSES, $player_class, 'unknown' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
player_class_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | ▶ | sub building_kind_name ($kind) { return _name_in( \@BUILDING_KINDS, $kind, 'unknown' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
building_kind_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 13 | ▶ | sub projectile_kind_name ($kind) { return _name_in( \@PROJECTILE_KINDS, $kind, 'unknown' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
projectile_kind_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | __END__ | ||||||||||||||||||||||||||||||||||||||||||