lib/gamefic/plot.rb in gamefic-1.6.0 vs lib/gamefic/plot.rb in gamefic-1.7.0

- old
+ new

@@ -1,7 +1,5 @@ -# TODO: JSON support is currently experimental. -#require 'gamefic/entityloader' require 'gamefic/tester' require 'gamefic/source' require 'gamefic/script' require 'gamefic/query' @@ -12,17 +10,19 @@ autoload :Commands, 'gamefic/plot/commands' autoload :Entities, 'gamefic/plot/entities' autoload :Articles, 'gamefic/plot/articles' autoload :YouMount, 'gamefic/plot/you_mount' autoload :Snapshot, 'gamefic/plot/snapshot' + autoload :Darkroom, 'gamefic/plot/darkroom' autoload :Host, 'gamefic/plot/host' autoload :Players, 'gamefic/plot/players' autoload :Playbook, 'gamefic/plot/playbook' autoload :Callbacks, 'gamefic/plot/callbacks' autoload :Theater, 'gamefic/plot/theater' attr_reader :commands, :imported_scripts, :source + # TODO: Metadata could use better protection attr_accessor :metadata include Theater include Gamefic, Tester, Players, Scenes, Commands, Entities include Articles, YouMount, Snapshot, Host, Callbacks @@ -34,10 +34,15 @@ @imported_scripts = [] @running = false post_initialize end + def player_class cls = nil + @player_class = cls unless cls.nil? + @player_class + end + # @return [Gamefic::Plot::Playbook] def playbook @playbook ||= Gamefic::Plot::Playbook.new end @@ -66,21 +71,26 @@ # Prepare the Plot for the next turn of gameplay. # This method is typically called by the Engine that manages game execution. def ready playbook.freeze @running = true + # Call the initial state to make sure it's set + initial_state call_ready call_player_ready p_subplots.each { |s| s.ready } end # Update the Plot's current turn of gameplay. # This method is typically called by the Engine that manages game execution. def update entities.each { |e| e.flush } call_before_player_update - p_players.each { |p| p.scene.update } + p_players.each { |p| + p.performed nil + p.scene.update + } p_entities.each { |e| e.update } call_player_update call_update p_subplots.each { |s| s.update unless s.concluded? } p_subplots.delete_if { |s| s.concluded? } @@ -115,9 +125,9 @@ imported_scripts.push imported_script true else false end - end + end end end