Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[bin/crypt] placing/examining an object

  • Loading branch information...
commit 02858d2a97204ed09586f296eb42625766ed0f0c 1 parent f8d2a55
Carl Mäsak authored

Showing 1 changed file with 27 additions and 0 deletions. Show diff stats Hide diff stats

  1. 27  bin/crypt
27  bin/crypt
@@ -252,6 +252,10 @@ class Adventure::DirectionAliased does Event {
252 252
     has $.alias;
253 253
 }
254 254
 
  255
+class Adventure::PlayerExamined does Event {
  256
+    has $.thing;
  257
+}
  258
+
255 259
 class X::Adventure is Exception {
256 260
 }
257 261
 
@@ -359,6 +363,17 @@ class Adventure::Engine {
359 363
         @events;
360 364
     }
361 365
 
  366
+    method place_thing($thing, $room) {
  367
+    }
  368
+
  369
+    method examine($thing) {
  370
+        my @events = Adventure::PlayerExamined.new(
  371
+            :$thing
  372
+        );
  373
+        self!apply($_) for @events;
  374
+        @events;
  375
+    }
  376
+
362 377
     method on_try_exit($room, $direction, &hook) {
363 378
         %!try_exit_hooks{$room}{$direction} = &hook;
364 379
     }
@@ -841,6 +856,18 @@ multi MAIN('test') {
841 856
             'connecting two rooms creates a mutual connection';
842 857
     }
843 858
 
  859
+    {
  860
+        my $engine = Adventure::Engine.new();
  861
+
  862
+        $engine.place_thing('ball', 'street');
  863
+        $engine.place_player('street');
  864
+        is $engine.examine('ball'),
  865
+            Adventure::PlayerExamined.new(
  866
+                :thing<ball>,
  867
+            ),
  868
+            'examining an object (+)';
  869
+    }
  870
+
844 871
     done;
845 872
 }
846 873
 

0 notes on commit 02858d2

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