gamefic 0.0.5 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/bin/gamefic +7 -0
  3. data/lib/gamefic/character.rb +2 -0
  4. data/lib/gamefic/core_ext/string.rb +2 -2
  5. data/lib/gamefic/director.rb +36 -3
  6. data/lib/gamefic/engine.rb +9 -5
  7. data/lib/gamefic/entity.rb +1 -1
  8. data/lib/gamefic/import/basics.rb +2 -0
  9. data/lib/gamefic/import/basics/actions.rb +1 -0
  10. data/lib/gamefic/import/basics/actions/container.rb +111 -0
  11. data/lib/gamefic/import/basics/actions/inventory.rb +49 -0
  12. data/lib/gamefic/import/basics/actions/look.rb +67 -0
  13. data/lib/gamefic/import/basics/actions/meta.rb +6 -0
  14. data/lib/gamefic/import/basics/actions/traversal.rb +35 -0
  15. data/lib/gamefic/import/basics/entities.rb +1 -0
  16. data/lib/gamefic/import/basics/entities/container.rb +24 -0
  17. data/lib/gamefic/import/basics/entities/fixture.rb +5 -0
  18. data/lib/gamefic/import/basics/entities/item.rb +7 -0
  19. data/lib/gamefic/import/basics/entities/itemized.rb +3 -0
  20. data/lib/gamefic/import/basics/entities/portable.rb +3 -0
  21. data/lib/gamefic/import/basics/entities/portal.rb +43 -0
  22. data/lib/gamefic/import/basics/entities/room.rb +24 -0
  23. data/lib/gamefic/import/basics/entities/scenery.rb +3 -0
  24. data/lib/gamefic/import/basics/room_modes.rb +48 -0
  25. data/lib/gamefic/plot.rb +89 -16
  26. data/lib/gamefic/shell.rb +317 -0
  27. data/lib/gamefic/syntax.rb +1 -1
  28. data/lib/gamefic/user.rb +3 -3
  29. metadata +23 -18
  30. data/lib/gamefic/action_ext.rb +0 -7
  31. data/lib/gamefic/action_ext/container.rb +0 -114
  32. data/lib/gamefic/action_ext/inventory.rb +0 -53
  33. data/lib/gamefic/action_ext/look.rb +0 -52
  34. data/lib/gamefic/action_ext/meta.rb +0 -10
  35. data/lib/gamefic/action_ext/traversal.rb +0 -39
  36. data/lib/gamefic/entity_ext.rb +0 -7
  37. data/lib/gamefic/entity_ext/container.rb +0 -28
  38. data/lib/gamefic/entity_ext/fixture.rb +0 -9
  39. data/lib/gamefic/entity_ext/item.rb +0 -11
  40. data/lib/gamefic/entity_ext/itemized.rb +0 -7
  41. data/lib/gamefic/entity_ext/portable.rb +0 -33
  42. data/lib/gamefic/entity_ext/portal.rb +0 -47
  43. data/lib/gamefic/entity_ext/room.rb +0 -28
  44. data/lib/gamefic/entity_ext/scenery.rb +0 -7
@@ -76,7 +76,7 @@ module Gamefic
76
76
  end
77
77
  end
78
78
  else
79
- if input_words[0] == symbol
79
+ if input_words[0].downcase == symbol.downcase
80
80
  input_words.shift
81
81
  else
82
82
  break
data/lib/gamefic/user.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Gamefic
2
-
2
+
3
3
  class User
4
4
  attr_reader :state, :character, :story
5
5
  def initialize(story)
@@ -31,9 +31,10 @@ module Gamefic
31
31
  class UserStream
32
32
  def initialize
33
33
  @queue = Array.new
34
+ puts "\n"
34
35
  end
35
36
  def send(data)
36
- print data
37
+ print data.terminalize + "\n"
37
38
  end
38
39
  def select(prompt)
39
40
  print prompt
