lib/gamefic/dispatcher.rb in gamefic-2.2.3 vs lib/gamefic/dispatcher.rb in gamefic-2.3.0
- old
+ new
@@ -7,10 +7,11 @@
# @param actions [Array<Action>]
def initialize actor, commands = [], actions = []
@actor = actor
@commands = commands
@actions = actions
+ @started = false
end
def merge dispatcher
commands.concat dispatcher.commands
actions.concat dispatcher.actions
@@ -19,17 +20,13 @@
def next
instance = nil
while instance.nil? && !@actions.empty?
action = actions.shift
commands.each do |cmd|
- instance = action.attempt(actor, cmd)
+ instance = action.attempt(actor, cmd, !@started)
if instance
- unless instance.meta?
- actor.playbooks.reverse.each do |playbook|
- return nil unless validate_playbook(playbook, instance)
- end
- end
+ @started = true
break
end
end
end
instance
@@ -64,13 +61,7 @@
# @return [Array<Command>]
attr_reader :commands
# @return [Array<Action>]
attr_reader :actions
-
- private
-
- def validate_playbook playbook, action
- playbook.validators.all? { |v| v.call(actor, action.verb, action.parameters) != false }
- end
end
end