line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Sudoku::Component::Table::Cell;
|
2
|
|
|
|
|
|
|
{
|
3
|
5
|
|
|
5
|
|
46184
|
use strict;
|
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
643
|
|
4
|
5
|
|
|
5
|
|
30
|
use warnings;
|
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
118
|
|
5
|
5
|
|
|
5
|
|
22
|
use Carp;
|
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
430
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01';
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
24
|
use base qw/Games::Sudoku::Component::Base/;
|
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
3685
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _initialize {
|
12
|
1122
|
|
|
1122
|
|
3102
|
my ($this, %options) = @_;
|
13
|
|
|
|
|
|
|
|
14
|
1122
|
|
|
|
|
2887
|
$this->{row} = $this->_check($options{row});
|
15
|
1122
|
|
|
|
|
2904
|
$this->{col} = $this->_check($options{col});
|
16
|
|
|
|
|
|
|
|
17
|
1122
|
|
33
|
|
|
3894
|
my $perm = $options{permission} || $options{perm};
|
18
|
|
|
|
|
|
|
|
19
|
1122
|
50
|
|
|
|
2382
|
croak 'Invalid perm: '.(ref $perm)
|
20
|
|
|
|
|
|
|
if ref $perm ne 'Games::Sudoku::Component::Table::Permission';
|
21
|
|
|
|
|
|
|
|
22
|
1122
|
|
|
|
|
1647
|
$this->{perm} = $perm;
|
23
|
|
|
|
|
|
|
|
24
|
1122
|
|
|
|
|
1522
|
$this->{value} = 0;
|
25
|
1122
|
|
|
|
|
2352
|
$this->{tmpvalue} = 0;
|
26
|
|
|
|
|
|
|
|
27
|
1122
|
|
|
|
|
3359
|
$this->{locked} = 0;
|
28
|
|
|
|
|
|
|
}
|
29
|
|
|
|
|
|
|
|
30
|
691
|
|
|
691
|
1
|
3288
|
sub row { $_[0]->{row} }
|
31
|
691
|
|
|
691
|
1
|
4742
|
sub col { $_[0]->{col} }
|
32
|
595
|
100
|
|
595
|
1
|
4990
|
sub realvalue { $_[0]->{value} || 0; }
|
33
|
174
|
|
|
174
|
1
|
2827
|
sub tmpvalue { $_[0]->{tmpvalue}; }
|
34
|
|
|
|
|
|
|
|
35
|
78
|
|
|
78
|
1
|
246
|
sub lock { $_[0]->{locked} = 1; }
|
36
|
157
|
|
|
157
|
1
|
656
|
sub unlock { $_[0]->{locked} = 0; }
|
37
|
0
|
|
|
0
|
1
|
0
|
sub is_locked { $_[0]->{locked}; }
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub value {
|
40
|
1339
|
|
|
1339
|
1
|
5646
|
my ($this, $value) = @_;
|
41
|
|
|
|
|
|
|
|
42
|
1339
|
100
|
66
|
|
|
5743
|
if (defined $value && !$this->{locked}) {
|
43
|
871
|
|
|
|
|
1382
|
my $old = $this->{value};
|
44
|
871
|
|
|
|
|
1141
|
my $row = $this->{row};
|
45
|
871
|
|
|
|
|
1061
|
my $col = $this->{col};
|
46
|
|
|
|
|
|
|
|
47
|
871
|
100
|
|
|
|
1778
|
if ($old) {
|
48
|
269
|
|
|
|
|
351
|
$this->{value} = 0;
|
49
|
269
|
|
|
|
|
848
|
$this->{perm}->allow($row,$col,$old);
|
50
|
|
|
|
|
|
|
}
|
51
|
|
|
|
|
|
|
|
52
|
871
|
100
|
100
|
|
|
2963
|
if ($value && !$this->is_allowed($value)) {
|
53
|
3
|
|
|
|
|
14
|
$this->{tmpvalue} = $this->_check($value);
|
54
|
3
|
|
|
|
|
6
|
$value = 0;
|
55
|
|
|
|
|
|
|
}
|
56
|
|
|
|
|
|
|
else {
|
57
|
868
|
|
|
|
|
1420
|
$this->{tmpvalue} = 0;
|
58
|
868
|
|
|
|
|
2310
|
$this->{value} = $this->_check0($value);
|
59
|
|
|
|
|
|
|
}
|
60
|
|
|
|
|
|
|
|
61
|
871
|
100
|
|
|
|
3067
|
$this->{perm}->deny($row,$col,$value) if $value;
|
62
|
|
|
|
|
|
|
}
|
63
|
|
|
|
|
|
|
|
64
|
1339
|
100
|
100
|
|
|
9136
|
$this->{tmpvalue} || $this->{value} || 0;
|
65
|
|
|
|
|
|
|
}
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub is_allowed {
|
68
|
555
|
|
|
555
|
1
|
8162
|
my ($this, $value) = @_;
|
69
|
|
|
|
|
|
|
|
70
|
555
|
100
|
|
|
|
1499
|
return $this->{perm}->result(
|
71
|
|
|
|
|
|
|
result => 0,
|
72
|
|
|
|
|
|
|
reason => 'has other value'
|
73
|
|
|
|
|
|
|
) if $this->{value};
|
74
|
|
|
|
|
|
|
|
75
|
545
|
|
|
|
|
2273
|
$this->{perm}->is_allowed($this->{row},$this->{col},$value);
|
76
|
|
|
|
|
|
|
}
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub allowed {
|
79
|
20758
|
|
|
20758
|
1
|
28518
|
my $this = shift;
|
80
|
|
|
|
|
|
|
|
81
|
20758
|
100
|
|
|
|
75198
|
return () if $this->{value};
|
82
|
|
|
|
|
|
|
|
83
|
8174
|
|
|
|
|
28335
|
my @allowed = $this->{perm}->allowed($this->{row},$this->{col});
|
84
|
|
|
|
|
|
|
}
|
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
1
|
|
483
|
sub _permissions { $_[0]->{perm}; }
|
87
|
|
|
|
|
|
|
}
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1;
|
90
|
|
|
|
|
|
|
__END__
|