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't put platforms on themselves

  • Loading branch information...
commit 576954e2faa792bb82329f313f1f503561ed8c52 1 parent 6d2119f
Carl Mäsak authored July 13, 2012

Showing 1 changed file with 28 additions and 4 deletions. Show diff stats Hide diff stats

  1. 32  bin/crypt
32  bin/crypt
@@ -341,10 +341,11 @@ class X::Adventure::CannotPutInNonContainer is X::Adventure {
341 341
 }
342 342
 
343 343
 class X::Adventure::YoDawg is X::Adventure {
344  
-    has $.in;
  344
+    has $.relation;
  345
+    has $.thing;
345 346
 
346 347
     method message {
347  
-        "Yo dawg, I know you like a $.in so I put a $.in in your $.in"
  348
+        "Yo dawg, I know you like a $.thing so I put a $.thing $.relation your $.thing"
348 349
     }
349 350
 }
350 351
 
@@ -488,7 +489,7 @@ class Adventure::Engine {
488 489
         die X::Adventure::CannotPutInNonContainer.new(:$in)
489 490
             unless %!containers{$in};
490 491
 
491  
-        die X::Adventure::YoDawg.new(:$in)
  492
+        die X::Adventure::YoDawg.new(:relation<in>, :thing($in))
492 493
             if $thing eq $in;
493 494
 
494 495
         my @events;
@@ -511,6 +512,9 @@ class Adventure::Engine {
511 512
         die X::Adventure::CannotPutOnNonPlatform.new(:$on)
512 513
             unless %!platforms{$on};
513 514
 
  515
+        die X::Adventure::YoDawg.new(:relation<on>, :thing($on))
  516
+            if $thing eq $on;
  517
+
514 518
         Adventure::PlayerPutOn.new(:$thing, :$on);
515 519
     }
516 520
 
@@ -1145,7 +1149,8 @@ multi MAIN('test') {
1145 1149
             X::Adventure::YoDawg,
1146 1150
             'putting a thing inside another (-) but it is the same thing',
1147 1151
             {
1148  
-                is .in, 'box', '.in attribute';
  1152
+                is .relation, 'in', '.relation attribute';
  1153
+                is .thing, 'box', '.thing attribute';
1149 1154
                 is .message,
1150 1155
                     "Yo dawg, I know you like a box so I put a box in your box",
1151 1156
                     '.message attribute';
@@ -1186,6 +1191,25 @@ multi MAIN('test') {
1186 1191
             };
1187 1192
     }
1188 1193
 
  1194
+    {
  1195
+        my $engine = Adventure::Engine.new();
  1196
+
  1197
+        $engine.place_thing('surface', 'street');
  1198
+        $engine.make_thing_a_platform('surface');
  1199
+        $engine.place_player('street');
  1200
+        throws_exception
  1201
+            { $engine.put_thing_on('surface', 'surface') },
  1202
+            X::Adventure::YoDawg,
  1203
+            'putting a thing on another (-) but it is the same thing',
  1204
+            {
  1205
+                is .relation, 'on', '.relation attribute';
  1206
+                is .thing, 'surface', '.thing attribute';
  1207
+                is .message,
  1208
+                    "Yo dawg, I know you like a surface so I put a surface on your surface",
  1209
+                    '.message attribute';
  1210
+            };
  1211
+    }
  1212
+
1189 1213
     done;
1190 1214
 }
1191 1215
 

0 notes on commit 576954e

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