Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[bin/crypt] message at darkness

  • Loading branch information...
commit 647e1b7f056acf06f01aa782c3705f3e1ffbc9ce 1 parent bc2bb14
Carl Mäsak authored July 22, 2012

Showing 1 changed file with 12 additions and 11 deletions. Show diff stats Hide diff stats

  1. 23  bin/crypt
23  bin/crypt
@@ -527,15 +527,15 @@ class Adventure::Engine {
527 527
         return False;
528 528
     }
529 529
 
530  
-    method !thing_in_room_or_inventory($thing) {
531  
-        self!is_thing_in($thing, $!player_location)
  530
+    method !thing_in_room_or_inventory($thing, $room) {
  531
+        self!is_thing_in($thing, $room)
532 532
         || self!is_thing_in($thing, 'player inventory');
533 533
     }
534 534
 
535  
-    method !shining_thing_here() {
  535
+    method !shining_thing_here($room) {
536 536
         for %!things_shining.kv -> $thing, $shining {
537 537
             next unless $shining;
538  
-            return True if self!thing_in_room_or_inventory($thing);
  538
+            return True if self!thing_in_room_or_inventory($thing, $room);
539 539
         }
540 540
         return False;
541 541
     }
@@ -558,8 +558,8 @@ class Adventure::Engine {
558 558
 
559 559
         my @events = Adventure::PlayerWalked.new(:$to);
560 560
         unless %!seen_room{$to}++ {
561  
-            my $pitch_black = %!dark_rooms{$!player_location}
562  
-                && !self!shining_thing_here();
  561
+            my $pitch_black = %!dark_rooms{$to}
  562
+                && !self!shining_thing_here($to);
563 563
 
564 564
             if $pitch_black {
565 565
                 @events.push(Adventure::PlayerLookedAtDarkness.new());
@@ -580,7 +580,7 @@ class Adventure::Engine {
580 580
             unless defined $!player_location;
581 581
 
582 582
         my $pitch_black = %!dark_rooms{$!player_location}
583  
-            && !self!shining_thing_here();
  583
+            && !self!shining_thing_here($!player_location);
584 584
 
585 585
         my @events = $pitch_black
586 586
             ?? Adventure::PlayerLookedAtDarkness.new()
@@ -683,10 +683,10 @@ class Adventure::Engine {
683 683
             unless defined $!player_location;
684 684
 
685 685
         die X::Adventure::NoSuchThingHere.new(:$thing)
686  
-            unless self!thing_in_room_or_inventory($thing);
  686
+            unless self!thing_in_room_or_inventory($thing, $!player_location);
687 687
 
688 688
         die X::Adventure::NoSuchThingHere.new(:thing($in))
689  
-            unless self!thing_in_room_or_inventory($in);
  689
+            unless self!thing_in_room_or_inventory($in, $!player_location);
690 690
 
691 691
         die X::Adventure::ThingNotCarryable.new(:action<put>, :$thing)
692 692
             unless %!carryable_things{$thing};
@@ -748,7 +748,7 @@ class Adventure::Engine {
748 748
             unless defined $!player_location;
749 749
 
750 750
         die X::Adventure::NoSuchThingHere.new(:$thing)
751  
-            unless self!thing_in_room_or_inventory($thing);
  751
+            unless self!thing_in_room_or_inventory($thing, $!player_location);
752 752
 
753 753
         die X::Adventure::ThingNotReadable.new(:$thing)
754 754
             unless %!readable_things{$thing};
@@ -819,7 +819,7 @@ class Adventure::Engine {
819 819
             unless defined $!player_location;
820 820
 
821 821
         die X::Adventure::NoSuchThingHere.new(:$thing)
822  
-            unless self!thing_in_room_or_inventory($thing);
  822
+            unless self!thing_in_room_or_inventory($thing, $!player_location);
823 823
 
824 824
         my @events = Adventure::PlayerUsed.new(:$thing);
825 825
         if %!light_sources{$thing} {
@@ -1205,6 +1205,7 @@ multi MAIN() {
1205 1205
                             say "You can go {join ' and ', .exits}.";
1206 1206
                         }
1207 1207
                     }
  1208
+                    when Adventure::PlayerLookedAtDarkness { say "It is pitch black." }
1208 1209
                     when Adventure::PlayerExamined { say %descriptions{.thing} }
1209 1210
                     when Adventure::ContentsRevealed {
1210 1211
                         my $contents = join " and ", map { "a $_" }, .contents;

0 notes on commit 647e1b7

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