Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
Showing with 68 additions and 12 deletions.
  1. +39 −12 bin/crypt
  2. +29 −0 game-data/descriptions
51 bin/crypt
View
@@ -1278,10 +1278,20 @@ class Crypt::Game {
};
# Things in hall
- .make_thing_carryable: 'tiny disk';
.place_thing: 'helmet', 'hall';
.make_thing_carryable: 'helmet';
.make_thing_a_container: 'helmet';
+ .place_thing: 'hanoi', 'hall';
+ .make_thing_implicit: 'hanoi';
+ .make_thing_a_container: 'hanoi';
+ for <left middle right> X~ ' rod' -> $rod {
+ .place_thing: $rod, 'contents:hanoi';
+ .make_thing_a_platform: $rod;
+ }
+ for <tiny small medium large huge> X~ ' disk' -> $disk {
+ .place_thing: $disk, 'contents:left rod';
+ }
+ .make_thing_carryable: 'tiny disk';
# Things in cave
.place_thing: 'fire', 'cave';
@@ -1359,13 +1369,11 @@ class Crypt::Game {
}
method take($thing) {
- my @events;
- if $thing eq 'tiny disk' {
- @events.push:
- $!hanoi.remove('tiny disk'),
- $!engine.place_thing('tiny disk', 'hall');
+ my @events = $!engine.take($thing);
+ if $thing eq 'tiny disk' && $!player_location eq 'hall' {
+ @events.unshift: $!hanoi.remove: $thing;
}
- return @events, $!engine.take($thing);
+ return @events;
}
method drop($thing) {
@@ -1377,7 +1385,11 @@ class Crypt::Game {
}
method put_thing_on($thing, $on) {
- return $!engine.put_thing_on($thing, $on);
+ my @events = $!engine.put_thing_on($thing, $on);
+ if $thing eq 'tiny disk' && $on ~~ /^ (\w+) ' rod' $/ {
+ @events.push: $!hanoi.add: $thing, ~$0;
+ }
+ return @events;
}
method read($thing) {
@@ -3025,10 +3037,6 @@ multi MAIN('test') {
:disk('tiny disk'),
:source<left>,
),
- Adventure::ThingPlaced.new(
- :thing('tiny disk'),
- :room<hall>,
- ),
Adventure::PlayerTook.new(
:thing('tiny disk'),
),
@@ -3090,6 +3098,25 @@ multi MAIN('test') {
'walking (+) abbreviated directions';
}
+ {
+ my $game = game_from_hall();
+
+ $game.use('flashlight');
+ $game.take('tiny disk');
+ is $game.put_thing_on('tiny disk', 'middle rod'),
+ [
+ Adventure::PlayerPutOn.new(
+ :thing('tiny disk'),
+ :on('middle rod'),
+ ),
+ Hanoi::DiskAdded.new(
+ :disk('tiny disk'),
+ :target<middle>,
+ ),
+ ],
+ 'can put tiny disk back after taking it';
+ }
+
done;
}
29 game-data/descriptions
View
@@ -62,6 +62,35 @@ more letter at the end, but it has since been worn away.
It's fixed to the ground under the sign. For some reason it reminds you of
objects used during religious ceremonies for offerings of different kinds.
+== hanoi
+The rods! The disks! So monstrous in its simplicity! So beautiful in its
+complexity!
+
+== tiny disk
+It's a bit heavy.
+
+== small disk
+It's very heavy.
+
+== middle disk
+It's enormously heavy.
+
+== large disk
+It's indescribably heavy.
+
+== huge disk
+It's so heavy that this description doesn't do its weight justice.
+
+== left rod
+It's a rod and it's on the left.
+
+== middle rod
+It's a rod and it's between the left rod and the right rod.
+
+== right rod
+It's a rod and it's on the right. It's made of liquorice.
+Nah, just kidding! It looks to be made of copper or something.
+
== helmet
Once surely part of a big metal uniform, now it's just the helmet. The visor,
seems to be fixed in place. The whole headpiece look like a big pot without a
Please sign in to comment.
Something went wrong with that request. Please try again.