Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[bin/crypt] can walk into crypt after putting out fire

  • Loading branch information...
commit 772c8d83b737623b92b3b2ef4098b691aef37f55 1 parent 00f8e1f
Carl Mäsak authored July 25, 2012
59  bin/crypt
@@ -537,7 +537,7 @@ class Adventure::Engine {
537 537
         }
538 538
     }
539 539
 
540  
-    method !is_thing_in($sought, $location) {
  540
+    method thing_is_in($sought, $location) {
541 541
         return unless $location;
542 542
         for %!thing_rooms.keys -> $thing {
543 543
             next unless %!thing_rooms{$thing} eq $location;
@@ -546,20 +546,20 @@ class Adventure::Engine {
546 546
             return True
547 547
                 if %!containers{$thing}
548 548
                 && (!%!openable_things{$thing} || %!open_things{$thing})
549  
-                && self!is_thing_in($sought, "contents:$thing");
  549
+                && self.thing_is_in($sought, "contents:$thing");
550 550
         }
551 551
         return False;
552 552
     }
553 553
 
554  
-    method !thing_in_room_or_inventory($thing, $room) {
555  
-        self!is_thing_in($thing, $room)
556  
-        || self!is_thing_in($thing, 'player inventory');
  554
+    method thing_in_room_or_inventory($thing, $room) {
  555
+        self.thing_is_in($thing, $room)
  556
+        || self.thing_is_in($thing, 'player inventory');
557 557
     }
558 558
 
559 559
     method !shining_thing_here($room) {
560 560
         for %!things_shining.kv -> $thing, $shining {
561 561
             next unless $shining;
562  
-            return True if self!thing_in_room_or_inventory($thing, $room);
  562
+            return True if self.thing_in_room_or_inventory($thing, $room);
563 563
         }
564 564
         return False;
565 565
     }
@@ -653,7 +653,7 @@ class Adventure::Engine {
653 653
             if $pitch_black;
654 654
 
655 655
         die X::Adventure::NoSuchThingHere.new(:$thing)
656  
-            unless self!is_thing_in($thing, $!player_location);
  656
+            unless self.thing_is_in($thing, $!player_location);
657 657
 
658 658
         die X::Adventure::NoSuchThingHere.new(:$thing)
659 659
             if %!hidden_things{$thing};
@@ -713,10 +713,10 @@ class Adventure::Engine {
713 713
             unless defined $!player_location;
714 714
 
715 715
         die X::Adventure::NoSuchThingHere.new(:$thing)
716  
-            unless self!thing_in_room_or_inventory($thing, $!player_location);
  716
+            unless self.thing_in_room_or_inventory($thing, $!player_location);
717 717
 
718 718
         die X::Adventure::NoSuchThingHere.new(:thing($in))
719  
-            unless self!thing_in_room_or_inventory($in, $!player_location);
  719
+            unless self.thing_in_room_or_inventory($in, $!player_location);
720 720
 
721 721
         die X::Adventure::ThingNotCarryable.new(:action<put>, :$thing)
722 722
             unless %!carryable_things{$thing};
@@ -778,7 +778,7 @@ class Adventure::Engine {
778 778
             unless defined $!player_location;
779 779
 
780 780
         die X::Adventure::NoSuchThingHere.new(:$thing)
781  
-            unless self!thing_in_room_or_inventory($thing, $!player_location);
  781
+            unless self.thing_in_room_or_inventory($thing, $!player_location);
782 782
 
783 783
         die X::Adventure::ThingNotReadable.new(:$thing)
784 784
             unless %!readable_things{$thing};
@@ -815,14 +815,14 @@ class Adventure::Engine {
815 815
             if $pitch_black;
816 816
 
817 817
         die X::Adventure::NoSuchThingHere.new(:$thing)
818  
-            unless self!is_thing_in($thing, $!player_location);
  818
+            unless self.thing_is_in($thing, $!player_location);
819 819
 
820 820
         die X::Adventure::ThingNotCarryable.new(:action<take>, :$thing)
821 821
             unless %!carryable_things{$thing};
822 822
 
823 823
         my @events;
824 824
         for %!remove_from_hooks.kv -> $container, &hook {
825  
-            if self!is_thing_in($thing, "contents:$container") {
  825
+            if self.thing_is_in($thing, "contents:$container") {
826 826
                 @events.push($_) when Event for &hook($thing);
827 827
             }
828 828
         }
@@ -866,7 +866,7 @@ class Adventure::Engine {
866 866
             unless defined $!player_location;
867 867
 
868 868
         die X::Adventure::NoSuchThingHere.new(:$thing)
869  
-            unless self!thing_in_room_or_inventory($thing, $!player_location);
  869
+            unless self.thing_in_room_or_inventory($thing, $!player_location);
870 870
 
871 871
         my @events = Adventure::PlayerUsed.new(:$thing);
872 872
         if %!light_sources{$thing} {
@@ -1032,8 +1032,13 @@ class Crypt::Game {
1032 1032
             .alias_direction: 'hall', 'out', 'north';
1033 1033
             .connect: <cave crypt>, 'northwest';
1034 1034
             .on_try_exit: 'cave', 'northwest', {
1035  
-                say "You try to walk past the fire, but it's too hot!";
1036  
-                False;
  1035
+                if .thing_is_in('fire', 'cave') {
  1036
+                    .remark('walk-past-fire-too-hot'),
  1037
+                    False;
  1038
+                }
  1039
+                else {
  1040
+                    True;
  1041
+                }
1037 1042
             };
1038 1043
             .make_room_dark: 'hall';
1039 1044
             .make_room_dark: 'cave';
@@ -2578,6 +2583,30 @@ multi MAIN('test') {
2578 2583
             'putting out the fire with water';
2579 2584
     }
2580 2585
 
  2586
+    sub game_after_putting_out_the_water {
  2587
+        my $game = game_after_hanoi_is_solved();
  2588
+
  2589
+        $game.take('helmet');
  2590
+        $game.walk('north');
  2591
+        $game.walk('north');
  2592
+        $game.put_thing_in('water', 'helmet');
  2593
+        $game.walk('south');
  2594
+        $game.walk('south');
  2595
+        $game.walk('down');
  2596
+        $game.put_thing_in('water', 'fire');
  2597
+        return $game;
  2598
+    }
  2599
+
  2600
+    {
  2601
+        my $game = game_after_putting_out_the_water();
  2602
+
  2603
+        is $game.walk('northwest')[0],
  2604
+            Adventure::PlayerWalked.new(
  2605
+                :to<crypt>,
  2606
+            ),
  2607
+            'after water is gone, can walk into crypt';
  2608
+    }
  2609
+
2581 2610
     done;
2582 2611
 }
2583 2612
 
3  game-data/descriptions
@@ -87,3 +87,6 @@ floor mats.
87 87
 
88 88
 == remark:fire-dies
89 89
 The fire wanes and dies out.
  90
+
  91
+== remark:walk-past-fire-too-hot
  92
+You try to walk past the fire, but it's too hot!

0 notes on commit 772c8d8

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