# TODO: JSON support is currently experimental. #require 'gamefic/entityloader' require 'gamefic/stage' require 'gamefic/tester' require 'gamefic/source' require 'gamefic/script' require 'gamefic/query' module Gamefic class Plot autoload :SceneMount, 'gamefic/plot/scene_mount' autoload :CommandMount, 'gamefic/plot/command_mount' autoload :EntityMount, 'gamefic/plot/entity_mount' autoload :QueryMount, 'gamefic/plot/query_mount' autoload :ArticleMount, 'gamefic/plot/article_mount' autoload :YouMount, 'gamefic/plot/you_mount' autoload :Snapshot, 'gamefic/plot/snapshot' attr_reader :commands, :imported_scripts, :rules, :asserts, :source # TODO Metadata could use better protection attr_accessor :default_scene, :metadata include Stage # TODO This include is only here to make the module's methods visible in the IDE. # Gamefic Studio has a PlotStageMetaMapper that handles it, but it doesn't run if # the plugin isn't activated. #include Gamefic, Tester, SceneMount, CommandMount, EntityMount, QueryMount, ArticleMount, YouMount, Snapshot mount Gamefic, Tester, SceneMount, CommandMount, EntityMount, QueryMount, ArticleMount, YouMount, Snapshot expose :script, :introduction, :assert_action, :before_player_update, :on_update, :on_player_update, :entities, :on_ready, :on_player_ready, :players, :scenes, :metadata # @param [Source::Base] def initialize(source = nil) @source = source || Source::Text.new({}) @commands = {} @syntaxes = [] @ready_procs = [] @before_player_update_procs = [] @update_procs = [] @player_ready = [] @player_procs = [] @working_scripts = [] @imported_scripts = [] @entities = [] @players = [] @asserts = {} @default_scene = :active post_initialize end def scenes if @scenes.nil? @scenes = {} @scenes[:active] = Scene::Active.new @scenes[:concluded] = Scene::Conclusion.new end @scenes end def concluded?(actor) scenes[actor.scene].kind_of?(Scene::Conclusion) end # Get an Array of all Actions defined in the Plot. # # @return Array[Action] def actions @commands.values.flatten end # Get an Array of all Actions associated with the specified verb. # # @param verb [Symbol] The Symbol for the verb (e.g., :go or :look) # @return Array The verb's associated Actions def actions_with_verb(verb) @commands[verb].clone || [] end # Get an Array of all scripts that have been imported into the Plot. # # @return [Array