Class: Gamefic::Engine
- Inherits:
-
Object
- Object
- Gamefic::Engine
- Defined in:
- lib/gamefic/engine.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(plot) ⇒ Engine
constructor
A new instance of Engine.
- #post_initialize ⇒ Object
- #run ⇒ Object
- #turn ⇒ Object
Constructor Details
#initialize(plot) ⇒ Engine
Returns a new instance of Engine.
4 5 6 7 |
# File 'lib/gamefic/engine.rb', line 4 def initialize(plot) @plot = plot post_initialize end |
Instance Method Details
#post_initialize ⇒ Object
8 9 10 |
# File 'lib/gamefic/engine.rb', line 8 def post_initialize @user = User.new @plot end |
#run ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/gamefic/engine.rb', line 11 def run @plot.introduce @user.character print @user.state.output while !@plot.concluded?(@user.character) turn end print @user.state.output end |
#turn ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gamefic/engine.rb', line 19 def turn @plot.ready print @user.state.output if !@user.character[:test_queue].nil? and @user.character[:test_queue].length > 0 test_command = @user.character[:test_queue].shift @user.character.tell "[TESTING] #{@plot.scenes[@user.character.scene].prompt} #{test_command}" @user.character.queue.push test_command else @user.stream.select @plot.scenes[@user.character.scene].prompt @user.state.input end @plot.update print @user.state.output end |