Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[crypt.pl] post-unlocking achievement logic

  • Loading branch information...
commit 6aa70d45d0ce1a8ecb6361894e72597db3539bca 1 parent b9caade
@masak authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 crypt.pl
View
10 crypt.pl
@@ -55,6 +55,8 @@
right => [],
;
+ has $!achievement = 'locked';
+
method move($source, $target) {
die X::Hanoi::NoSuchRod.new(:rod<source>, :name($source))
unless %!state.exists($source);
@@ -77,7 +79,8 @@
@target_rod.push( @source_rod.pop );
my $size = $moved_disk.words[0];
my @events = DiskMoved.new(:$size, :$source, :$target);
- if %!state<right> == @disks {
+ if %!state<right> == @disks && $!achievement eq 'locked' {
+ $!achievement = 'unlocked';
@events.push(AchievementUnlocked.new);
}
return @events;
@@ -197,6 +200,11 @@ (&code, $ex_type, &followup?)
DiskMoved.new(:size<tiny>, :$source, :$target),
AchievementUnlocked.new(),
), 'putting all disks on the right rod unlocks achievement';
+
+ $game.move($target, $source);
+ is $game.move($source, $target), (
+ DiskMoved.new(:size<tiny>, :$source, :$target),
+ ), 'moving things back and forth does not unlock achievement again';
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.