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 drop things

  • Loading branch information...
commit a0b45bb49c6dab13cbe1302c021950ba92f88277 1 parent f03f3ca
Carl Mäsak authored July 15, 2012

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

  1. 23  bin/crypt
23  bin/crypt
@@ -311,6 +311,10 @@ class Adventure::ThingMadeCarryable does Event {
311 311
     has $.thing;
312 312
 }
313 313
 
  314
+class Adventure::PlayerDropped does Event {
  315
+    has $.thing;
  316
+}
  317
+
314 318
 class X::Adventure is Exception {
315 319
 }
316 320
 
@@ -652,6 +656,11 @@ class Adventure::Engine {
652 656
         self!apply_and_return: @events;
653 657
     }
654 658
 
  659
+    method drop($thing) {
  660
+        my @events = Adventure::PlayerDropped.new(:$thing);
  661
+        self!apply_and_return: @events;
  662
+    }
  663
+
655 664
     method on_try_exit($room, $direction, &hook) {
656 665
         %!try_exit_hooks{$room}{$direction} = &hook;
657 666
     }
@@ -1543,6 +1552,20 @@ multi MAIN('test') {
1543 1552
             };
1544 1553
     }
1545 1554
 
  1555
+    {
  1556
+        my $engine = Adventure::Engine.new();
  1557
+
  1558
+        $engine.place_thing('cup', 'porch');
  1559
+        $engine.make_thing_carryable('cup');
  1560
+        $engine.place_player('porch');
  1561
+        $engine.take('cup');
  1562
+        is $engine.drop('cup'),
  1563
+            Adventure::PlayerDropped.new(
  1564
+                :thing<cup>,
  1565
+            ),
  1566
+            'dropping a thing (+)';
  1567
+    }
  1568
+
1546 1569
     done;
1547 1570
 }
1548 1571
 

0 notes on commit a0b45bb

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