diff options
Diffstat (limited to 'curling.rb')
-rw-r--r-- | curling.rb | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -61,7 +61,16 @@ To restart the game, run `rm k` to remove the cookie that stores your game state end get '/:command' do |command| - engine = Hex.new cookies.to_h + begin + engine = Hex.new cookies.to_h + rescue InvalidChecksumError + halt 422, <<~MSG + Invalid state, checksum does not match! + If you lost your last valid game state, you'll have to remove your current + cookie and start over. + MSG + end + engine.step command engine.state_h.each_pair do |key, value| cookies[key] = value |