Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[bin/crypt] can examine things in inventory

  • Loading branch information...
commit b8f270b6bab68a8332568b9f90250ba3c09e7dfa 1 parent 8325b8e
@masak authored
Showing with 45 additions and 4 deletions.
  1. +45 −4 bin/crypt
View
49 bin/crypt
@@ -690,7 +690,7 @@ class Adventure::Engine {
if $pitch_black;
die X::Adventure::NoSuchThingHere.new(:$thing)
- unless self.thing_is_in($thing, $!player_location);
+ unless self.thing_in_room_or_inventory($thing, $!player_location);
die X::Adventure::NoSuchThingHere.new(:$thing)
if %!hidden_things{$thing};
@@ -717,7 +717,7 @@ class Adventure::Engine {
unless defined $!player_location;
die X::Adventure::NoSuchThingHere.new(:$thing)
- unless (%!thing_rooms{$thing} // '') eq $!player_location;
+ unless self.thing_in_room_or_inventory($thing, $!player_location);
die X::Adventure::NoSuchThingHere.new(:$thing)
if %!hidden_things{$thing};
@@ -759,9 +759,15 @@ class Adventure::Engine {
die X::Adventure::NoSuchThingHere.new(:$thing)
unless self.thing_in_room_or_inventory($thing, $!player_location);
+ die X::Adventure::NoSuchThingHere.new(:$thing)
+ if %!hidden_things{$thing};
+
die X::Adventure::NoSuchThingHere.new(:thing($in))
unless self.thing_in_room_or_inventory($in, $!player_location);
+ die X::Adventure::NoSuchThingHere.new(:$thing)
+ if %!hidden_things{$in};
+
die X::Adventure::ThingNotCarryable.new(:action<put>, :$thing)
unless %!carryable_things{$thing};
@@ -797,8 +803,17 @@ class Adventure::Engine {
die X::Adventure::PlayerNowhere.new()
unless defined $!player_location;
- # XXX: should check if the first thing is there
- # XXX: should check if the second thing is there
+ die X::Adventure::NoSuchThingHere.new(:$thing)
+ unless self.thing_in_room_or_inventory($thing, $!player_location);
+
+ die X::Adventure::NoSuchThingHere.new(:$thing)
+ if %!hidden_things{$thing};
+
+ die X::Adventure::NoSuchThingHere.new(:thing($on))
+ unless self.thing_in_room_or_inventory($on, $!player_location);
+
+ die X::Adventure::NoSuchThingHere.new(:$thing)
+ if %!hidden_things{$on};
die X::Adventure::ThingNotCarryable.new(:action<put>, :$thing)
unless %!carryable_things{$thing};
@@ -832,6 +847,9 @@ class Adventure::Engine {
die X::Adventure::NoSuchThingHere.new(:$thing)
unless self.thing_in_room_or_inventory($thing, $!player_location);
+ die X::Adventure::NoSuchThingHere.new(:$thing)
+ if %!hidden_things{$thing};
+
die X::Adventure::ThingNotReadable.new(:$thing)
unless %!readable_things{$thing};
@@ -872,6 +890,9 @@ class Adventure::Engine {
die X::Adventure::NoSuchThingHere.new(:$thing)
unless self.thing_is_in($thing, $!player_location);
+ die X::Adventure::NoSuchThingHere.new(:$thing)
+ if %!hidden_things{$thing};
+
die X::Adventure::ThingNotCarryable.new(:action<take>, :$thing)
unless %!carryable_things{$thing};
@@ -901,6 +922,9 @@ class Adventure::Engine {
die X::Adventure::PlayerDoesNotHave.new(:$thing)
unless self.thing_is_in($thing, 'player inventory');
+ die X::Adventure::PlayerDoesNotHave.new(:$thing)
+ if %!hidden_things{$thing};
+
my @events = Adventure::PlayerDropped.new(:$thing);
@events.push(self!tick);
self!apply_and_return: @events;
@@ -931,6 +955,9 @@ class Adventure::Engine {
die X::Adventure::NoSuchThingHere.new(:$thing)
unless self.thing_in_room_or_inventory($thing, $!player_location);
+ die X::Adventure::NoSuchThingHere.new(:$thing)
+ if %!hidden_things{$thing};
+
my @events = Adventure::PlayerUsed.new(:$thing);
if %!light_sources{$thing} {
@events.push(Adventure::LightSourceSwitchedOn.new(:$thing));
@@ -2905,6 +2932,20 @@ multi MAIN('test') {
'making it out alive with the treasure';
}
+ {
+ my $engine = Adventure::Engine.new();
+
+ $engine.place_thing('box', 'saloon');
+ $engine.make_thing_carryable('box');
+ $engine.place_player('saloon');
+ $engine.take('box');
+ is $engine.examine('box'),
+ Adventure::PlayerExamined.new(
+ :thing<box>,
+ ),
+ 'examining a thing (+) in inventory';
+ }
+
done;
}
Please sign in to comment.
Something went wrong with that request. Please try again.