Class: Gamefic::Tty::Engine
- Inherits:
-
Object
- Object
- Gamefic::Tty::Engine
- Defined in:
- lib/gamefic-tty/engine.rb
Instance Attribute Summary collapse
-
#character ⇒ Object
readonly
Returns the value of attribute character.
-
#plot ⇒ Object
readonly
Returns the value of attribute plot.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(plot: Gamefic::Plot.new, user: Gamefic::Tty::User.new) ⇒ Engine
constructor
A new instance of Engine.
- #run ⇒ Object
- #turn ⇒ Object
Constructor Details
#initialize(plot: Gamefic::Plot.new, user: Gamefic::Tty::User.new) ⇒ Engine
Returns a new instance of Engine.
8 9 10 11 12 13 14 |
# File 'lib/gamefic-tty/engine.rb', line 8 def initialize(plot: Gamefic::Plot.new, user: Gamefic::Tty::User.new) @plot = plot @user = user @character = @plot.get_player_character @plot.introduce @character @plot.ready end |
Instance Attribute Details
#character ⇒ Object (readonly)
Returns the value of attribute character.
6 7 8 |
# File 'lib/gamefic-tty/engine.rb', line 6 def character @character end |
#plot ⇒ Object (readonly)
Returns the value of attribute plot.
4 5 6 |
# File 'lib/gamefic-tty/engine.rb', line 4 def plot @plot end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
5 6 7 |
# File 'lib/gamefic-tty/engine.rb', line 5 def user @user end |
Class Method Details
.run(**args) ⇒ Object
21 22 23 24 25 |
# File 'lib/gamefic-tty/engine.rb', line 21 def self.run **args engine = new(**args) engine.run engine end |
Instance Method Details
#run ⇒ Object
16 17 18 19 |
# File 'lib/gamefic-tty/engine.rb', line 16 def run turn until @character.concluded? @user.update @character.output end |
#turn ⇒ Object
27 28 29 30 31 |
# File 'lib/gamefic-tty/engine.rb', line 27 def turn send_and_receive @plot.update @plot.ready end |