@@ -57,7 +58,6 @@ module Gamefic
57
58
  def update
58
59
  line = @user.stream.recv
59
60
  if line != nil
60
- #@user.character.perform line
61
61
  @user.character.queue.push line
62
62
  end
63
63
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamefic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-14 00:00:00.000000000 Z
11
+ date: 2014-03-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: An adventure game engine
14
14
  email: fsnyder@gamefic.com
15
- executables: []
15
+ executables:
16
+ - gamefic
16
17
  extensions: []
17
18
  extra_rdoc_files: []
18
19
  files:
19
20
  - lib/gamefic.rb
20
21
  - lib/gamefic/entity.rb
21
22
  - lib/gamefic/character.rb
22
- - lib/gamefic/action_ext.rb
23
23
  - lib/gamefic/story.rb
24
+ - lib/gamefic/shell.rb
24
25
  - lib/gamefic/base.rb
25
26
  - lib/gamefic/query.rb
26
- - lib/gamefic/entity_ext.rb
27
27
  - lib/gamefic/action.rb
28
28
  - lib/gamefic/node.rb
29
29
  - lib/gamefic/director.rb
@@ -33,21 +33,26 @@ files:
33
33
  - lib/gamefic/keywords.rb
34
34
  - lib/gamefic/syntax.rb
35
35
  - lib/gamefic/describable.rb
36
- - lib/gamefic/action_ext/look.rb
37
- - lib/gamefic/action_ext/inventory.rb
38
- - lib/gamefic/action_ext/container.rb
39
- - lib/gamefic/action_ext/meta.rb
40
- - lib/gamefic/action_ext/traversal.rb
36
+ - lib/gamefic/import/basics/room_modes.rb
37
+ - lib/gamefic/import/basics/actions/look.rb
38
+ - lib/gamefic/import/basics/actions/inventory.rb
39
+ - lib/gamefic/import/basics/actions/container.rb
40
+ - lib/gamefic/import/basics/actions/meta.rb
41
+ - lib/gamefic/import/basics/actions/traversal.rb
42
+ - lib/gamefic/import/basics/actions.rb
43
+ - lib/gamefic/import/basics/entities/fixture.rb
44
+ - lib/gamefic/import/basics/entities/item.rb
45
+ - lib/gamefic/import/basics/entities/scenery.rb
46
+ - lib/gamefic/import/basics/entities/portable.rb
47
+ - lib/gamefic/import/basics/entities/itemized.rb
48
+ - lib/gamefic/import/basics/entities/room.rb
49
+ - lib/gamefic/import/basics/entities/portal.rb
50
+ - lib/gamefic/import/basics/entities/container.rb
51
+ - lib/gamefic/import/basics/entities.rb
52
+ - lib/gamefic/import/basics.rb
41
53
  - lib/gamefic/core_ext/string.rb
42
54
  - lib/gamefic/core_ext/array.rb
43
- - lib/gamefic/entity_ext/fixture.rb
44
- - lib/gamefic/entity_ext/item.rb
45
- - lib/gamefic/entity_ext/scenery.rb
46
- - lib/gamefic/entity_ext/portable.rb
47
- - lib/gamefic/entity_ext/itemized.rb
48
- - lib/gamefic/entity_ext/room.rb
49
- - lib/gamefic/entity_ext/portal.rb
50
- - lib/gamefic/entity_ext/container.rb
55
+ - bin/gamefic
51
56
  homepage: http://gamefic.com
52
57
  licenses:
53
58
  - MIT
