Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[bin/crypt] you can read the sign

  • Loading branch information...
commit 116c42168608affbafbad7eb327ac5f4ced8e635 1 parent 5d29eb5
@masak authored
Showing with 21 additions and 2 deletions.
  1. +21 −2 bin/crypt
View
23 bin/crypt
@@ -706,7 +706,8 @@ class Adventure::Engine {
die X::Adventure::PlayerNowhere.new()
unless defined $!player_location;
- # XXX: should check if the thing is there
+ die X::Adventure::NoSuchThingHere.new(:$thing)
+ unless self!thing_in_room_or_inventory($thing);
die X::Adventure::ThingNotReadable.new(:$thing)
unless %!readable_things{$thing};
@@ -929,6 +930,7 @@ class Crypt::Game {
.place_thing('basket', 'chamber');
.make_thing_a_container('basket');
.place_thing('sign', 'chamber');
+ .make_thing_readable('sign');
.on_put(
'basket',
-> $_ {
@@ -970,6 +972,10 @@ class Crypt::Game {
return $!engine.put_thing_on($thing, $on);
}
+ method read($thing) {
+ return $!engine.read($thing);
+ }
+
method save {
$!engine.save;
}
@@ -1136,6 +1142,9 @@ multi MAIN() {
when Adventure::GameRemarked {
say %descriptions{"remark:{.remark}"};
}
+ when Adventure::PlayerRead {
+ say %descriptions{"{.thing}"};
+ }
}
CATCH {
when X::Adventure { say .message, '.' }
@@ -1995,7 +2004,7 @@ multi MAIN('test') {
Adventure::PlayerLooked.new(
:room<chamber>,
:exits<south north>,
- :things<basket>,
+ :things<basket sign>,
),
],
'walking into the hill (+) after opening the door';
@@ -2065,6 +2074,16 @@ multi MAIN('test') {
'putting the leaves in the basket';
}
+ {
+ my $game = game_from_chamber();
+
+ is $game.read('sign'),
+ Adventure::PlayerRead.new(
+ :thing<sign>,
+ ),
+ 'reading the sign';
+ }
+
done;
}

0 comments on commit 116c421

Please sign in to comment.
Something went wrong with that request. Please try again.