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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 567c41f4ddc68dcf42fcb5952d6279250100f117
4
- data.tar.gz: 7d2b9383cc049ab220917377ae7c76a7d4adc694
3
+ metadata.gz: 63846578f9f4d58fb35a150a601b8b5d16b197c8
4
+ data.tar.gz: 360676b4be22f3eb71661bf8ee9c63edd629207b
5
5
  SHA512:
6
- metadata.gz: 3ce9c4b0051c2e64591b7a08ce693d2817b9c66e94240e3f4ae52ecb012b0e89355ca692efe01dbd502d1590d18e05755c93d96cd2c695e7a4ae068b6e5f8e66
7
- data.tar.gz: 318903449d67116cf8da824a29c845180516de69ba4344d1f45499acef3f6cc5c728e3fb31641010dca3735a8a786835a4447a4dea5405a941dd482dcf014ce3
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
- options.sort{ |a,b| b.action.specificity <=> a.action.specificity }
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
- options.sort{ |a,b| b.action.specificity <=> a.action.specificity }
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
@@ -24,8 +24,10 @@ module Gamefic
24
24
  # TODO: Metadata could use better protection
25
25
  attr_accessor :metadata
26
26
  include Stage
27
- mount Gamefic, Tester, Players, SceneMount, CommandMount, Entities,
28
- ArticleMount, YouMount, Snapshot, Host, Callbacks
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 The Entity instance.
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
@@ -33,7 +33,7 @@ module Gamefic
33
33
  # Determine whether the player is involved in a subplot.
34
34
  #
35
35
  # @return [Boolean]
36
- def subbed? player
36
+ def in_subplot? player
37
37
  !subplot_for(player).nil?
38
38
  end
39
39
 
@@ -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
@@ -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.subbed?(player)
64
+ if plot.in_subplot?(player)
60
65
  player.tell denied_message
61
66
  else
62
67
  super
@@ -1,3 +1,3 @@
1
1
  module Gamefic
2
- VERSION = '1.5.0'
2
+ VERSION = '1.5.1'
3
3
  end
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.0
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-14 00:00:00.000000000 Z
11
+ date: 2017-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor