Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[bin/crypt] player can take things

  • Loading branch information...
commit 819d4aaadccced9f75dad59f9edbcd952eeabf02 1 parent 4217c15
@masak authored
Showing with 25 additions and 0 deletions.
  1. +25 −0 bin/crypt
View
25 bin/crypt
@@ -301,6 +301,10 @@ class Adventure::ThingUnhidden does Event {
has $.thing;
}
+class Adventure::PlayerTook does Event {
+ has $.thing;
+}
+
class X::Adventure is Exception {
}
@@ -603,6 +607,15 @@ class Adventure::Engine {
@events;
}
+ method make_thing_carryable($thing) {
+ }
+
+ method take($thing) {
+ my @events = Adventure::PlayerTook.new(:$thing);
+ self!apply($_) for @events;
+ @events;
+ }
+
method on_try_exit($room, $direction, &hook) {
%!try_exit_hooks{$room}{$direction} = &hook;
}
@@ -1390,6 +1403,18 @@ multi MAIN('test') {
'opening a thing (+) unhidden by a callback';
}
+ {
+ my $engine = Adventure::Engine.new();
+
+ $engine.place_thing('box', 'saloon');
+ $engine.make_thing_carryable('box');
+ is $engine.take('box'),
+ Adventure::PlayerTook.new(
+ :thing<box>,
+ ),
+ 'taking a thing (+)';
+ }
+
done;
}
Please sign in to comment.
Something went wrong with that request. Please try again.