RCP/Database/Result/Hazard.pm

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