gamefic 1.6.0 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.rubocop.yml +16 -0
- data/.solargraph.yml +5 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +7 -0
- data/LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +10 -0
- data/gamefic.gemspec +27 -0
- data/lib/gamefic.rb +11 -8
- data/lib/gamefic/action.rb +68 -58
- data/lib/gamefic/active.rb +331 -0
- data/lib/gamefic/actor.rb +8 -0
- data/lib/gamefic/command.rb +9 -7
- data/lib/gamefic/core_ext/array.rb +27 -49
- data/lib/gamefic/core_ext/string.rb +25 -16
- data/lib/gamefic/describable.rb +37 -22
- data/lib/gamefic/element.rb +47 -0
- data/lib/gamefic/entity.rb +24 -48
- data/lib/gamefic/{matchable.rb → keywords.rb} +52 -50
- data/lib/gamefic/messaging.rb +43 -45
- data/lib/gamefic/node.rb +14 -5
- data/lib/gamefic/plot.rb +73 -85
- data/lib/gamefic/plot/darkroom.rb +80 -0
- data/lib/gamefic/plot/host.rb +42 -46
- data/lib/gamefic/plot/snapshot.rb +14 -214
- data/lib/gamefic/query.rb +15 -17
- data/lib/gamefic/query/base.rb +51 -42
- data/lib/gamefic/query/children.rb +0 -0
- data/lib/gamefic/query/descendants.rb +2 -2
- data/lib/gamefic/query/external.rb +18 -0
- data/lib/gamefic/query/family.rb +3 -7
- data/lib/gamefic/query/matches.rb +75 -67
- data/lib/gamefic/query/parent.rb +0 -0
- data/lib/gamefic/query/siblings.rb +0 -0
- data/lib/gamefic/query/text.rb +12 -12
- data/lib/gamefic/query/tree.rb +17 -0
- data/lib/gamefic/scene.rb +1 -5
- data/lib/gamefic/scene/{active.rb → activity.rb} +4 -6
- data/lib/gamefic/scene/base.rb +77 -13
- data/lib/gamefic/scene/conclusion.rb +0 -2
- data/lib/gamefic/scene/custom.rb +0 -2
- data/lib/gamefic/scene/multiple_choice.rb +18 -16
- data/lib/gamefic/scene/multiple_scene.rb +29 -20
- data/lib/gamefic/scene/pause.rb +7 -2
- data/lib/gamefic/scene/yes_or_no.rb +21 -9
- data/lib/gamefic/scriptable.rb +88 -0
- data/lib/gamefic/serialize.rb +223 -0
- data/lib/gamefic/subplot.rb +47 -51
- data/lib/gamefic/syntax.rb +15 -13
- data/lib/gamefic/version.rb +3 -3
- data/lib/gamefic/world.rb +18 -0
- data/lib/gamefic/world/callbacks.rb +135 -0
- data/lib/gamefic/world/commands.rb +184 -0
- data/lib/gamefic/world/entities.rb +98 -0
- data/lib/gamefic/{plot → world}/playbook.rb +245 -236
- data/lib/gamefic/world/players.rb +37 -0
- data/lib/gamefic/world/scenes.rb +226 -0
- metadata +40 -108
- data/bin/gamefic +0 -9
- data/lib/gamefic/character.rb +0 -232
- data/lib/gamefic/character/state.rb +0 -12
- data/lib/gamefic/engine.rb +0 -7
- data/lib/gamefic/engine/base.rb +0 -66
- data/lib/gamefic/engine/tty.rb +0 -24
- data/lib/gamefic/grammar.rb +0 -13
- data/lib/gamefic/grammar/conjugator.rb +0 -20
- data/lib/gamefic/grammar/gender.rb +0 -11
- data/lib/gamefic/grammar/person.rb +0 -10
- data/lib/gamefic/grammar/plural.rb +0 -13
- data/lib/gamefic/grammar/pronouns.rb +0 -105
- data/lib/gamefic/grammar/tense.rb +0 -6
- data/lib/gamefic/grammar/verb_set.rb +0 -43
- data/lib/gamefic/grammar/verbs.rb +0 -26
- data/lib/gamefic/grammar/word_adapter.rb +0 -49
- data/lib/gamefic/plot/articles.rb +0 -22
- data/lib/gamefic/plot/callbacks.rb +0 -127
- data/lib/gamefic/plot/commands.rb +0 -121
- data/lib/gamefic/plot/entities.rb +0 -88
- data/lib/gamefic/plot/players.rb +0 -15
- data/lib/gamefic/plot/scenes.rb +0 -149
- data/lib/gamefic/plot/theater.rb +0 -73
- data/lib/gamefic/plot/you_mount.rb +0 -22
- data/lib/gamefic/script.rb +0 -13
- data/lib/gamefic/script/base.rb +0 -42
- data/lib/gamefic/script/file.rb +0 -14
- data/lib/gamefic/script/text.rb +0 -14
- data/lib/gamefic/shell.rb +0 -76
- data/lib/gamefic/source.rb +0 -14
- data/lib/gamefic/source/base.rb +0 -12
- data/lib/gamefic/source/file.rb +0 -23
- data/lib/gamefic/source/text.rb +0 -16
- data/lib/gamefic/tester.rb +0 -19
- data/lib/gamefic/text.rb +0 -8
- data/lib/gamefic/text/ansi.rb +0 -53
- data/lib/gamefic/text/html.rb +0 -68
- data/lib/gamefic/text/html/conversions.rb +0 -250
- data/lib/gamefic/text/html/entities.rb +0 -9
- data/lib/gamefic/tty.rb +0 -10
- data/lib/gamefic/user.rb +0 -8
- data/lib/gamefic/user/base.rb +0 -15
- data/lib/gamefic/user/buffer.rb +0 -32
- data/lib/gamefic/user/tty.rb +0 -54
data/lib/gamefic/tty.rb
DELETED
data/lib/gamefic/user.rb
DELETED
data/lib/gamefic/user/base.rb
DELETED
data/lib/gamefic/user/buffer.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
module Gamefic
|
2
|
-
|
3
|
-
# A simple buffer class for collecting and returning data received from
|
4
|
-
# plots.
|
5
|
-
class User::Buffer
|
6
|
-
def initialize
|
7
|
-
@data = ''
|
8
|
-
end
|
9
|
-
|
10
|
-
# Append a message to the buffer.
|
11
|
-
def send message
|
12
|
-
@data += message
|
13
|
-
end
|
14
|
-
|
15
|
-
# Read the current buffer without clearing it.
|
16
|
-
#
|
17
|
-
# @return [String]
|
18
|
-
def peek
|
19
|
-
@data
|
20
|
-
end
|
21
|
-
|
22
|
-
# Get the current data and clear the buffer.
|
23
|
-
#
|
24
|
-
# @return [String]
|
25
|
-
def flush
|
26
|
-
tmp = @data
|
27
|
-
@data = ''
|
28
|
-
tmp
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
data/lib/gamefic/user/tty.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'gamefic/engine'
|
2
|
-
require 'json'
|
3
|
-
require 'gamefic/text'
|
4
|
-
|
5
|
-
module Gamefic
|
6
|
-
|
7
|
-
# Extend User::Base to convert HTML into ANSI text.
|
8
|
-
#
|
9
|
-
# @note Due to their dependency on io/console, User::Tty and Engine::Tty are
|
10
|
-
# not included in the core Gamefic library. `require gamefic/tty` if you
|
11
|
-
# need them.
|
12
|
-
#
|
13
|
-
class User::Tty < User::Base
|
14
|
-
def update state
|
15
|
-
print Gamefic::Text::Html::Conversions.html_to_ansi(state[:output])
|
16
|
-
end
|
17
|
-
|
18
|
-
def save filename, snapshot
|
19
|
-
json = JSON.generate snapshot
|
20
|
-
if json.nil?
|
21
|
-
@character.tell "Nothing to save."
|
22
|
-
end
|
23
|
-
if filename.nil?
|
24
|
-
stream.select "Enter the filename to save:"
|
25
|
-
filename = stream.queue.pop
|
26
|
-
end
|
27
|
-
if filename != ''
|
28
|
-
File.open(filename, 'w') do |f|
|
29
|
-
f.write json
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def restore filename
|
35
|
-
if filename.nil?
|
36
|
-
stream.select "Enter the filename to restore:"
|
37
|
-
filename = stream.queue.pop
|
38
|
-
end
|
39
|
-
if filename != ''
|
40
|
-
if File.exists?(filename)
|
41
|
-
data = JSON.parse File.read(filename), symbolize_names: true
|
42
|
-
#if (data[:metadata] != @character.plot.metadata)
|
43
|
-
# @character.tell "The save file is not compatible with this version of the game."
|
44
|
-
#else
|
45
|
-
return data
|
46
|
-
#end
|
47
|
-
else
|
48
|
-
@character.tell "File \"#{filename}\" not found."
|
49
|
-
end
|
50
|
-
end
|
51
|
-
nil
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|