Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[bin/crypt] implement opening things

  • Loading branch information...
commit 97260bd778c12718e4be5cf6a5a1f045d553b6f5 1 parent fcd3e8d
@masak authored
Showing with 24 additions and 0 deletions.
  1. +24 −0 bin/crypt
View
24 bin/crypt
@@ -261,6 +261,10 @@ class Adventure::ThingPlaced does Event {
has $.room;
}
+class Adventure::PlayerOpened does Event {
+ has $.thing;
+}
+
class X::Adventure is Exception {
}
@@ -396,6 +400,13 @@ class Adventure::Engine {
@events;
}
+ method make_thing_openable($thing) {
+ }
+
+ method open($thing) {
+ Adventure::PlayerOpened.new(:$thing);
+ }
+
method on_try_exit($room, $direction, &hook) {
%!try_exit_hooks{$room}{$direction} = &hook;
}
@@ -907,6 +918,19 @@ multi MAIN('test') {
};
}
+ {
+ my $engine = Adventure::Engine.new();
+
+ $engine.place_thing('car', 'street');
+ $engine.make_thing_openable('car');
+ $engine.place_player('street');
+ is $engine.open('car'),
+ Adventure::PlayerOpened.new(
+ :thing<car>,
+ ),
+ 'opening an object (+)';
+ }
+
done;
}
Please sign in to comment.
Something went wrong with that request. Please try again.