@@ -1,7 +0,0 @@
1
- module Gamefic
2
-
3
- Dir[File.dirname(__FILE__) + '/action_ext/*.rb'].each do |file|
4
- require file
5
- end
6
-
7
- end
@@ -1,114 +0,0 @@
1
- module Gamefic
2
-
3
- Action.new nil, :look, Query.new(:family, Container) do |actor, thing|
4
- passthru
5
- if thing.closeable?
6
- actor.tell "#{thing.longname.specify.cap_first} is #{thing.closed? ? 'closed' : 'open'}."
7
- end
8
- end
9
-
10
- Action.new nil, :look_inside, Query.new(:family, Container) do |actor, container|
11
- if container.closed?
12
- actor.tell "#{container.longname.cap_first.specify} is closed."
13
- else
14
- if container.children.length == 0
15
- actor.tell "You don't find anything."
16
- else
17
- if container.children.length == 1
18
- actor.tell "#{container.longname.specify.cap_first} contains #{container.children[0].longname}."
19
- else
20
- actor.tell "#{container.longname.specify.cap_first} contains: #{container.children.join_and(', ')}."
21
- end
22
- end
23
- end
24
- end
25
- Syntax.new nil, "look inside :container", :look_inside, :container
26
- Syntax.new nil, "search :container", :look_inside, :container
27
- Syntax.new nil, "look in :container", :look_inside, :container
28
-
29
- Action.new nil, :look_in_at, Query.new(:family, Container), Subquery.new(:children, Entity) do |actor, container, item|
30
- if container.closed?
31
- actor.tell "#{container.longname.cap_first.specify} is closed."
32
- else
33
- actor.tell item.description
34
- end
35
- end
36
-
37
- Action.new nil, :look_in_at, Query.new(:family, Container), Query.new(:string) do |actor, container, item|
38
- if container.closed?
39
- actor.tell "#{container.longname.cap_first.specify} is closed."
40
- else
41
- passthru
42
- end
43
- end
44
-
45
- Syntax.new nil, "look at :item in :container", :look_in_at, :container, :item
46
- Syntax.new nil, "look :item in :container", :look_in_at, :container, :item
47
-
48
- Action.new nil, :take_from, Query.new(:family, Container), Subquery.new(:children, Portable) do |actor, container, item|
49
- if container.closed?
50
- actor.tell "#{container.longname.cap_first.specify} is closed."
51
- else
52
- item.parent = actor
53
- actor.tell "You take #{item.longname} from #{container.longname.specify}."
54
- end
55
- end
56
- Syntax.new nil, "take :item from :container", :take_from, :container, :item
57
- Syntax.new nil, "get :item from :container", :take_from, :container, :item
58
- Syntax.new nil, "remove :item from :container", :take_from, :container, :item
59
-
60
- Action.new nil, :drop_in, Query.new(:family, Container), Query.new(:children) do |actor, container, item|
61
- if container.closed?
62
- actor.tell "#{container.longname.cap_first.specify} is closed."
63
- else
64
- item.parent = container
65
- actor.tell "You put #{item.longname} in #{container.longname}."
66
- end
67
- end
68
- Syntax.new nil, "drop :item in :container", :drop_in, :container, :item
69
- Syntax.new nil, "put :item in :container", :drop_in, :container, :item
70
- Syntax.new nil, "place :item in :container", :drop_in, :container, :item
71
-
72
- Action.new nil, :open, Query.new(:string) do |actor, string|
73
- actor.tell "You don't see any \"#{string}\" here."
74
- end
75
-
76
- Action.new nil, :open, Query.new(:family, Entity) do |actor, thing|
77
- actor.tell "You can't open #{thing.longname.specify}."
78
- end
79
-
80
- Action.new nil, :open, Query.new(:family, Container) do |actor, container|
81
- if container.closeable?
82
- if container.closed?
83
- actor.tell "You open #{container.longname.specify}."
84
- container.closed = false
85
- else
86
- actor.tell "It's already open."
87
- end
88
- else
89
- actor.tell "You can't open #{container.longname.specify}."
90
- end
91
- end
92
-
93
- Action.new nil, :close, Query.new(:string) do |actor, string|
94
- actor.tell "You don't see any \"#{string}\" here."
95
- end
96
-
97
- Action.new nil, :close, Query.new(:family, Entity) do |actor, thing|
98
- actor.tell "You can't close #{thing.longname.specify}."
99
- end
100
-
101
- Action.new nil, :close, Query.new(:family, Container) do |actor, container|
102
- if container.closeable?
103
- if container.closed?
104
- actor.tell "It's already closed."
105
- else
106
- actor.tell "You close #{container.longname.specify}."
107
- container.closed = true
108
- end
109
- else
110
- actor.tell "You can't close #{container.longname.specify}."
111
- end
112
- end
113
-
114
- end
@@ -1,53 +0,0 @@
1
- module Gamefic
2
-
3
- Action.new nil, :inventory do |actor|
4
- if actor.children.length > 0
5
- actor.tell actor.children.join(', ')
6
- else
7
- actor.tell "You aren't carrying anything."
8
- end
9
- end
10
- Syntax.new nil, "i", :inventory
11
-
12
- Action.new nil, :take, Query.new(:siblings, Portable) do |actor, thing|
13
- thing.parent = actor
14
- actor.tell "You take #{thing.longname.specify}.", true
15
- end
16
-
17
- Action.new nil, :take, Query.new(:siblings) do |actor, thing|
18
- actor.tell "You can't carry #{thing.longname.specify}."
19
- end
20
-
21
- Action.new nil, :take, Query.new(:string) do |actor, thing|
22
- containers = actor.children.that_are(Container)
23
- containers = containers + actor.parent.children.that_are(Container)
24
- found = false
25
- containers.each { |container|
26
- if container.closed? == false
27
- query = Query.new(:children, Portable)
28
- result = query.execute(container, thing)
29
- if result.objects.length == 1
30
- found = true
31
- actor.perform "take #{result.objects[0].longname} from #{container.longname}"
32
- break
33
- end
34
- end
35
- }
36
- if found == false
37
- actor.tell "You don't see anything called \"#{thing}\" here."
38
- end
39
- end
40
-
41
- Action.new nil, :drop, Query.new(:children) do |actor, thing|
42
- thing.parent = actor.parent
43
- actor.tell "You drop #{thing.longname.specify}.", true
44
- end
45
-
46
- Syntax.new nil, "get :thing", :take, :thing
47
- Syntax.new nil, "pick :thing up", :take, :thing
48
- Syntax.new nil, "pick up :thing", :take, :thing
49
-
50
- Syntax.new nil, "put down :thing", :drop, :thing
51
- Syntax.new nil, "put :thing down", :drop, :thing
52
-
53
- end
@@ -1,52 +0,0 @@
1
- module Gamefic
2
-
3
- Action.new nil, :look do |actor|
4
- actor.perform "itemize room full"
5
- end
6
-
7
- Action.new nil, :look_around do |actor|
8
- actor.perform "look"
9
- end
10
-
11
- Action.new nil, :itemize_room, Query.new(:string) do |actor, option|
12
- actor.tell "## #{actor.parent.longname.cap_first}"
13
- if option == "full"
14
- actor.tell actor.parent.description
15
- end
16
- chars = actor.parent.children.that_are(Character) - [actor]
17
- if chars.length > 0
18
- actor.tell "Others here: #{chars.join(", ")}"
19
- end
20
- #items = actor.parent.children.that_are(Itemized) - [chars] - [actor] - actor.parent.children.that_are(Portal)
21
- items = actor.parent.children.that_are(Itemized)
22
- if items.length > 0
23
- actor.tell "Visible items: #{items.join(", ")}"
24
- end
25
- portals = actor.parent.children.that_are(Portal)
26
- if portals.length > 0
27
- actor.tell "Obvious exits: #{portals.join(', ')}"
28
- else
29
- actor.tell "Obvious exits: none"
30
- end
31
- end
32
- Syntax.new nil, "itemize room", :itemize_room, "short"
33
- Syntax.new nil, "itemize room :option", :itemize_room, :option
34
-
35
- Action.new nil, :look, Query.new(:family) do |actor, thing|
36
- actor.tell thing.description
37
- end
38
-
39
- Action.new nil, :look, Query.new(:parent) do |actor, thing|
40
- actor.perform "look"
41
- end
42
-
43
- Action.new nil, :look, String do |actor, string|
44
- actor.tell "You don't see any \"#{string}\" here."
45
- end
46
-
47
- Syntax.new nil, "look at :thing", :look, :thing
48
- Syntax.new nil, "examine :thing", :look, :thing
49
- Syntax.new nil, "exam :thing", :look, :thing
50
- Syntax.new nil, "x :thing", :look, :thing
51
-
52
- end
@@ -1,10 +0,0 @@
1
- module Gamefic
2
-
3
- Action.new nil, :quit do |actor|
4
- actor.destroy
5
- end
6
- Action.new nil, :commands do |actor|
7
- actor.tell actor.plot.commandwords.sort.join(", ")
8
- end
9
-
10
- end
@@ -1,39 +0,0 @@
1
- module Gamefic
2
-
3
- Action.new nil, :go, Query.new(:siblings, Portal) do |actor, portal|
4
- actor.parent = portal.destination
5
- actor.tell "You go #{portal.name}."
6
- actor.perform "itemize room"
7
- end
8
-
9
- Action.new nil, :go, String do |actor, string|
10
- actor.tell "You don't see any exit \"#{string}\" from here."
11
- end
12
-
13
- Action.new nil, :go do |actor|
14
- actor.tell "Where do you want to go?"
15
- end
16
-
17
- Syntax.new nil, "north", :go, "north"
18
- Syntax.new nil, "south", :go, "south"
19
- Syntax.new nil, "west", :go, "west"
20
- Syntax.new nil, "east", :go, "east"
21
- Syntax.new nil, "up", :go, "up"
22
- Syntax.new nil, "down", :go, "down"
23
- Syntax.new nil, "northwest", :go, "northwest"
24
- Syntax.new nil, "northeast", :go, "northeast"
25
- Syntax.new nil, "southwest", :go, "southwest"
26
- Syntax.new nil, "southeast", :go, "southeast"
27
-
28
- Syntax.new nil, "n", :go, "north"
29
- Syntax.new nil, "s", :go, "south"
30
- Syntax.new nil, "w", :go, "west"
31
- Syntax.new nil, "e", :go, "east"
32
- Syntax.new nil, "u", :go, "up"
33
- Syntax.new nil, "d", :go, "down"
34
- Syntax.new nil, "nw", :go, "northwest"
35
- Syntax.new nil, "ne", :go, "northeast"
36
- Syntax.new nil, "sw", :go, "southwest"
37
- Syntax.new nil, "se", :go, "southeast"
38
-
39
- end
@@ -1,7 +0,0 @@
1
- module Gamefic
2
-
3
- Dir[File.dirname(__FILE__) + '/entity_ext/*.rb'].each do |file|
4
- require file
5
- end
6
-
7
- end
@@ -1,28 +0,0 @@
1
- require "gamefic/entity_ext/itemized"
2
-
3
- module Gamefic
4
-
5
- class Container < Entity
6
- include Itemized
7
- def closeable=(bool)
8
- @closeable = bool
9
- end
10
- def closeable?
11
- @closeable ||= false
12
- if (@closeable == true && @closed == nil)
13
- @closed = false
14
- end
15
- @closeable
16
- end
17
- def closed?
18
- (@closed == true)
19
- end
20
- def closed=(bool)
21
- if bool == true
22
- @closeable = true
23
- end
24
- @closed = bool
25
- end
26
- end
27
-
28
- end
@@ -1,9 +0,0 @@
1
- require "gamefic/entity_ext/itemized"
2
-
3
- module Gamefic
4
-
5
- class Fixture < Entity
6
- include Itemized
7
- end
8
-
9
- end