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 take the tiny disk from hanoi

  • Loading branch information...
commit 07222ec4f5360b67bde31915e854359b5167cb9b 1 parent acf6aef
Carl Mäsak authored

Showing 1 changed file with 29 additions and 1 deletion. Show diff stats Hide diff stats

  1. 30  bin/crypt
30  bin/crypt
@@ -1191,6 +1191,7 @@ class Crypt::Game {
1191 1191
                 };
1192 1192
 
1193 1193
             # Things in hall
  1194
+            .make_thing_carryable: 'tiny disk';
1194 1195
             .place_thing: 'helmet', 'hall';
1195 1196
             .make_thing_carryable: 'helmet';
1196 1197
             .make_thing_a_container: 'helmet';
@@ -1257,7 +1258,13 @@ class Crypt::Game {
1257 1258
     }
1258 1259
 
1259 1260
     method take($thing) {
1260  
-        return $!engine.take($thing);
  1261
+        my @events;
  1262
+        if $thing eq 'tiny disk' {
  1263
+            @events.push:
  1264
+                $!hanoi.remove('tiny disk'),
  1265
+                $!engine.place_thing('tiny disk', 'hall');
  1266
+        }
  1267
+        return @events, $!engine.take($thing);
1261 1268
     }
1262 1269
 
1263 1270
     method drop($thing) {
@@ -2807,6 +2814,27 @@ multi MAIN('test') {
2807 2814
             'not getting out in time before the cavern collapses';
2808 2815
     }
2809 2816
 
  2817
+    {
  2818
+        my $game = game_from_hall();
  2819
+
  2820
+        $game.use('flashlight');
  2821
+        is $game.take('tiny disk'),
  2822
+            [
  2823
+                Hanoi::DiskRemoved.new(
  2824
+                    :disk('tiny disk'),
  2825
+                    :source<left>,
  2826
+                ),
  2827
+                Adventure::ThingPlaced.new(
  2828
+                    :thing('tiny disk'),
  2829
+                    :room<hall>,
  2830
+                ),
  2831
+                Adventure::PlayerTook.new(
  2832
+                    :thing('tiny disk'),
  2833
+                ),
  2834
+            ],
  2835
+            'can take the tiny disk from the hanoi game';
  2836
+    }
  2837
+
2810 2838
     done;
2811 2839
 }
2812 2840
 

0 notes on commit 07222ec

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