lib/gamefic/plot.rb in gamefic-1.0.0 vs lib/gamefic/plot.rb in gamefic-1.1.0
- old
+ new
@@ -3,10 +3,11 @@
require 'gamefic/stage'
require 'gamefic/tester'
require 'gamefic/source'
require 'gamefic/script'
require 'gamefic/query'
+require 'gamefic/subplot'
module Gamefic
class Plot
autoload :SceneMount, 'gamefic/plot/scene_mount'
@@ -23,12 +24,15 @@
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
+ mount Gamefic, Tester, SceneMount, CommandMount, EntityMount, QueryMount,
+ ArticleMount, YouMount, Snapshot, Subplot::Host
+ 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 = {}
@@ -42,10 +46,11 @@
@imported_scripts = []
@entities = []
@players = []
@asserts = {}
@default_scene = :active
+ @subplots = []
post_initialize
end
def scenes
if @scenes.nil?
@@ -163,10 +168,11 @@
end
# Introduce a player to the game.
# This method is typically called by the Engine that manages game execution.
def introduce(player)
+ player.extend Subplot::Feature
@players.push player
if @introduction != nil
@introduction.call(player)
end
# TODO: There should probably be a default state specified
@@ -339,10 +345,10 @@
end
used_names.push new_name
user_friendly += " #{new_name}"
args.push new_name
}
- Syntax.new self, user_friendly.strip, "#{action.verb} #{args.join(' ')}"
+ add_syntax Syntax.new(user_friendly.strip, "#{action.verb} #{args.join(' ')}")
end
def rem_action(action)
@commands[action.verb].delete(action)
end
def rem_syntax(syntax)