lib/gamefic/user/tty.rb in gamefic-1.5.1 vs lib/gamefic/user/tty.rb in gamefic-1.6.0

- old
+ new

@@ -4,14 +4,21 @@ module Gamefic # Extend User::Base to convert HTML into ANSI text. # + # @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. + # class User::Tty < User::Base + def update state + print Gamefic::Text::Html::Conversions.html_to_ansi(state[:output]) + end + def save filename, snapshot - data = snapshot.merge(:metadata => @character.plot.metadata) - json = JSON.generate data + json = JSON.generate snapshot if json.nil? @character.tell "Nothing to save." end if filename.nil? stream.select "Enter the filename to save:" @@ -19,11 +26,10 @@ end if filename != '' File.open(filename, 'w') do |f| f.write json end - @character.tell "Game saved." end end def restore filename if filename.nil? @@ -31,23 +37,18 @@ filename = stream.queue.pop end if filename != '' if File.exists?(filename) data = JSON.parse File.read(filename), symbolize_names: true - if (data[:metadata] != @character.plot.metadata) - @character.tell "The save file is not compatible with this version of the game." - else + #if (data[:metadata] != @character.plot.metadata) + # @character.tell "The save file is not compatible with this version of the game." + #else return data - end + #end else @character.tell "File \"#{filename}\" not found." end end nil end - - def flush - Gamefic::Text::Html::Conversions.html_to_ansi(super) - end end - end