Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[crypt.pl] achievements can be locked, too

  • Loading branch information...
commit 96d9cf3bbc2e1b9bc7d56f82fa3fa017471531ce 1 parent 6aa70d4
@masak authored
Showing with 15 additions and 0 deletions.
  1. +15 −0 crypt.pl
View
15 crypt.pl
@@ -19,6 +19,9 @@
class AchievementUnlocked does Event {
}
+class AchievementLocked does Event {
+}
+
class X::Hanoi::LargerOnSmaller is Exception {
has $.larger;
has $.smaller;
@@ -83,6 +86,10 @@
$!achievement = 'unlocked';
@events.push(AchievementUnlocked.new);
}
+ if $size eq 'small' && $!achievement eq 'unlocked' {
+ $!achievement = 'locked';
+ @events.push(AchievementLocked.new);
+ }
return @events;
}
}
@@ -206,6 +213,14 @@ (&code, $ex_type, &followup?)
DiskMoved.new(:size<tiny>, :$source, :$target),
), 'moving things back and forth does not unlock achievement again';
}
+
+ {
+ $game.move('right', 'middle');
+ is $game.move(my $source = 'right', my $target = 'left'), (
+ DiskMoved.new(:size<small>, :$source, :$target),
+ AchievementLocked.new(),
+ ), 'removing two disks from the right rod locks achievement';
+ }
}
done;
Please sign in to comment.
Something went wrong with that request. Please try again.