lib/cyberarm_engine/common.rb in cyberarm_engine-0.21.0 vs lib/cyberarm_engine/common.rb in cyberarm_engine-0.22.0

- old
+ new

@@ -6,11 +6,14 @@ def current_state window.current_state end - def previous_state - window.previous_state + def previous_state(state = nil) + raise "Only available for CyberarmEngine::GameState and subclasses" unless is_a?(CyberarmEngine::GameState) || state.is_a?(CyberarmEngine::GameState) + + i = window.states.index(state || self) + window.states[i - 1] unless (i - 1).negative? end def pop_state window.pop_state end