! ============================================================================ !
!   Cloak of Darkness - a simple demonstration of Interactive Fiction
!       Original Inform version written by Roger Firth on 17Sep99
!       This version for HUGO written by John Menichelli on 19Sep99
! ============================================================================ !

#version 2.5

#set VERBSTUBS                  ! include verb stub routines

#set NO_AUX_MATH                ! don't need advanced math routines

#switches -ls                   ! print statistics to CLOAK.LST
#ifset DEBUG
#switches -d
#endif

verb "hang"
    * held "on" xobject  DoPutIn

#include "verblib.g"            ! normal verb grammar

!----------------------------------------------------------------------------

#ifset PRECOMPILED_LIBRARY
#link "hugolib.hlb"
#else
#include "hugolib.h"            ! standard library routines
#endif

property fake_number

routine init
{
    counter = -1                ! 1 turn before turn 0

    MAX_SCORE = 2
    STATUSTYPE = 1              ! score/turns
    TEXTCOLOR = DEF_FOREGROUND
    BGCOLOR = DEF_BACKGROUND
    SL_TEXTCOLOR = DEF_SL_FOREGROUND
    SL_BGCOLOR = DEF_SL_BACKGROUND

    prompt = ">"
    color TEXTCOLOR, BGCOLOR

    DEFAULT_FONT = PROP_OFF
    Font(DEFAULT_FONT)

    cls

    "\n\nHurrying through the rainswept November night, you're glad to see the
    bright lights of the Opera House. It's surprising that there aren't more
    people about but, hey, what do you expect in a cheap demo game...?\n\n"

    Font(BOLD_ON)
    "Cloak of Darkness"
    Font(BOLD_OFF)
    "A Basic IF Demonstration"
    print BANNER

    player = you
    location = foyer
    old_location = location

    move player to location     ! initialize player location
    FindLight(location)         ! whether the player can see
    DescribePlace(location)     ! the appropriate description
    location is visited
    CalculateHolding(player)    ! total size of player contents

    Acquire(player, cloak)      ! give the player the cloak
    cloak is known, worn
}

#ifset PRECOMPILED_LIBRARY
replace main
{
#else
routine main
{
#endif
    counter++
    PrintStatusLine
    run location.each_turn
    runevents
    RunScripts
    if speaking not in location ! in case the character being spoken
        speaking = 0            ! to leaves
}

player_character you "you"
{}


room foyer "Foyer of the Opera House"
{
    long_desc
    {
       "You are standing in a spacious hall, splendidly decorated in red
        and gold, with glittering chandeliers overhead. The entrance from
        the street is to the north, and there are doorways south and west."
    }    
    s_to  bar
    w_to  cloakroom
    n_to
    {
       "You've only just arrived, and besides, the weather outside
        seems to be getting worse."
    }
    is light
}

room cloakroom "Cloakroom"
{
    long_desc
    {
       "The walls of this small room were clearly once lined with hooks,
        though now only one remains. The exit is a door to the east."
    }
    e_to  foyer
    is light
}

scenery hook "small brass hook"
{
    nouns "hook" "peg"
    adjectives "small" "brass"
    article "the"
    in cloakroom
    long_desc
    {
        "It's just a small brass hook, ";
        if Contains(hook, cloak)
        {
            "with a cloak hanging on it."
        }
        else
        {       
            "screwed to the wall."
        }
    }
    is platform
    capacity 2
}
    
room bar "Foyer bar"
{
    long_desc
    {
       "The bar, much rougher than you'd have guessed after the opulence
        of the foyer to the north, is completely empty. There seems to
        be some sort of message scrawled in the sawdust on the floor."
    }           
    n_to foyer
    before
    {
        location DoGo
        {
            if self is not light and object ~= n_obj
            {
                scrawled_message.fake_number += 2
                "Blundering around in the dark isn't a good idea!"
            }
            else
                MovePlayer(n_obj)
        }        
        AnyVerb(location)
        {
            if verbroutine = &DoGo, &DoExit, &MovePlayer : return
            
            if self is not light
            {
                scrawled_message.fake_number++
                "In the dark? You could easily disturb something!"
                return true
            }
            return false    
        }
    }
    is not light
}

object cloak "velvet cloak"
{
    noun "cloak"
    adjectives "handsome" "dark" "black" "velvet" "satin"
    article "a"
    long_desc
    {
       "A handsome cloak, of velvet trimmed with satin, and slightly
        spattered with raindrops. Its blackness is so deep that it
        almost seems to suck light from the room."
    }           
    before
    {
        object DoDrop, DoPutIn
        {
            if xobject = hook or location = cloakroom
            {
                bar is light
                if self is not special
                {
                    score++
                    self is special
                }
                return false
            }
            else
            {
                "This isn't the best place to leave a smart cloak
                lying around."
                return true
            }
        }
    }
    after
    {
        object DoGet
        {
            bar is not light
            return false
        }
    }
    is clothing
    size 2
}

scenery scrawled_message "scrawled message"
{
    noun "message" "sawdust" "floor"
    in bar
    long_desc
    {
        if self.fake_number < 2
        {
            score++
           "The message, neatly marked in the sawdust, reads...\n\n
            You have won!"
            endflag = 3
        }
        else
        {
           "The message has been carelessly trampled, making it
            difficult to read. You can just distinguish the words...\n\n
            You have lost."
            endflag = 3
        }
    }
    fake_number 0
    is readable
}