diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/wittle/puzzles_controller.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/controllers/wittle/puzzles_controller.rb b/app/controllers/wittle/puzzles_controller.rb index b481460..8dc2ac8 100644 --- a/app/controllers/wittle/puzzles_controller.rb +++ b/app/controllers/wittle/puzzles_controller.rb | |||
@@ -22,6 +22,14 @@ module Wittle | |||
22 | @puzzle = Puzzle.find(params[:id]) | 22 | @puzzle = Puzzle.find(params[:id]) |
23 | @playable = @puzzle.latest? && !((session[:played_puzzles] || []).include? @puzzle.id) | 23 | @playable = @puzzle.latest? && !((session[:played_puzzles] || []).include? @puzzle.id) |
24 | @already_started = ((session[:started_puzzles] || []).include? @puzzle.id) | 24 | @already_started = ((session[:started_puzzles] || []).include? @puzzle.id) |
25 | |||
26 | unless @playable | ||
27 | if (session[:puzzle_solutions] || {}).has_key? @puzzle.id.to_s | ||
28 | @solution = session[:puzzle_solutions][@puzzle.id.to_s] | ||
29 | else | ||
30 | @solution = @puzzle.solved_data | ||
31 | end | ||
32 | end | ||
25 | end | 33 | end |
26 | 34 | ||
27 | def start | 35 | def start |
@@ -45,6 +53,9 @@ module Wittle | |||
45 | 53 | ||
46 | session[:played_puzzles] ||= [] | 54 | session[:played_puzzles] ||= [] |
47 | session[:played_puzzles] << @puzzle.id | 55 | session[:played_puzzles] << @puzzle.id |
56 | |||
57 | session[:puzzle_solutions] ||= {} | ||
58 | session[:puzzle_solutions][@puzzle.id] = params[:solved] | ||
48 | end | 59 | end |
49 | 60 | ||
50 | def submit | 61 | def submit |