Class: Gamefic::User::Tty
Overview
Note:
Due to their dependency on io/console, User::Tty and Engine::Tty are not included in the core Gamefic library. ‘require gamefic/tty` if you need them.
Extend User::Base to convert HTML into ANSI text.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Gamefic::User::Base
Instance Method Details
#restore(filename) ⇒ Object
32 33 34 35 36 |
# File 'lib/gamefic/user/tty.rb', line 32 def restore filename json = File.read(filename) snapshot = JSON.parse(json, symbolize_names: true) engine.plot.restore snapshot end |
#save(filename, snapshot) ⇒ Object
26 27 28 29 30 |
# File 'lib/gamefic/user/tty.rb', line 26 def save filename, snapshot File.open(filename, 'w') do |file| file << snapshot.to_json end end |
#update ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gamefic/user/tty.rb', line 14 def update unless character.state[:options].nil? list = '<ol class="multiple_choice">' character.state[:options].each { |o| list += "<li><a href=\"#\" rel=\"gamefic\" data-command=\"#{o}\">#{o}</a></li>" } list += "</ol>" character.tell list end print Gamefic::Text::Html::Conversions.html_to_ansi(character.state[:output]) end |