line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
91
|
use 5.010001; |
|
5
|
|
|
|
|
24
|
|
2
|
5
|
|
|
5
|
|
59
|
use strict; |
|
5
|
|
|
|
|
30
|
|
|
5
|
|
|
|
|
100
|
|
3
|
5
|
|
|
5
|
|
22
|
use warnings; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
293
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Story::Interact::Syntax; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.001012'; |
9
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
32
|
use Story::Interact::Page (); |
|
5
|
|
|
|
|
24
|
|
|
5
|
|
|
|
|
170
|
|
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
77
|
use List::Util (); |
|
5
|
|
|
|
|
41
|
|
|
5
|
|
|
|
|
168
|
|
13
|
5
|
|
|
5
|
|
2660
|
use match::simple qw( match ); |
|
5
|
|
|
|
|
12954
|
|
|
5
|
|
|
|
|
55
|
|
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
5
|
|
3799
|
use Exporter::Shiny; |
|
5
|
|
|
|
|
2510
|
|
|
5
|
|
|
|
|
51
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @EXPORT = qw( |
18
|
|
|
|
|
|
|
text |
19
|
|
|
|
|
|
|
next_page |
20
|
|
|
|
|
|
|
at |
21
|
|
|
|
|
|
|
abstract |
22
|
|
|
|
|
|
|
todo |
23
|
|
|
|
|
|
|
world |
24
|
|
|
|
|
|
|
location |
25
|
|
|
|
|
|
|
player |
26
|
|
|
|
|
|
|
npc |
27
|
|
|
|
|
|
|
define_npc |
28
|
|
|
|
|
|
|
visited |
29
|
|
|
|
|
|
|
params |
30
|
|
|
|
|
|
|
true |
31
|
|
|
|
|
|
|
false |
32
|
|
|
|
|
|
|
match |
33
|
|
|
|
|
|
|
random |
34
|
|
|
|
|
|
|
INTERNAL_STATE |
35
|
|
|
|
|
|
|
INTERNAL_PAGE |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my ( $page, $state ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub START { |
41
|
45
|
|
|
45
|
0
|
124
|
( $state, my $page_id ) = @_; |
42
|
45
|
|
|
|
|
895
|
$page = Story::Interact::Page->new( id => $page_id ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub text { |
46
|
65
|
|
|
65
|
0
|
261
|
$page->add_text( @_ ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub next_page { |
50
|
74
|
|
|
74
|
0
|
250
|
$page->add_next_page( @_ ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub at { |
54
|
52
|
100
|
|
52
|
0
|
209
|
if ( @_ ) { |
55
|
40
|
|
|
|
|
118
|
my ( $code ) = @_; |
56
|
40
|
|
|
|
|
979
|
$page->_set_location( $code ); |
57
|
|
|
|
|
|
|
} |
58
|
52
|
|
|
|
|
1921
|
return $page->location; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub todo { |
62
|
0
|
0
|
|
0
|
0
|
0
|
if ( @_ ) { |
63
|
0
|
|
|
|
|
0
|
my ( $value ) = @_; |
64
|
0
|
|
|
|
|
0
|
$page->_set_todo( $value ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
else { |
67
|
0
|
|
|
|
|
0
|
$page->_set_todo( 1 ); |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
0
|
return; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub abstract { |
73
|
0
|
0
|
|
0
|
0
|
0
|
if ( @_ ) { |
74
|
0
|
|
|
|
|
0
|
my ( $value ) = @_; |
75
|
0
|
|
|
|
|
0
|
$page->_set_abstract( $value ); |
76
|
|
|
|
|
|
|
} |
77
|
0
|
|
|
|
|
0
|
return $page->abstract; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub world () { |
81
|
0
|
|
|
0
|
0
|
0
|
return $state->world; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub location { |
85
|
12
|
50
|
|
12
|
0
|
41
|
my ( $code ) = @_ ? @_ : ( at() ); |
86
|
12
|
|
100
|
|
|
319
|
$state->location->{$code} //= {}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub player () { |
90
|
10
|
|
|
10
|
0
|
49
|
return $state->player; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub npc ($) { |
94
|
1
|
|
|
1
|
0
|
4
|
my ( $code ) = @_; |
95
|
1
|
|
|
|
|
25
|
return $state->character->{$code}; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub define_npc { |
99
|
1
|
|
|
1
|
0
|
6
|
my ( $code, %attrs ) = @_; |
100
|
1
|
|
|
|
|
11
|
return $state->define_npc( $code, %attrs ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub visited { |
104
|
6
|
50
|
|
6
|
0
|
31
|
my ( $code ) = @_ ? @_ : ( $page->id ); |
105
|
6
|
|
50
|
|
|
81
|
$state->visited->{$code} //= 0; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub params () { |
109
|
2
|
|
|
2
|
0
|
50
|
return $state->params; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub FINISH { |
113
|
45
|
|
|
45
|
0
|
182
|
$state->update_from_page( $page ); |
114
|
45
|
|
|
|
|
75
|
my $return = $page; |
115
|
45
|
|
|
|
|
76
|
undef $page; |
116
|
45
|
|
|
|
|
180
|
return $return; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub pp { |
120
|
0
|
|
|
0
|
0
|
|
require JSON::PP; |
121
|
0
|
|
|
|
|
|
print JSON::PP |
122
|
|
|
|
|
|
|
->new |
123
|
|
|
|
|
|
|
->pretty( 1 ) |
124
|
|
|
|
|
|
|
->canonical( 1 ) |
125
|
|
|
|
|
|
|
->convert_blessed( 1 ) |
126
|
|
|
|
|
|
|
->encode( shift ), "\n"; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub DEBUG { |
130
|
0
|
|
|
0
|
0
|
|
eval( shift() . ";" ); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub true () { |
134
|
|
|
|
|
|
|
!!1; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub false () { |
138
|
|
|
|
|
|
|
!!0; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub INTERNAL_STATE () { |
142
|
0
|
|
|
0
|
0
|
|
return $state; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub INTERNAL_PAGE () { |
146
|
0
|
|
|
0
|
0
|
|
return $page; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub random ($) { |
150
|
0
|
|
|
0
|
0
|
|
my ( $array ) = @_; |
151
|
0
|
|
|
|
|
|
my ( $item ) = List::Util::sample( 1, @$array ); |
152
|
0
|
|
|
|
|
|
return $item; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
1; |