Module: Gamefic::Plot::Snapshot

Included in:
Gamefic::Plot
Defined in:
lib/gamefic/plot/snapshot.rb

Instance Method Summary collapse

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.

Parameters:



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

#saveHash

Save the current game state as a data hash. See Gamefic::Plot::Darkroom for more information about the data format.

Returns:



10
11
12
# File 'lib/gamefic/plot/snapshot.rb', line 10

def save
  Gamefic::Plot::Darkroom.new(self).save
end