RCP/Database/Result/HazardSet.pm

filter: Statementstmt 85.1% 23 / 27 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 100% 2 / 2 totaltotal 80.5% 29 / 36 CC 2 SCAR 9.8
CC
2
Cov
79%
weight
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.7
« RCP/Setup.pm ↑ Summary RCP/Database/Result/Hazard.pm »
1 package Games::Framework::RCP::Database::Result::HazardSet;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 our $VERSION = '0.22';
7  
8 3 ▶use base qw/DBIx::Class/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 __PACKAGE__->load_components(qw/UTF8Columns Core/);
11 3 __PACKAGE__->table('hazard_sets');
12 3 __PACKAGE__->add_columns(
13 id_hazard_set => {
14 data_type => 'integer',
15 is_nullable => 0,
16 is_auto_increment => 1,
17 comments => 'ID of the hazard set.',
18 extra => {unsigned => 1},
19 },
20 name => {
21 data_type => 'varchar',
22 size => 64,
23 is_nullable => 0,
24 comments => 'Name of the hazard set.',
25 },
26 description => {
27 data_type => 'varchar',
28 size => 100,
29 is_nullable => 0,
30 comments => 'Description/flavortext of the hazard set.',
31 },
32 fkey_color => {
33 data_type => 'integer',
34 is_nullable => 1,
35 default_value => undef,
36 comments => 'Color of the hazard set.',
37 },
38 weight => {
39 data_type => 'real',
40 default_value => 1,
41 comments => 'How likely is it for this hazard set to be chosen?',
42 extra => {unsigned => 1},
43 accessor => '_weight',
44 },
45 );
46  
47 3 __PACKAGE__->utf8_columns(qw/name description/);
48 3 __PACKAGE__->set_primary_key('id_hazard_set');
49 3 __PACKAGE__->add_unique_constraint( [qw(name)] );
50  
51 3 __PACKAGE__->belongs_to(color => 'Games::Framework::RCP::Database::Result::Color', 'fkey_color');
52  
53 3 __PACKAGE__->has_many(hazard => 'Games::Framework::RCP::Database::Result::Hazard', 'fkey_hazard_set');
54  
55 2 ▶sub sqlt_deploy_hook {
Subroutine sqlt_deploy_hook: called CC=1 SCAR=0.0
Pod documented
56 2 my ($self, $sqlt_table) = @_;
57
58 2 $sqlt_table->options({ENGINE => 'InnoDB'});
59 2 $sqlt_table->options({CHARSET => 'UTF8'});
60 2 $sqlt_table->comments('The big list of hazard sets.');
61 }
62  
63 0 ▶sub weight {
Subroutine weight: not called CC=2 SCAR=17.9
Pod documented
64 0 my $self = shift;
65
66 0 my $weight = $self->_weight;
67
68 0 ▶ return 0 if $weight <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $weight <= 0 0 0 0
69
70 0 return $weight * rand;
71 }
72  
73 3 1;
74  
75 __END__
« RCP/Setup.pm ↑ Summary RCP/Database/Result/Hazard.pm »