blib/lib/Game/CharacterSheetGenerator/HalflingNames.pm

filter: Statementstmt 100% 24 / 24 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 82.0% 32 / 39 CC 2 SCAR 3.8
CC
2
Cov
90%
halfling_name
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« blib/lib/Game/CharacterSheetGenerator/DwarfNames.pm ↑ Summary blib/lib/Game/CharacterSheetGenerator/HumanNames.pm »
1 #!/usr/bin/env perl
2 # Copyright (C) 2012-2022 Alex Schroeder <alex@gnu.org>
3  
4 # This program is free software: you can redistribute it and/or modify it under
5 # the terms of the GNU General Public License as published by the Free Software
6 # Foundation, either version 3 of the License, or (at your option) any later
7 # version.
8 #
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License along with
14 # this program. If not, see <http://www.gnu.org/licenses/>.
15  
16 =encoding utf8
17  
18 =head1 NAME
19  
20 Game::CharacterSheetGenerator::HalflingName - return a halfling name
21  
22 =head1 SYNOPSIS
23  
24 use Game::CharacterSheetGenerator::HalflingName qw(halfling_name);
25 # returns both $name and $gender (F, M, or ?)
26 my ($name, $gender) = halfling_name();
27 # returns the same name and its gender
28 ($name, $gender) = halfling_name("Alex");
29  
30 =head1 DESCRIPTION
31  
32 This package has one function that returns a halfling name and a gender. The gender
33 returned is "M", "F", or "?".
34  
35 If a name is provided, the gender is returned.
36  
37 =cut
38  
39 package Game::CharacterSheetGenerator::HalflingNames;
40 11 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 11 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 11 require Exporter;
44 11 our @ISA = qw(Exporter);
45 11 our @EXPORT_OK = qw(halfling_name);
46  
47 sub one {
48 25 ▶ my $i = int(rand(scalar @_));
Subroutine one: called CC=1 SCAR=0.0
Pod undocumented
49 25 return $_[$i];
50 }
51  
52 # http://themiddleages.net/people/names.html
53  
54 11 my @names = qw{Adalbert M Ageric M Agiulf M Ailwin M Alan M Alard M Alaric M
55 Aldred M Alexander M Alured M Amalaric M Amalric M Amaury M Andica M Anselm M
56 Ansovald M Aregisel M Arnald M Arnegisel M Asa M Athanagild M Athanaric M Aubrey
57 M Audovald M Austregisel M Authari M Badegisel M Baldric M Baldwin M Bartholomew
58 M Bennet M Bernard M Bero M Berthar M Berthefried M Bertram M Bisinus M Blacwin
59 M Burchard M Carloman M Chararic M Charibert M Childebert M Childeric M
60 Chilperic M Chlodomer M Chramnesind M Clovis M Colin M Constantine M Dagaric M
61 Dagobert M David M Drogo M Eberulf M Ebregisel M Edwin M Elias M Engeram M
62 Engilbert M Ernald M Euric M Eustace M Fabian M Fordwin M Forwin M Fulk M Gamel
63 M Gararic M Garivald M Geoffrey M Gerard M Gerold M Gervase M Gilbert M Giles M
64 Gladwin M Godomar M Godwin M Grimald M Gunderic M Gundobad M Gunthar M Guntram M
65 Guy M Hamo M Hamond M Harding M Hartmut M Helyas M Henry M Herlewin M Hermangild
66 M Herminafrid M Hervey M Hildebald M Hugh M Huneric M Imnachar M Ingomer M James
67 M Jocelin M John M Jordan M Lawrence M Leofwin M Leudast M Leuvigild M Lothar M
68 Luke M Magnachar M Magneric M Marachar M Martin M Masci M Matthew M Maurice M
69 Meginhard M Merovech M Michael M Munderic M Nicholas M Nigel M Norman M Odo M
70 Oliva M Osbert M Otker M Pepin M Peter M Philip M Ragnachar M Ralf M Ralph M
71 Ranulf M Rathar M Reccared M Ricchar M Richard M Robert M Roger M Saer M Samer M
72 Savaric M Sichar M Sigeric M Sigibert M Sigismund M Silvester M Simon M Stephan
73 M Sunnegisil M Tassilo M Terric M Terry M Theobald M Theoderic M Theudebald M
74 Theuderic M Thierry M Thomas M Thorismund M Thurstan M Umfrey M Vulfoliac M
75 Waleran M Walter M Waltgaud M Warin M Werinbert M William M Willichar M Wimarc M
76 Ymbert M Ada F Adallinda F Adaltrude F Adelina F Adofleda F Agnes F Albofleda F
77 Albreda F Aldith F Aldusa F Alice F Alina F Amabilia F Amalasuntha F Amanda F
78 Amice F Amicia F Amiria F Anabel F Annora F Arnegunde F Ascilia F Audovera F
79 Austrechild F Avelina F Avice F Avoca F Basilea F Beatrice F Bela F Beretrude F
80 Berta F Berthefled F Berthefried F Berthegund F Bertrada F Brunhild F Cecilia F
81 Celestria F Chlodosind F Chlothsinda F Cicely F Clarice F Clotild F Constance F
82 Denise F Dionisia F Edith F Eleanor F Elena F Elizabeth F Ellen F Emma F
83 Estrilda F Faileuba F Fastrada F Felicia F Fina F Fredegunde F Galswinth F
84 Gersvinda F Gisela F Goda F Goiswinth F Golda F Grecia F Gundrada F Gundrea F
85 Gundred F Gunnora F Haunild F Hawisa F Helen F Helewise F Hilda F Hildegarde F
86 Hiltrude F Ida F Idonea F Ingitrude F Ingunde F Isabel F Isolda F Joan F Joanna
87 F Julian F Juliana F Katherine F Lanthechilde F Laura F Leticia F Lettice F
88 Leubast F Leubovera F Liecia F Linota F Liutgarde F Lora F Lucia F Mabel F
89 Madelgarde F Magnatrude F Malota F Marcatrude F Marcovefa F Margaret F Margery F
90 Marsilia F Mary F Matilda F Maud F Mazelina F Millicent F Muriel F Nesta F
91 Nicola F Parnel F Petronilla F Philippa F Primeveire F Radegund F Richenda F
92 Richolda F Rigunth F Roesia F Rosamund F Rothaide F Rotrude F Ruothilde F
93 Sabelina F Sabina F Sarah F Susanna F Sybil F Sybilla F Theodelinda F Theoderada
94 F Ultrogotha F Vuldretrada F Wymarc F};
95  
96 # This slow setting allows us to find errors.
97 11 my %names;
98 11 my $last = "";
99 11 ▶while (@names) {
Branch: 1 branch
BranchTrueFalseTotal
if (@names) 3454 11 3465
100 3454 my $key = shift(@names);
101 3454 my $val = shift(@names);
102 3454 ▶ die "$last $key" unless $val =~ /^[FM?]$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $val =~ /^[FM?]$/u 0 3454 3454
103 3454 $names{$key} = $val;
104 3454 $last = $val;
105 }
106  
107 sub halfling_name {
108 25 ▶ my $name = shift || one(keys %names);
Subroutine halfling_name: called CC=2 SCAR=7.6
Pod undocumented
Condition33%1/3
shift() || one(keys %names)
l!l&&r!l&&!r
0250
MC/DC0%0/2
shift() || one(keys %names)
shift() one(keys %names)
Truth table33%1/3
A || B
A= shift()B= one(keys %names)
ABresult
1X1
011
000
109 25 my $gender = $names{$name};
110 25 return ($name, $gender);
111 }
112  
113 11 1;
« blib/lib/Game/CharacterSheetGenerator/DwarfNames.pm ↑ Summary blib/lib/Game/CharacterSheetGenerator/HumanNames.pm »