File Coverage

blib/lib/Game/CharacterSheetGenerator/HalflingNames.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition 1 3 33.3
subroutine 4 4 100.0
pod 0 2 0.0
total 16 20 80.0


line stmt bran cond sub pod time code
1             #!/usr/bin/env perl
2             # Copyright (C) 2012-2022 Alex Schroeder
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 .
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 9     9   63 use Modern::Perl;
  9         18  
  9         94  
41 9     9   1148 use utf8;
  9         20  
  9         48  
42              
43             require Exporter;
44             our @ISA = qw(Exporter);
45             our @EXPORT_OK = qw(halfling_name);
46              
47             sub one {
48 30     30 0 94 my $i = int(rand(scalar @_));
49 30         97 return $_[$i];
50             }
51              
52             # http://themiddleages.net/people/names.html
53              
54             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             my %names;
98             my $last = "";
99             while (@names) {
100             my $key = shift(@names);
101             my $val = shift(@names);
102             die "$last $key" unless $val =~ /^[FM?]$/;
103             $names{$key} = $val;
104             $last = $val;
105             }
106              
107             sub halfling_name {
108 30   33 30 0 1575 my $name = shift || one(keys %names);
109 30         290 my $gender = $names{$name};
110 30         165 return ($name, $gender);
111             }
112              
113             1;