Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[bin/crypt] you can put leaves in the basket

  • Loading branch information...
commit 5fcb6488f78e72309f99bc972cd00886533471b1 1 parent 88c1694
@masak authored
Showing with 60 additions and 5 deletions.
  1. +56 −5 bin/crypt
  2. +4 −0 game-data/descriptions
View
61 bin/crypt
@@ -504,6 +504,11 @@ class Adventure::Engine {
return False;
}
+ method !thing_in_room_or_inventory($thing) {
+ self!is_thing_in($thing, $!player_location)
+ || self!is_thing_in($thing, 'player inventory');
+ }
+
method walk($direction) {
die X::Adventure::PlayerNowhere.new()
unless defined $!player_location;
@@ -636,8 +641,11 @@ class Adventure::Engine {
die X::Adventure::PlayerNowhere.new()
unless defined $!player_location;
- # XXX: should check if the first thing is there
- # XXX: should check if the second thing is there
+ die X::Adventure::NoSuchThingHere.new(:$thing)
+ unless self!thing_in_room_or_inventory($thing);
+
+ die X::Adventure::NoSuchThingHere.new(:thing($in))
+ unless self!thing_in_room_or_inventory($in);
die X::Adventure::ThingNotCarryable.new(:action<put>, :$thing)
unless %!carryable_things{$thing};
@@ -876,7 +884,7 @@ class Crypt::Game {
.alias_direction('chamber', 'out', 'north');
.connect(<chamber hall>, 'south');
.alias_direction('chamber', 'in', 'south');
- .alias_direction('cave', 'out', 'north');
+ .alias_direction('hall', 'out', 'north');
.connect(<hall cave>, 'down');
.connect(<cave crypt>, 'northwest');
.on_try_exit('cave', 'northwest', {
@@ -896,8 +904,7 @@ class Crypt::Game {
'car',
-> $_ {
when 'leaves' { $!engine.remark('car-full-of-leaves') }
- }
- );
+ });
# Things on hill
.place_thing('grass', 'hill');
@@ -916,6 +923,18 @@ class Crypt::Game {
.make_thing_implicit('leaves');
.make_thing_carryable('leaves');
+ # Things in chamber
+ .place_thing('basket', 'chamber');
+ .make_thing_a_container('basket');
+ .on_put(
+ 'basket',
+ -> $_ {
+ when 'leaves' {
+ $!engine.connect(<chamber hall>, 'south'),
+ $!engine.remark('passageway-opens-up');
+ }
+ });
+
.place_player('clearing');
}
}
@@ -1973,6 +1992,7 @@ multi MAIN('test') {
Adventure::PlayerLooked.new(
:room<chamber>,
:exits<south north>,
+ :things<basket>,
),
],
'walking into the hill (+) after opening the door';
@@ -2011,6 +2031,37 @@ multi MAIN('test') {
'putting the leaves in the car';
}
+ sub game_from_chamber {
+ my $game = Crypt::Game.new();
+
+ $game.walk('east');
+ $game.take('leaves');
+ $game.examine('bushes');
+ $game.open('door');
+ $game.walk('in');
+ return $game;
+ }
+
+ {
+ my $game = game_from_chamber();
+
+ is $game.put_thing_in('leaves', 'basket'),
+ [
+ Adventure::PlayerPutIn.new(
+ :thing<leaves>,
+ :in<basket>,
+ ),
+ Adventure::TwoRoomsConnected.new(
+ :rooms<chamber hall>,
+ :direction<south>,
+ ),
+ Adventure::GameRemarked.new(
+ :remark<passageway-opens-up>,
+ ),
+ ],
+ 'putting the leaves in the basket';
+ }
+
done;
}
View
4 game-data/descriptions
@@ -55,3 +55,7 @@ They look like the kind of leaves that would love a good rustle.
== remark:car-full-of-leaves
Great. Now your car is full of leaves.
+
+== remark:passageway-opens-up
+The ground rumbles and shakes a bit.
+A passageway opens up to the south, into the caverns.
Please sign in to comment.
Something went wrong with that request. Please try again.