fictive 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fictive/choice.rb +11 -0
- data/lib/fictive/passage.rb +18 -0
- data/lib/fictive/story.rb +11 -38
- data/lib/fictive/version.rb +1 -1
- data/lib/fictive.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88bfc254e92afc19fed8f8e93619ec339b54a2e6
|
4
|
+
data.tar.gz: 64fb1b355aa5c51c7dccf384661d0b1714b1a5df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30dd9a864867c4dadd1f8e0793d897891fcd114f5282e115fed818c3df1c54daf78830573b2bb1c2fed8346a22b0bf061c09cb4ba074a987616c431819de4a28
|
7
|
+
data.tar.gz: bc5308f29f24d21fd8a1bc29c842e9c2e4b8dcf1943614b1655f7e4e319b9c2b6a74bada7dd2216e77b8b64ed59c783575c2fb5e6a4919f824e8156cfae5aa13
|
data/lib/fictive/story.rb
CHANGED
@@ -1,59 +1,32 @@
|
|
1
1
|
module Fictive
|
2
|
-
class Scene
|
3
|
-
attr_reader :passage
|
4
|
-
|
5
|
-
def initialize(metadata, passage)
|
6
|
-
@metadata = metadata
|
7
|
-
@passage = passage
|
8
|
-
end
|
9
|
-
|
10
|
-
def path
|
11
|
-
@metadata.fetch(:path)
|
12
|
-
end
|
13
|
-
|
14
|
-
def choices
|
15
|
-
@metadata.fetch(:choices, [])
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class Choice
|
20
|
-
def initialize(metadata)
|
21
|
-
@metadata = metadata
|
22
|
-
end
|
23
|
-
|
24
|
-
def path
|
25
|
-
@metadata.fetch(:path)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
2
|
class Story
|
30
3
|
def self.demo
|
31
4
|
self.new([
|
32
|
-
|
33
|
-
|
5
|
+
Passage.new({id: 'hello', choices: [Choice.new({id: 'goodbye'})]}, 'Hello world'),
|
6
|
+
Passage.new({id: 'goodbye'}, 'Goodbye world')
|
34
7
|
])
|
35
8
|
end
|
36
9
|
|
37
|
-
def initialize(
|
38
|
-
@
|
39
|
-
@
|
40
|
-
@
|
41
|
-
@
|
10
|
+
def initialize(passages)
|
11
|
+
@passages = passages
|
12
|
+
@passages_index = {}
|
13
|
+
@passages.each_with_index do |passage, id|
|
14
|
+
@passages_index[passage.id] = id
|
42
15
|
end
|
43
16
|
|
44
17
|
@index = 0
|
45
18
|
end
|
46
19
|
|
47
20
|
def has_next?
|
48
|
-
!@
|
21
|
+
!@passages.at(@index).nil? && !@passages.at(@index + 1).nil?
|
49
22
|
end
|
50
23
|
|
51
24
|
def next
|
52
|
-
@
|
25
|
+
@passages.at(@index)
|
53
26
|
end
|
54
27
|
|
55
|
-
def choose_path(
|
56
|
-
@index = @
|
28
|
+
def choose_path(id)
|
29
|
+
@index = @passages_index[id]
|
57
30
|
end
|
58
31
|
end
|
59
32
|
end
|
data/lib/fictive/version.rb
CHANGED
data/lib/fictive.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fictive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rickerby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -64,6 +64,8 @@ files:
|
|
64
64
|
- README.md
|
65
65
|
- fictive.gemspec
|
66
66
|
- lib/fictive.rb
|
67
|
+
- lib/fictive/choice.rb
|
68
|
+
- lib/fictive/passage.rb
|
67
69
|
- lib/fictive/story.rb
|
68
70
|
- lib/fictive/syntax.rb
|
69
71
|
- lib/fictive/text/compiler.rb
|