Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

integrate the hanoi game more into the adventure

They are now real objects with descriptions and stuff.
  • Loading branch information...
commit 3aadbbfecbd721fe8827db2faf6858c50dc0ba37 1 parent 72e0e71
Carl Mäsak authored July 30, 2012
51  bin/crypt
@@ -1278,10 +1278,20 @@ class Crypt::Game {
1278 1278
                 };
1279 1279
 
1280 1280
             # Things in hall
1281  
-            .make_thing_carryable: 'tiny disk';
1282 1281
             .place_thing: 'helmet', 'hall';
1283 1282
             .make_thing_carryable: 'helmet';
1284 1283
             .make_thing_a_container: 'helmet';
  1284
+            .place_thing: 'hanoi', 'hall';
  1285
+            .make_thing_implicit: 'hanoi';
  1286
+            .make_thing_a_container: 'hanoi';
  1287
+            for <left middle right> X~ ' rod' -> $rod {
  1288
+                .place_thing: $rod, 'contents:hanoi';
  1289
+                .make_thing_a_platform: $rod;
  1290
+            }
  1291
+            for <tiny small medium large huge> X~ ' disk' -> $disk {
  1292
+                .place_thing: $disk, 'contents:left rod';
  1293
+            }
  1294
+            .make_thing_carryable: 'tiny disk';
1285 1295
 
1286 1296
             # Things in cave
1287 1297
             .place_thing: 'fire', 'cave';
@@ -1359,13 +1369,11 @@ class Crypt::Game {
1359 1369
     }
1360 1370
 
1361 1371
     method take($thing) {
1362  
-        my @events;
1363  
-        if $thing eq 'tiny disk' {
1364  
-            @events.push:
1365  
-                $!hanoi.remove('tiny disk'),
1366  
-                $!engine.place_thing('tiny disk', 'hall');
  1372
+        my @events = $!engine.take($thing);
  1373
+        if $thing eq 'tiny disk' && $!player_location eq 'hall' {
  1374
+            @events.unshift: $!hanoi.remove: $thing;
1367 1375
         }
1368  
-        return @events, $!engine.take($thing);
  1376
+        return @events;
1369 1377
     }
1370 1378
 
1371 1379
     method drop($thing) {
@@ -1377,7 +1385,11 @@ class Crypt::Game {
1377 1385
     }
1378 1386
 
1379 1387
     method put_thing_on($thing, $on) {
1380  
-        return $!engine.put_thing_on($thing, $on);
  1388
+        my @events = $!engine.put_thing_on($thing, $on);
  1389
+        if $thing eq 'tiny disk' && $on ~~ /^ (\w+) ' rod' $/ {
  1390
+            @events.push: $!hanoi.add: $thing, ~$0;
  1391
+        }
  1392
+        return @events;
1381 1393
     }
1382 1394
 
1383 1395
     method read($thing) {
@@ -3025,10 +3037,6 @@ multi MAIN('test') {
3025 3037
                     :disk('tiny disk'),
3026 3038
                     :source<left>,
3027 3039
                 ),
3028  
-                Adventure::ThingPlaced.new(
3029  
-                    :thing('tiny disk'),
3030  
-                    :room<hall>,
3031  
-                ),
3032 3040
                 Adventure::PlayerTook.new(
3033 3041
                     :thing('tiny disk'),
3034 3042
                 ),
@@ -3090,6 +3098,25 @@ multi MAIN('test') {
3090 3098
             'walking (+) abbreviated directions';
3091 3099
     }
3092 3100
 
  3101
+    {
  3102
+        my $game = game_from_hall();
  3103
+
  3104
+        $game.use('flashlight');
  3105
+        $game.take('tiny disk');
  3106
+        is $game.put_thing_on('tiny disk', 'middle rod'),
  3107
+            [
  3108
+                Adventure::PlayerPutOn.new(
  3109
+                    :thing('tiny disk'),
  3110
+                    :on('middle rod'),
  3111
+                ),
  3112
+                Hanoi::DiskAdded.new(
  3113
+                    :disk('tiny disk'),
  3114
+                    :target<middle>,
  3115
+                ),
  3116
+            ],
  3117
+            'can put tiny disk back after taking it';
  3118
+    }
  3119
+
3093 3120
     done;
3094 3121
 }
3095 3122
 
29  game-data/descriptions
@@ -62,6 +62,35 @@ more letter at the end, but it has since been worn away.
62 62
 It's fixed to the ground under the sign. For some reason it reminds you of
63 63
 objects used during religious ceremonies for offerings of different kinds.
64 64
 
  65
+== hanoi
  66
+The rods! The disks! So monstrous in its simplicity! So beautiful in its
  67
+complexity!
  68
+
  69
+== tiny disk
  70
+It's a bit heavy.
  71
+
  72
+== small disk
  73
+It's very heavy.
  74
+
  75
+== middle disk
  76
+It's enormously heavy.
  77
+
  78
+== large disk
  79
+It's indescribably heavy.
  80
+
  81
+== huge disk
  82
+It's so heavy that this description doesn't do its weight justice.
  83
+
  84
+== left rod
  85
+It's a rod and it's on the left.
  86
+
  87
+== middle rod
  88
+It's a rod and it's between the left rod and the right rod.
  89
+
  90
+== right rod
  91
+It's a rod and it's on the right. It's made of liquorice.
  92
+Nah, just kidding! It looks to be made of copper or something.
  93
+
65 94
 == helmet
66 95
 Once surely part of a big metal uniform, now it's just the helmet. The visor,
67 96
 seems to be fixed in place. The whole headpiece look like a big pot without a

0 notes on commit 3aadbbf

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