Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[bin/crypt] implement opening things

  • Loading branch information...
commit 97260bd778c12718e4be5cf6a5a1f045d553b6f5 1 parent fcd3e8d
Carl Mäsak authored July 10, 2012

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

  1. 24  bin/crypt
24  bin/crypt
@@ -261,6 +261,10 @@ class Adventure::ThingPlaced does Event {
261 261
     has $.room;
262 262
 }
263 263
 
  264
+class Adventure::PlayerOpened does Event {
  265
+    has $.thing;
  266
+}
  267
+
264 268
 class X::Adventure is Exception {
265 269
 }
266 270
 
@@ -396,6 +400,13 @@ class Adventure::Engine {
396 400
         @events;
397 401
     }
398 402
 
  403
+    method make_thing_openable($thing) {
  404
+    }
  405
+
  406
+    method open($thing) {
  407
+        Adventure::PlayerOpened.new(:$thing);
  408
+    }
  409
+
399 410
     method on_try_exit($room, $direction, &hook) {
400 411
         %!try_exit_hooks{$room}{$direction} = &hook;
401 412
     }
@@ -907,6 +918,19 @@ multi MAIN('test') {
907 918
             };
908 919
     }
909 920
 
  921
+    {
  922
+        my $engine = Adventure::Engine.new();
  923
+
  924
+        $engine.place_thing('car', 'street');
  925
+        $engine.make_thing_openable('car');
  926
+        $engine.place_player('street');
  927
+        is $engine.open('car'),
  928
+            Adventure::PlayerOpened.new(
  929
+                :thing<car>,
  930
+            ),
  931
+            'opening an object (+)';
  932
+    }
  933
+
910 934
     done;
911 935
 }
912 936
 

0 notes on commit 97260bd

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