Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[bin/crypt] player can take things

  • Loading branch information...
commit 819d4aaadccced9f75dad59f9edbcd952eeabf02 1 parent 4217c15
Carl Mäsak authored July 15, 2012

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

  1. 25  bin/crypt
25  bin/crypt
@@ -301,6 +301,10 @@ class Adventure::ThingUnhidden does Event {
301 301
     has $.thing;
302 302
 }
303 303
 
  304
+class Adventure::PlayerTook does Event {
  305
+    has $.thing;
  306
+}
  307
+
304 308
 class X::Adventure is Exception {
305 309
 }
306 310
 
@@ -603,6 +607,15 @@ class Adventure::Engine {
603 607
         @events;
604 608
     }
605 609
 
  610
+    method make_thing_carryable($thing) {
  611
+    }
  612
+
  613
+    method take($thing) {
  614
+        my @events = Adventure::PlayerTook.new(:$thing);
  615
+        self!apply($_) for @events;
  616
+        @events;
  617
+    }
  618
+
606 619
     method on_try_exit($room, $direction, &hook) {
607 620
         %!try_exit_hooks{$room}{$direction} = &hook;
608 621
     }
@@ -1390,6 +1403,18 @@ multi MAIN('test') {
1390 1403
             'opening a thing (+) unhidden by a callback';
1391 1404
     }
1392 1405
 
  1406
+    {
  1407
+        my $engine = Adventure::Engine.new();
  1408
+
  1409
+        $engine.place_thing('box', 'saloon');
  1410
+        $engine.make_thing_carryable('box');
  1411
+        is $engine.take('box'),
  1412
+            Adventure::PlayerTook.new(
  1413
+                :thing<box>,
  1414
+            ),
  1415
+            'taking a thing (+)';
  1416
+    }
  1417
+
1393 1418
     done;
1394 1419
 }
1395 1420
 

0 notes on commit 819d4aa

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