Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[bin/crypt] disallow doing things when nowhere

  • Loading branch information...
commit 1744ffdb7e7b52ec1ddddfd174761ca3ab2c8196 1 parent 9dc3615
Carl Mäsak authored July 14, 2012

Showing 1 changed file with 18 additions and 0 deletions. Show diff stats Hide diff stats

  1. 18  bin/crypt
18  bin/crypt
@@ -433,6 +433,9 @@ class Adventure::Engine {
433 433
     }
434 434
 
435 435
     method look() {
  436
+        die X::Adventure::PlayerIsNowhere.new()
  437
+            unless defined $!player_location;
  438
+
436 439
         my @events = Adventure::PlayerLooked.new(
437 440
             :room($!player_location),
438 441
             :exits(%!exits{$!player_location}.keys),
@@ -470,6 +473,9 @@ class Adventure::Engine {
470 473
     }
471 474
 
472 475
     method examine($thing) {
  476
+        die X::Adventure::PlayerIsNowhere.new()
  477
+            unless defined $!player_location;
  478
+
473 479
         die X::Adventure::NoSuchThingHere.new(:$thing)
474 480
             unless (%!thing_rooms{$thing} // '') eq $!player_location;
475 481
 
@@ -485,6 +491,9 @@ class Adventure::Engine {
485 491
     }
486 492
 
487 493
     method open($thing) {
  494
+        die X::Adventure::PlayerIsNowhere.new()
  495
+            unless defined $!player_location;
  496
+
488 497
         die X::Adventure::ThingNotOpenable.new(:$thing)
489 498
             unless %!openable_things{$thing};
490 499
 
@@ -503,6 +512,9 @@ class Adventure::Engine {
503 512
     }
504 513
 
505 514
     method put_thing_in($thing, $in) {
  515
+        die X::Adventure::PlayerIsNowhere.new()
  516
+            unless defined $!player_location;
  517
+
506 518
         die X::Adventure::CannotPutInNonContainer.new(:$in)
507 519
             unless %!containers{$in};
508 520
 
@@ -526,6 +538,9 @@ class Adventure::Engine {
526 538
     }
527 539
 
528 540
     method put_thing_on($thing, $on) {
  541
+        die X::Adventure::PlayerIsNowhere.new()
  542
+            unless defined $!player_location;
  543
+
529 544
         die X::Adventure::CannotPutOnNonPlatform.new(:$on)
530 545
             unless %!platforms{$on};
531 546
 
@@ -542,6 +557,9 @@ class Adventure::Engine {
542 557
     }
543 558
 
544 559
     method read($thing) {
  560
+        die X::Adventure::PlayerIsNowhere.new()
  561
+            unless defined $!player_location;
  562
+
545 563
         die X::Adventure::ThingIsNotReadable.new(:$thing)
546 564
             unless %!readable_things{$thing};
547 565
 

0 notes on commit 1744ffd

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