Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[bin/crypt] looking now tells about exits

  • Loading branch information...
commit c9841be088255a1177857b370645cf1e0562aded 1 parent 79f0763
Carl Mäsak authored July 08, 2012

Showing 1 changed file with 20 additions and 3 deletions. Show diff stats Hide diff stats

  1. 23  bin/crypt
23  bin/crypt
@@ -238,6 +238,7 @@ class Adventure::PlayerWasPlaced does Event {
238 238
 
239 239
 class Adventure::PlayerLooked does Event {
240 240
     has $.description_of;
  241
+    has @.exits;
241 242
 }
242 243
 
243 244
 class Adventure::TwoRoomsConnected does Event {
@@ -315,14 +316,20 @@ class Adventure::Engine {
315 316
 
316 317
         my @events = Adventure::PlayerWalked.new(:$to);
317 318
         unless %!seen_room{$to}++ {
318  
-            @events.push(Adventure::PlayerLooked.new(:description_of($to)));
  319
+            @events.push(Adventure::PlayerLooked.new(
  320
+                :description_of($to),
  321
+                :exits(%!exits{$to}.keys),
  322
+            ));
319 323
         }
320 324
         self!apply($_) for @events;
321 325
         @events;
322 326
     }
323 327
 
324 328
     method look() {
325  
-        my @events = Adventure::PlayerLooked.new(:description_of($!player_location));
  329
+        my @events = Adventure::PlayerLooked.new(
  330
+            :description_of($!player_location),
  331
+            :exits(%!exits($!player_location)),
  332
+        );
326 333
         self!apply($_) for @events;
327 334
         @events;
328 335
     }
@@ -330,7 +337,10 @@ class Adventure::Engine {
330 337
     method place_player($in) {
331 338
         my @events = Adventure::PlayerWasPlaced.new(:$in);
332 339
         unless %!seen_room{$in}++ {
333  
-            @events.push(Adventure::PlayerLooked.new(:description_of($in)));
  340
+            @events.push(Adventure::PlayerLooked.new(
  341
+                :description_of($in),
  342
+                :exits(%!exits{$in}.keys),
  343
+            ));
334 344
         }
335 345
         self!apply($_) for @events;
336 346
         @events;
@@ -461,6 +471,7 @@ multi MAIN() {
461 471
         say .ucfirst;
462 472
         say "";
463 473
         say %descriptions{$_};
  474
+        say "You can go east.";
464 475
         say "";
465 476
     }
466 477
 
@@ -499,6 +510,9 @@ multi MAIN() {
499 510
                         say ucfirst .description_of;
500 511
                         say "";
501 512
                         say %descriptions{.description_of};
  513
+                        if .exits {
  514
+                            say "You can go {join ' and ', .exits}.";
  515
+                        }
502 516
                     }
503 517
                 }
504 518
             }
@@ -521,6 +535,9 @@ multi MAIN() {
521 535
                     when Adventure::PlayerWalked { say ucfirst .to; say "" }
522 536
                     when Adventure::PlayerLooked {
523 537
                         say %descriptions{.description_of};
  538
+                        if .exits {
  539
+                            say "You can go {join ' and ', .exits}.";
  540
+                        }
524 541
                     }
525 542
                 }
526 543
                 CATCH {

0 notes on commit c9841be

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