gamefic 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gamefic/director/parser.rb +20 -2
- data/lib/gamefic/plot.rb +4 -2
- data/lib/gamefic/plot/entities.rb +7 -1
- data/lib/gamefic/plot/host.rb +1 -1
- data/lib/gamefic/stage.rb +23 -0
- data/lib/gamefic/subplot.rb +7 -2
- data/lib/gamefic/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 63846578f9f4d58fb35a150a601b8b5d16b197c8
|
|
4
|
+
data.tar.gz: 360676b4be22f3eb71661bf8ee9c63edd629207b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6a1f09d1c998ddeca48c721c0d8336479b0f1762b98f6a57f1f440f08309b33f1993585ac386d9443a4b5d616012d85c285f5d4298bd64437e025d235d52cb1f
|
|
7
|
+
data.tar.gz: 3fd2d90bb464dc6c2ed83d9a72fba6d3177b7cdd65853b740fdc77a7414b8113a8b4a5e79466fc3e1e964f01d1427d0daf30f90abe93fca7b461459ff867b76b
|
|
@@ -31,7 +31,16 @@ module Gamefic
|
|
|
31
31
|
if options.length == 0
|
|
32
32
|
tokens.unshift command
|
|
33
33
|
end
|
|
34
|
-
|
|
34
|
+
# HACK: This sort is necessary for a problem on Windows.
|
|
35
|
+
options.sort{ |a,b|
|
|
36
|
+
if a.action.specificity == b.action.specificity
|
|
37
|
+
# Newer action takes precedence
|
|
38
|
+
b.action.order_key <=> a.action.order_key
|
|
39
|
+
else
|
|
40
|
+
# Higher specificity takes precedence
|
|
41
|
+
b.action.specificity <=> a.action.specificity
|
|
42
|
+
end
|
|
43
|
+
}
|
|
35
44
|
end
|
|
36
45
|
def self.from_string(actor, command)
|
|
37
46
|
options = []
|
|
@@ -45,7 +54,16 @@ module Gamefic
|
|
|
45
54
|
options.concat bind_contexts_in_result(actor, match.arguments, action)
|
|
46
55
|
}
|
|
47
56
|
}
|
|
48
|
-
|
|
57
|
+
# HACK: This sort is necessary for a problem on Windows.
|
|
58
|
+
options.sort{ |a,b|
|
|
59
|
+
if a.action.specificity == b.action.specificity
|
|
60
|
+
# Newer action takes precedence
|
|
61
|
+
b.action.order_key <=> a.action.order_key
|
|
62
|
+
else
|
|
63
|
+
# Higher specificity takes precedence
|
|
64
|
+
b.action.specificity <=> a.action.specificity
|
|
65
|
+
end
|
|
66
|
+
}
|
|
49
67
|
end
|
|
50
68
|
class << self
|
|
51
69
|
private
|
data/lib/gamefic/plot.rb
CHANGED
|
@@ -24,8 +24,10 @@ module Gamefic
|
|
|
24
24
|
# TODO: Metadata could use better protection
|
|
25
25
|
attr_accessor :metadata
|
|
26
26
|
include Stage
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
# @!parse include Gamefic, Tester, Players, SceneMount, CommandMount, Entities
|
|
28
|
+
mount Gamefic, Tester, Players, SceneMount, CommandMount, Entities
|
|
29
|
+
# @!parse include ArticleMount, YouMount, Snapshot, Host, Callbacks
|
|
30
|
+
mount ArticleMount, YouMount, Snapshot, Host, Callbacks
|
|
29
31
|
expose :script, :metadata
|
|
30
32
|
|
|
31
33
|
# @param [Source::Base]
|
|
@@ -10,7 +10,7 @@ module Gamefic
|
|
|
10
10
|
#
|
|
11
11
|
# @param cls [Class] The Class of the Entity to be created.
|
|
12
12
|
# @param args [Hash] The entity's properties.
|
|
13
|
-
# @return
|
|
13
|
+
# @return [Entity]
|
|
14
14
|
def make cls, args = {}, &block
|
|
15
15
|
ent = cls.new args, &block
|
|
16
16
|
if ent.kind_of?(Entity) == false
|
|
@@ -55,10 +55,16 @@ module Gamefic
|
|
|
55
55
|
result.objects[0]
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
# Get an array of entities associated with this plot.
|
|
59
|
+
#
|
|
60
|
+
# @return [Array<Entity>]
|
|
58
61
|
def entities
|
|
59
62
|
p_entities.clone
|
|
60
63
|
end
|
|
61
64
|
|
|
65
|
+
# Get an array of players associated with this plot.
|
|
66
|
+
#
|
|
67
|
+
# @return [Array<Character>]
|
|
62
68
|
def players
|
|
63
69
|
p_players.clone
|
|
64
70
|
end
|
data/lib/gamefic/plot/host.rb
CHANGED
data/lib/gamefic/stage.rb
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
module Gamefic
|
|
2
2
|
|
|
3
3
|
module Stage
|
|
4
|
+
# Execute a block of code in a subset of the object's scope.
|
|
5
|
+
#
|
|
6
|
+
# An object's stage is an isolated namespace that has its own instance
|
|
7
|
+
# variables and limited access to its parent's instance methods.
|
|
4
8
|
def stage *args, &block
|
|
5
9
|
s = generate_stage
|
|
6
10
|
if block.nil?
|
|
@@ -47,6 +51,14 @@ module Gamefic
|
|
|
47
51
|
end
|
|
48
52
|
|
|
49
53
|
module ClassMethods
|
|
54
|
+
# Mount a module in this class.
|
|
55
|
+
#
|
|
56
|
+
# Mounting a module will include it like a typical mixin and expose its
|
|
57
|
+
# public methods to the stage.
|
|
58
|
+
#
|
|
59
|
+
# Assuming you have a module Foo with one public method bar,
|
|
60
|
+
# <code>mount Foo</code> is functionally equivalent to
|
|
61
|
+
# <code>include Foo; expose bar</code>.
|
|
50
62
|
def mount *args
|
|
51
63
|
args.each { |a|
|
|
52
64
|
include a
|
|
@@ -54,6 +66,17 @@ module Gamefic
|
|
|
54
66
|
}
|
|
55
67
|
end
|
|
56
68
|
|
|
69
|
+
# Give this object's stage access to an instance method.
|
|
70
|
+
#
|
|
71
|
+
# @example
|
|
72
|
+
# class Container
|
|
73
|
+
# def foobar; end
|
|
74
|
+
# expose :foobar
|
|
75
|
+
# end
|
|
76
|
+
# x = Container.new
|
|
77
|
+
# x.stage do
|
|
78
|
+
# foobar
|
|
79
|
+
# end
|
|
57
80
|
def expose *args
|
|
58
81
|
args.each { |a|
|
|
59
82
|
exposed_methods[a] = nil
|
data/lib/gamefic/subplot.rb
CHANGED
|
@@ -8,10 +8,15 @@ module Gamefic
|
|
|
8
8
|
attr_reader :plot
|
|
9
9
|
attr_writer :denied_message
|
|
10
10
|
|
|
11
|
+
# @!parse include Plot::Entities
|
|
11
12
|
mount Plot::Entities
|
|
13
|
+
# @!parse include Plot::CommandMount
|
|
12
14
|
mount Plot::CommandMount
|
|
15
|
+
# @!parse include Plot::Callbacks
|
|
13
16
|
mount Plot::Callbacks
|
|
17
|
+
# @!parse include Plot::SceneMount
|
|
14
18
|
mount Plot::SceneMount
|
|
19
|
+
|
|
15
20
|
expose :plot, :conclude
|
|
16
21
|
|
|
17
22
|
class << self
|
|
@@ -46,7 +51,7 @@ module Gamefic
|
|
|
46
51
|
@playbook ||= plot.playbook.dup
|
|
47
52
|
end
|
|
48
53
|
|
|
49
|
-
# HACK: Always assume subplots are running for the sake of entity destruction
|
|
54
|
+
# HACK: Always assume subplots are running for the sake of entity destruction
|
|
50
55
|
def running?
|
|
51
56
|
true
|
|
52
57
|
end
|
|
@@ -56,7 +61,7 @@ module Gamefic
|
|
|
56
61
|
end
|
|
57
62
|
|
|
58
63
|
def introduce player
|
|
59
|
-
if plot.
|
|
64
|
+
if plot.in_subplot?(player)
|
|
60
65
|
player.tell denied_message
|
|
61
66
|
else
|
|
62
67
|
super
|
data/lib/gamefic/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gamefic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.5.
|
|
4
|
+
version: 1.5.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: 2017-03-
|
|
11
|
+
date: 2017-03-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|