| 1 | package Language::Homespring::Snowmelt; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | $VERSION = 0.01; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 31 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 9 | 31 | my $class = shift; | |||||||||||||||||||||||||||
| 10 | 31 | my $self = bless {}, $class; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 31 | my $options = shift; | |||||||||||||||||||||||||||
| 13 | 31 | $self->{interp} = $options->{interp}; | |||||||||||||||||||||||||||
| 14 | 31 | $self->{time_at_node} = 0; | |||||||||||||||||||||||||||
| 15 | 31 | $self->{location} = $options->{location}; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 31 | return $self; | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 114 | ▶ | sub move { | ||||||||||||||||||||||||||
|
Subroutine
move: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | 114 | my ($self) = @_; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 114 | $self->{time_at_node}++; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | # see if we can leave the current node | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 114 | ▶ | return if (($self->{location}->{node_name} eq 'marshy') && ($self->{time_at_node} == 1)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"location"}{"node_name"} eq "marshy" and $self->{"time_at_node"} == 1
MC/DC100%2/2
$self->{"location"}{"node_name"} eq "marshy" and $self->{"time_at_node"} == 1
$self->{"location"}{"node_name"} eq "marshy"
$self->{"time_at_node"} == 1
Truth table100%3/3
A and B
A= $self->{"location"}{"node_name"} eq "marshy"B= $self->{"time_at_node"} == 1
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # see if we can enter the next one | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 86 | my $dest = $self->{location}->{parent_node}; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 86 | ▶ | if (defined($dest)){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 81 | $self->{location} = $dest; | |||||||||||||||||||||||||||
| 35 | 81 | $self->{time_at_node} = 0; | |||||||||||||||||||||||||||
| 36 | 81 | $self->smash(); | |||||||||||||||||||||||||||
| 37 | }else{ | ||||||||||||||||||||||||||||
| 38 | # if there's nowhere to go, | ||||||||||||||||||||||||||||
| 39 | 5 | $self->kill(); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 5 | ▶ | sub kill { | ||||||||||||||||||||||||||
|
Subroutine
kill: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 45 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||
| 46 | 5 | @{$self->{interp}->{snowmelt}} = grep{ | |||||||||||||||||||||||||||
| 47 | 32 | $_ ne $self | |||||||||||||||||||||||||||
| 48 | 5 | }@{$self->{interp}->{snowmelt}}; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 81 | ▶ | sub smash { | ||||||||||||||||||||||||||
|
Subroutine
smash: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 52 | 81 | my ($self) = @_; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | # smash stuff at the current node | ||||||||||||||||||||||||||||
| 55 | 81 | my $node_name = $self->{location}->{node_name}; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | #print "Smashing up a $node_name...\n"; | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 81 | $self->{location}->{destroyed} = 1; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 81 | ▶ | if ($node_name eq 'universe'){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 2 | $self->{interp}->{universe_ok} = 0; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 4 | 1; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||