lib/BalanceOfPower/Relations/Influence.pm

filter: Statementstmt 29.8% 17 / 57 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 30.7% 4 / 13 Podpod 0.0% 0 / 9 totaltotal 17.6% 21 / 119 CC 15 SCAR 27.3
CC
15
Cov
19%
click
30.0
status_label
20.0
get_loot_quote
20.0
CRAP 15.3
« blib/lib/BalanceOfPower/Dice.pm ↑ Summary lib/BalanceOfPower/Commands/DeclareWar.pm »
1 package BalanceOfPower::Relations::Influence;
2 11 $BalanceOfPower::Relations::Influence::VERSION = '0.300010';
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use BalanceOfPower::Constants ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 11 with 'BalanceOfPower::Relations::Role::Relation';
11  
12 # Status:
13 # 0: occupy
14 # 1: dominate
15 # 2: control
16  
17 11 has status => (
18 is => 'rw',
19 default => -1
20 );
21 11 has next => (
22 is => 'rw',
23 default => -1
24 );
25 11 has clock => (
26 is => 'rw',
27 default => 0
28 );
29 sub bidirectional
30 {
31 0 ▶ return 0;
Subroutine bidirectional: not called CC=1 SCAR=6.9
Pod undocumented
32 }
33 sub status_label
34 {
35 0 ▶ my $self = shift;
Subroutine status_label: not called CC=4 SCAR=30.0
Pod undocumented
36 0 ▶ if($self->status == 0)
Branch: 3 branches
BranchTrueFalseTotal
if ($self->status == 0) { } 0 0 0
elsif ($self->status == 1) { } 0 0 0
elsif ($self->status == 2) { } 0 0 0
37 {
38 0 return 'occupy';
39 }
40 elsif($self->status == 1)
41 {
42 0 return 'dominate';
43 }
44 elsif($self->status == 2)
45 {
46 0 return 'control';
47 }
48 else
49 {
50 0 return undef;
51 }
52 }
53 sub get_loot_quote
54 {
55 0 ▶ my $self = shift;
Subroutine get_loot_quote: not called CC=4 SCAR=30.0
Pod undocumented
56 0 ▶ if($self->status == 0)
Branch: 3 branches
BranchTrueFalseTotal
if ($self->status == 0) { } 0 0 0
elsif ($self->status == 1) { } 0 0 0
elsif ($self->status == 2) { } 0 0 0
57 {
58 0 return OCCUPATION_LOOT_BY_TYPE
59 }
60 elsif($self->status == 1)
61 {
62 0 return DOMINATION_LOOT_BY_TYPE;
63 }
64 elsif($self->status == 2)
65 {
66 0 return CONTROL_LOOT_BY_TYPE;
67 }
68 else
69 {
70 0 return undef;
71 }
72 }
73 sub click
74 {
75 0 ▶ my $self = shift;
Subroutine click: not called CC=5 SCAR=34.0
Pod undocumented
76 0 $self->clock($self->clock + 1);
77 0 ▶ if($self->status == 0 && $self->clock >= OCCUPATION_CLOCK_LIMIT)
Branch: 2 branches
BranchTrueFalseTotal
if ($self->status == 0 and $self->clock >= 1) { } 0 0 0
elsif ($self->status == 1 and $self->clock >= 5) { } 0 0 0
Condition0%0/3
$self->status == 0 and $self->clock >= 1
!ll&&!rl&&r
000
MC/DC0%0/2
$self->status == 0 and $self->clock >= 1
$self->status == 0 $self->clock >= 1
Truth table0%0/3
A and B
A= $self->status == 0B= $self->clock >= 1
ABresult
0X0
100
111
78 {
79 0 return $self->change_to_next();
80 }
81 ▶ elsif($self->status == 1 && $self->clock >= DOMINATION_CLOCK_LIMIT)
Condition0%0/3
$self->status == 1 and $self->clock >= 5
!ll&&!rl&&r
000
MC/DC0%0/2
$self->status == 1 and $self->clock >= 5
$self->status == 1 $self->clock >= 5
Truth table0%0/3
A and B
A= $self->status == 1B= $self->clock >= 5
ABresult
0X0
100
111
82 {
83 0 return $self->change_to_next();
84 }
85 else
86 {
87 0 return $self->status;
88 }
89 }
90 sub change_to_next
91 {
92 0 ▶ my $self = shift;
Subroutine change_to_next: not called CC=1 SCAR=6.9
Pod undocumented
93 0 $self->status($self->next);
94 0 $self->clock(0);
95 0 return $self->status_label;
96 }
97 sub print
98 {
99 0 ▶ my $self = shift;
Subroutine print: not called CC=1 SCAR=6.9
Pod undocumented
100 0 return $self->node1 . " " . $self->status_label . " " . $self->node2;
101 }
102 sub actual_influence
103 {
104 0 ▶ my $self = shift;
Subroutine actual_influence: not called CC=4 SCAR=30.0
Pod undocumented
105 0 ▶ if(($self->status == 1 && $self->next != -1) ||
Branch: 1 branch
BranchTrueFalseTotal
if ($self->status == 1 and $self->next != -1 or $_->status > 1) { } 0 0 0
Condition0%0/6
$self->status == 1 and $self->next != -1 or $_->status > 1
l!l&&r!l&&!r
000
$self->status == 1 and $self->next != -1
!ll&&!rl&&r
000
MC/DC0%0/3
$self->status == 1 and $self->next != -1 or $_->status > 1
$self->status == 1 $self->next != -1 $_->status > 1
Truth table0%0/5
A and B or C
A= $self->status == 1B= $self->next != -1C= $_->status > 1
ABCresult
11X1
0X11
1011
0X00
1000
106 $_->status > 1)
107 {
108 0 return 1;
109 }
110 else
111 {
112 0 return 0;
113 }
114 }
115 sub dump
116 {
117 0 ▶ my $self = shift;
Subroutine dump: not called CC=2 SCAR=17.9
Pod undocumented
118 0 my $io = shift;
119 0 ▶ my $indent = shift || "";
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
120 0 print {$io} $indent . join(";", $self->node1, $self->node2, $self->status, $self->next, $self->clock) . "\n";
121 }
122 sub load
123 {
124 0 ▶ my $self = shift;
Subroutine load: not called CC=1 SCAR=6.9
Pod undocumented
125 0 my $data = shift;
126 0 $data =~ s/^\s+//;
127 0 chomp $data;
128 0 my ($node1, $node2, $status, $next, $clock) = split ";", $data;
129 0 return $self->new(node1 => $node1, node2 => $node2, status => $status, next => $next, clock => $clock);
130 }
131  
132  
133 11 1;
« blib/lib/BalanceOfPower/Dice.pm ↑ Summary lib/BalanceOfPower/Commands/DeclareWar.pm »