Module: Gamefic::Plot::Snapshot
- Included in:
- Gamefic::Plot
- Defined in:
- lib/gamefic/plot/snapshot.rb
Instance Method Summary collapse
-
#restore(snapshot) ⇒ void
Restore the game state from a snapshot.
-
#save ⇒ Hash
Save the current game state as a data hash.
Instance Method Details
#restore(snapshot) ⇒ void
Note:
The string conversion is performed as a convenience for web apps.
This method returns an undefined value.
Restore the game state from a snapshot.
If ‘snapshot` is a string, parse it as a JSON object.
22 23 24 25 |
# File 'lib/gamefic/plot/snapshot.rb', line 22 def restore snapshot snapshot = JSON.parse(snapshot) if snapshot.is_a?(String) Gamefic::Plot::Darkroom.new(self).restore(snapshot) end |
#save ⇒ Hash
Save the current game state as a data hash. See Gamefic::Plot::Darkroom for more information about the data format.
10 11 12 |
# File 'lib/gamefic/plot/snapshot.rb', line 10 def save Gamefic::Plot::Darkroom.new(self).save end |