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 put things into containers

  • Loading branch information...
commit a9fe2f791bd27ee81d84eb9b66d6ed6849bb8299 1 parent 7132e85
Carl Mäsak authored July 11, 2012

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

  1. 27  bin/crypt
27  bin/crypt
@@ -265,6 +265,11 @@ class Adventure::PlayerOpened does Event {
265 265
     has $.thing;
266 266
 }
267 267
 
  268
+class Adventure::PlayerPut does Event {
  269
+    has $.thing;
  270
+    has $.in;
  271
+}
  272
+
268 273
 class X::Adventure is Exception {
269 274
 }
270 275
 
@@ -434,6 +439,13 @@ class Adventure::Engine {
434 439
         @events;
435 440
     }
436 441
 
  442
+    method make_thing_a_container($thing) {
  443
+    }
  444
+
  445
+    method put_thing_in($thing, $in) {
  446
+        Adventure::PlayerPut.new(:$thing, :$in);
  447
+    }
  448
+
437 449
     method on_try_exit($room, $direction, &hook) {
438 450
         %!try_exit_hooks{$room}{$direction} = &hook;
439 451
     }
@@ -993,6 +1005,21 @@ multi MAIN('test') {
993 1005
             };
994 1006
     }
995 1007
 
  1008
+    {
  1009
+        my $engine = Adventure::Engine.new();
  1010
+
  1011
+        $engine.place_thing('box', 'street');
  1012
+        $engine.place_thing('doll', 'street');
  1013
+        $engine.make_thing_a_container('box');
  1014
+        $engine.place_player('street');
  1015
+        is $engine.put_thing_in('doll', 'box'),
  1016
+            Adventure::PlayerPut.new(
  1017
+                :thing<doll>,
  1018
+                :in<box>,
  1019
+            ),
  1020
+            'putting a thing inside another (+)';
  1021
+    }
  1022
+
996 1023
     done;
997 1024
 }
998 1025
 

0 notes on commit a9fe2f7

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