Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[bin/crypt] hole opens and closes based on hanoi

Tradeoffs, they're everywhere. But it works.
  • Loading branch information...
commit 69d6d841ae49c81160b91e45d12da9075740cf36 1 parent 3d9700e
@masak authored
Showing with 40 additions and 1 deletion.
  1. +34 −1 bin/crypt
  2. +6 −0 game-data/descriptions
View
35 bin/crypt
@@ -251,6 +251,11 @@ class Adventure::TwoRoomsConnected does Event {
has $.direction;
}
+class Adventure::TwoRoomsDisconnected does Event {
+ has @.rooms;
+ has $.direction;
+}
+
class Adventure::DirectionAliased does Event {
has $.room;
has $.direction;
@@ -492,6 +497,14 @@ class Adventure::Engine {
self!apply_and_return: @events;
}
+ method disconnect(@rooms, $direction) {
+ die X::Adventure::NoSuchDirection.new(:action('disconnect rooms'), :$direction)
+ unless $direction eq any(@possible_directions);
+
+ my @events = Adventure::TwoRoomsDisconnected.new(:@rooms, :$direction);
+ self!apply_and_return: @events;
+ }
+
method !contents_of($thing) {
return %!thing_rooms.grep({.value eq "contents:$thing"})>>.key;
}
@@ -891,6 +904,12 @@ class Adventure::Engine {
%!exits{$room1}{$direction} = $room2;
%!exits{$room2}{opposite $direction} = $room1;
}
+ when Adventure::TwoRoomsDisconnected {
+ my ($room1, $room2) = .rooms.list;
+ my $direction = .direction;
+ %!exits{$room1}.delete($direction);
+ %!exits{$room2}.delete(opposite $direction);
+ }
when Adventure::PlayerWalked {
$!player_location = .to;
}
@@ -1078,7 +1097,20 @@ class Crypt::Game {
die X::Crypt::NoDisksHere.new
unless $!player_location eq 'hall';
- return $!hanoi.move($source, $target);
+ my @events = $!hanoi.move($source, $target);
+ for @events {
+ when Hanoi::AchievementUnlocked {
+ push @events,
+ $!engine.remark('floor-reveals-hole'),
+ $!engine.connect(<hall cave>, 'down');
+ }
+ when Hanoi::AchievementLocked {
+ push @events,
+ $!engine.remark('floor-hides-hole'),
+ $!engine.disconnect(<hall cave>, 'down');
+ }
+ }
+ return @events;
}
method save {
@@ -1287,6 +1319,7 @@ multi MAIN() {
}
CATCH {
when X::Adventure { say .message, '.' }
+ when X::Hanoi { say .message, '.' }
}
}
View
6 game-data/descriptions
@@ -71,3 +71,9 @@ You discover a door in the hill, under the thick grass!
== remark:passageway-opens-up
The ground rumbles and shakes a bit.
A passageway opens up to the south, into the caverns.
+
+== remark:floor-reveals-hole
+The whole floor tips, and reveals a hole beneath the wall.
+
+== remark:floor-hides-hole
+The whole floor tips back, hiding the hole again.
Please sign in to comment.
Something went wrong with that request. Please try again.