Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[bin/crypt] cannot put non-carryable things

  • Loading branch information...
commit a09a7a141729b575044ee296b93f2aa7b5b5135d 1 parent 9a88a7f
Carl Mäsak authored July 15, 2012

Showing 1 changed file with 54 additions and 5 deletions. Show diff stats Hide diff stats

  1. 59  bin/crypt
59  bin/crypt
@@ -558,6 +558,9 @@ class Adventure::Engine {
558 558
         die X::Adventure::PlayerNowhere.new()
559 559
             unless defined $!player_location;
560 560
 
  561
+        die X::Adventure::ThingNotCarryable.new(:action<put>, :$thing)
  562
+            unless %!carryable_things{$thing};
  563
+
561 564
         die X::Adventure::CannotPutInNonContainer.new(:$in)
562 565
             unless %!containers{$in};
563 566
 
@@ -584,6 +587,9 @@ class Adventure::Engine {
584 587
         die X::Adventure::PlayerNowhere.new()
585 588
             unless defined $!player_location;
586 589
 
  590
+        die X::Adventure::ThingNotCarryable.new(:action<put>, :$thing)
  591
+            unless %!carryable_things{$thing};
  592
+
587 593
         die X::Adventure::CannotPutOnNonPlatform.new(:$on)
588 594
             unless %!platforms{$on};
589 595
 
@@ -1218,8 +1224,9 @@ multi MAIN('test') {
1218 1224
         my $engine = Adventure::Engine.new();
1219 1225
 
1220 1226
         $engine.place_thing('box', 'street');
1221  
-        $engine.place_thing('doll', 'street');
1222 1227
         $engine.make_thing_a_container('box');
  1228
+        $engine.place_thing('doll', 'street');
  1229
+        $engine.make_thing_carryable('doll');
1223 1230
         $engine.place_player('street');
1224 1231
         is $engine.put_thing_in('doll', 'box'),
1225 1232
             Adventure::PlayerPutIn.new(
@@ -1233,8 +1240,9 @@ multi MAIN('test') {
1233 1240
         my $engine = Adventure::Engine.new();
1234 1241
 
1235 1242
         $engine.place_thing('brick', 'street');
1236  
-        $engine.place_thing('doll', 'street');
1237 1243
         # don't make brick a container
  1244
+        $engine.place_thing('doll', 'street');
  1245
+        $engine.make_thing_carryable('doll');
1238 1246
         $engine.place_player('street');
1239 1247
         throws_exception
1240 1248
             { $engine.put_thing_in('doll', 'brick') },
@@ -1252,9 +1260,10 @@ multi MAIN('test') {
1252 1260
         my $engine = Adventure::Engine.new();
1253 1261
 
1254 1262
         $engine.place_thing('crate', 'street');
1255  
-        $engine.place_thing('doll', 'street');
1256 1263
         $engine.make_thing_a_container('crate');
1257 1264
         $engine.make_thing_openable('crate');
  1265
+        $engine.place_thing('doll', 'street');
  1266
+        $engine.make_thing_carryable('doll');
1258 1267
         $engine.place_player('street');
1259 1268
         is $engine.put_thing_in('doll', 'crate'),
1260 1269
             [
@@ -1274,6 +1283,7 @@ multi MAIN('test') {
1274 1283
 
1275 1284
         $engine.place_thing('box', 'street');
1276 1285
         $engine.make_thing_a_container('box');
  1286
+        $engine.make_thing_carryable('box');
1277 1287
         $engine.place_player('street');
1278 1288
         throws_exception
1279 1289
             { $engine.put_thing_in('box', 'box') },
@@ -1292,8 +1302,9 @@ multi MAIN('test') {
1292 1302
         my $engine = Adventure::Engine.new();
1293 1303
 
1294 1304
         $engine.place_thing('surface', 'street');
1295  
-        $engine.place_thing('doll', 'street');
1296 1305
         $engine.make_thing_a_platform('surface');
  1306
+        $engine.place_thing('doll', 'street');
  1307
+        $engine.make_thing_carryable('doll');
1297 1308
         $engine.place_player('street');
1298 1309
         is $engine.put_thing_on('doll', 'surface'),
1299 1310
             Adventure::PlayerPutOn.new(
@@ -1307,8 +1318,9 @@ multi MAIN('test') {
1307 1318
         my $engine = Adventure::Engine.new();
1308 1319
 
1309 1320
         $engine.place_thing('hole', 'street');
1310  
-        $engine.place_thing('doll', 'street');
1311 1321
         # don't make hole a platform
  1322
+        $engine.place_thing('doll', 'street');
  1323
+        $engine.make_thing_carryable('doll');
1312 1324
         $engine.place_player('street');
1313 1325
         throws_exception
1314 1326
             { $engine.put_thing_on('doll', 'hole') },
@@ -1327,6 +1339,7 @@ multi MAIN('test') {
1327 1339
 
1328 1340
         $engine.place_thing('surface', 'street');
1329 1341
         $engine.make_thing_a_platform('surface');
  1342
+        $engine.make_thing_carryable('surface');
1330 1343
         $engine.place_player('street');
1331 1344
         throws_exception
1332 1345
             { $engine.put_thing_on('surface', 'surface') },
@@ -1456,6 +1469,42 @@ multi MAIN('test') {
1456 1469
             };
1457 1470
     }
1458 1471
 
  1472
+    {
  1473
+        my $engine = Adventure::Engine.new();
  1474
+
  1475
+        $engine.place_thing('box', 'street');
  1476
+        $engine.make_thing_a_container('box');
  1477
+        $engine.place_thing('doll', 'street');
  1478
+        # don't make doll carryable
  1479
+        $engine.place_player('street');
  1480
+        throws_exception
  1481
+            { $engine.put_thing_in('doll', 'box') },
  1482
+            X::Adventure::ThingNotCarryable,
  1483
+            'putting a thing inside another (-) not carryable',
  1484
+            {
  1485
+                is .action, 'put', '.action attribute';
  1486
+                is .thing, 'doll', '.thing attribute';
  1487
+            };
  1488
+    }
  1489
+
  1490
+    {
  1491
+        my $engine = Adventure::Engine.new();
  1492
+
  1493
+        $engine.place_thing('surface', 'street');
  1494
+        $engine.make_thing_a_platform('surface');
  1495
+        $engine.place_thing('doll', 'street');
  1496
+        # don't make doll carryable
  1497
+        $engine.place_player('street');
  1498
+        throws_exception
  1499
+            { $engine.put_thing_on('doll', 'surface') },
  1500
+            X::Adventure::ThingNotCarryable,
  1501
+            'putting a thing on another (-) not carryable',
  1502
+            {
  1503
+                is .action, 'put', '.action attribute';
  1504
+                is .thing, 'doll', '.thing attribute';
  1505
+            };
  1506
+    }
  1507
+
1459 1508
     done;
1460 1509
 }
1461 1510
 

0 notes on commit a09a7a1

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