Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[crypt.pl] achievements can be locked, too

  • Loading branch information...
commit 96d9cf3bbc2e1b9bc7d56f82fa3fa017471531ce 1 parent 6aa70d4
Carl Mäsak authored July 01, 2012

Showing 1 changed file with 15 additions and 0 deletions. Show diff stats Hide diff stats

  1. 15  crypt.pl
15  crypt.pl
@@ -19,6 +19,9 @@
19 19
 class AchievementUnlocked does Event {
20 20
 }
21 21
 
  22
+class AchievementLocked does Event {
  23
+}
  24
+
22 25
 class X::Hanoi::LargerOnSmaller is Exception {
23 26
     has $.larger;
24 27
     has $.smaller;
@@ -83,6 +86,10 @@
83 86
             $!achievement = 'unlocked';
84 87
             @events.push(AchievementUnlocked.new);
85 88
         }
  89
+        if $size eq 'small' && $!achievement eq 'unlocked' {
  90
+            $!achievement = 'locked';
  91
+            @events.push(AchievementLocked.new);
  92
+        }
86 93
         return @events;
87 94
     }
88 95
 }
@@ -206,6 +213,14 @@ (&code, $ex_type, &followup?)
206 213
                 DiskMoved.new(:size<tiny>, :$source, :$target),
207 214
             ), 'moving things back and forth does not unlock achievement again';
208 215
         }
  216
+
  217
+        {
  218
+            $game.move('right', 'middle');
  219
+            is $game.move(my $source = 'right', my $target = 'left'), (
  220
+                DiskMoved.new(:size<small>, :$source, :$target),
  221
+                AchievementLocked.new(),
  222
+            ), 'removing two disks from the right rod locks achievement';
  223
+        }
209 224
     }
210 225
 
211 226
     done;

0 notes on commit 96d9cf3

Please sign in to comment.
Something went wrong with that request. Please try again.