gamefic 1.6.0 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +16 -0
  5. data/.solargraph.yml +5 -0
  6. data/CHANGELOG.md +6 -0
  7. data/Gemfile +7 -0
  8. data/LICENSE +20 -0
  9. data/README.md +28 -0
  10. data/Rakefile +10 -0
  11. data/gamefic.gemspec +27 -0
  12. data/lib/gamefic.rb +11 -8
  13. data/lib/gamefic/action.rb +68 -58
  14. data/lib/gamefic/active.rb +331 -0
  15. data/lib/gamefic/actor.rb +8 -0
  16. data/lib/gamefic/command.rb +9 -7
  17. data/lib/gamefic/core_ext/array.rb +27 -49
  18. data/lib/gamefic/core_ext/string.rb +25 -16
  19. data/lib/gamefic/describable.rb +37 -22
  20. data/lib/gamefic/element.rb +47 -0
  21. data/lib/gamefic/entity.rb +24 -48
  22. data/lib/gamefic/{matchable.rb → keywords.rb} +52 -50
  23. data/lib/gamefic/messaging.rb +43 -45
  24. data/lib/gamefic/node.rb +14 -5
  25. data/lib/gamefic/plot.rb +73 -85
  26. data/lib/gamefic/plot/darkroom.rb +80 -0
  27. data/lib/gamefic/plot/host.rb +42 -46
  28. data/lib/gamefic/plot/snapshot.rb +14 -214
  29. data/lib/gamefic/query.rb +15 -17
  30. data/lib/gamefic/query/base.rb +51 -42
  31. data/lib/gamefic/query/children.rb +0 -0
  32. data/lib/gamefic/query/descendants.rb +2 -2
  33. data/lib/gamefic/query/external.rb +18 -0
  34. data/lib/gamefic/query/family.rb +3 -7
  35. data/lib/gamefic/query/matches.rb +75 -67
  36. data/lib/gamefic/query/parent.rb +0 -0
  37. data/lib/gamefic/query/siblings.rb +0 -0
  38. data/lib/gamefic/query/text.rb +12 -12
  39. data/lib/gamefic/query/tree.rb +17 -0
  40. data/lib/gamefic/scene.rb +1 -5
  41. data/lib/gamefic/scene/{active.rb → activity.rb} +4 -6
  42. data/lib/gamefic/scene/base.rb +77 -13
  43. data/lib/gamefic/scene/conclusion.rb +0 -2
  44. data/lib/gamefic/scene/custom.rb +0 -2
  45. data/lib/gamefic/scene/multiple_choice.rb +18 -16
  46. data/lib/gamefic/scene/multiple_scene.rb +29 -20
  47. data/lib/gamefic/scene/pause.rb +7 -2
  48. data/lib/gamefic/scene/yes_or_no.rb +21 -9
  49. data/lib/gamefic/scriptable.rb +88 -0
  50. data/lib/gamefic/serialize.rb +223 -0
  51. data/lib/gamefic/subplot.rb +47 -51
  52. data/lib/gamefic/syntax.rb +15 -13
  53. data/lib/gamefic/version.rb +3 -3
  54. data/lib/gamefic/world.rb +18 -0
  55. data/lib/gamefic/world/callbacks.rb +135 -0
  56. data/lib/gamefic/world/commands.rb +184 -0
  57. data/lib/gamefic/world/entities.rb +98 -0
  58. data/lib/gamefic/{plot → world}/playbook.rb +245 -236
  59. data/lib/gamefic/world/players.rb +37 -0
  60. data/lib/gamefic/world/scenes.rb +226 -0
  61. metadata +40 -108
  62. data/bin/gamefic +0 -9
  63. data/lib/gamefic/character.rb +0 -232
  64. data/lib/gamefic/character/state.rb +0 -12
  65. data/lib/gamefic/engine.rb +0 -7
  66. data/lib/gamefic/engine/base.rb +0 -66
  67. data/lib/gamefic/engine/tty.rb +0 -24
  68. data/lib/gamefic/grammar.rb +0 -13
  69. data/lib/gamefic/grammar/conjugator.rb +0 -20
  70. data/lib/gamefic/grammar/gender.rb +0 -11
  71. data/lib/gamefic/grammar/person.rb +0 -10
  72. data/lib/gamefic/grammar/plural.rb +0 -13
  73. data/lib/gamefic/grammar/pronouns.rb +0 -105
  74. data/lib/gamefic/grammar/tense.rb +0 -6
  75. data/lib/gamefic/grammar/verb_set.rb +0 -43
  76. data/lib/gamefic/grammar/verbs.rb +0 -26
  77. data/lib/gamefic/grammar/word_adapter.rb +0 -49
  78. data/lib/gamefic/plot/articles.rb +0 -22
  79. data/lib/gamefic/plot/callbacks.rb +0 -127
  80. data/lib/gamefic/plot/commands.rb +0 -121
  81. data/lib/gamefic/plot/entities.rb +0 -88
  82. data/lib/gamefic/plot/players.rb +0 -15
  83. data/lib/gamefic/plot/scenes.rb +0 -149
  84. data/lib/gamefic/plot/theater.rb +0 -73
  85. data/lib/gamefic/plot/you_mount.rb +0 -22
  86. data/lib/gamefic/script.rb +0 -13
  87. data/lib/gamefic/script/base.rb +0 -42
  88. data/lib/gamefic/script/file.rb +0 -14
  89. data/lib/gamefic/script/text.rb +0 -14
  90. data/lib/gamefic/shell.rb +0 -76
  91. data/lib/gamefic/source.rb +0 -14
  92. data/lib/gamefic/source/base.rb +0 -12
  93. data/lib/gamefic/source/file.rb +0 -23
  94. data/lib/gamefic/source/text.rb +0 -16
  95. data/lib/gamefic/tester.rb +0 -19
  96. data/lib/gamefic/text.rb +0 -8
  97. data/lib/gamefic/text/ansi.rb +0 -53
  98. data/lib/gamefic/text/html.rb +0 -68
  99. data/lib/gamefic/text/html/conversions.rb +0 -250
  100. data/lib/gamefic/text/html/entities.rb +0 -9
  101. data/lib/gamefic/tty.rb +0 -10
  102. data/lib/gamefic/user.rb +0 -8
  103. data/lib/gamefic/user/base.rb +0 -15
  104. data/lib/gamefic/user/buffer.rb +0 -32
  105. data/lib/gamefic/user/tty.rb +0 -54
@@ -1,10 +0,0 @@
1
- require 'gamefic/text'
2
-
3
- module Gamefic
4
- module Engine
5
- autoload :Tty, 'gamefic/engine/tty'
6
- end
7
- module User
8
- autoload :Tty, 'gamefic/user/tty'
9
- end
10
- end
@@ -1,8 +0,0 @@
1
- module Gamefic
2
-
3
- module User
4
- autoload :Base, 'gamefic/user/base'
5
- autoload :Buffer, 'gamefic/user/buffer'
6
- end
7
-
8
- end
@@ -1,15 +0,0 @@
1
- module Gamefic
2
- class User::Base
3
- def update state
4
- raise 'Unimplemented'
5
- end
6
-
7
- def save filename, snapshot
8
- raise 'Unimplemented'
9
- end
10
-
11
- def restore filename
12
- raise 'Unimplemented'
13
- end
14
- end
15
- end
@@ -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
@@ -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