<?xml version="1.0"?>
<!--
Cloak of Darkness - a simple demonstration of Interactive Fiction
This version for AIEE written by Mark Hughes, 2003Jan04
Based on Cloak of Darkness by Roger Firth
http://www.firthworks.com/roger/cloak/
-->

<adventure start="foyer" maxscore="2">
  <intro>
    <text>\tCloak of Darkness
\n\tA basic IF demonstration, by Roger Firth
\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...?</text>
    <!-- variables default to 0 or empty string depending on context, but it's
      good practice to declare them.
    -->
    <set var="damage">0</set>
    <set var="hung_cloak">0</set>
  </intro>

  <item id="cloak" loc="player" article="a" name="black velvet cloak">
    <alias name="velvet"/>
    <alias name="cloak"/>
    <look>
      <text>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.</text>
    </look>
    <drop>
      <text>This isn't the best place to leave a smart cloak lying
around.</text>
      <abort/>
    </drop>
    <put>
      <!-- not that there's anything else to put it in, but... -->
      <if><test var="_arg2" op="ne">hook</test>
        <then>
          <text>This isn't the best place to leave a smart cloak lying
around.</text>
          <abort/>
        </then>
      </if>
      <if><test var="hung_cloak" op="eq">0</test>
        <then>
          <set var="hung_cloak">1</set>
          <score value="1"/>
        </then>
      </if>
    </put>
  </item>

  <room id="foyer" name="Foyer of the Opera House">
    <look>
      <text>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.</text>
    </look>
    <exit dir="s" room="bar"/>
    <exit dir="w" room="cloakroom"/>
    <exit dir="n">
      <text>You've only just arrived, and besides, the weather outside seems to
be getting worse.</text>
    </exit>
  </room>

  <room id="cloakroom" name="Cloak Room">
    <look>
      <text>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.</text>
    </look>
    <exit dir="e" room="foyer"/>
  </room>

  <item id="hook" loc="cloakroom" article="a" name="small brass hook">
    <alias name="brass hook"/>
    <alias name="hook"/>
    <alias name="peg"/>
    <invisible/>
    <!-- make it a container, so you can put the cloak in it (yes, but it's
      close enough). -->
    <container/>
    <!-- make it too heavy to take -->
    <weight value="9999"/>
    <look>
      <if><hasitem item="cloak"/>
        <then>
          <text>It's just a small brass hook with a cloak hanging on it.</text>
        </then>
        <else>
          <text>It's just a small brass hook screwed to the wall.</text>
        </else>
      </if>
      <abort/>
    </look>
  </item>

  <room id="bar" name="Foyer Bar">
    <enter>
      <if><hasitem owner="player" item="cloak"/>
        <then><light on="false"/></then>
        <else><light on="true"/></else>
      </if>
    </enter>

    <look>
      <text>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.</text>
    </look>

    <exit dir="n" room="foyer"/>

    <!-- Will not catch 'look' or special commands.  Tough luck, it'd be cruel
      to have the player's eyes disturb things. -->
    <command>
      <if><test var="_cmd" op="eq">m</test>
        <then>
          <text>Blundering around in the dark isn't a good idea!</text>
          <set var="damage" op="+">1</set>
        </then>
        <else>
          <text>In the dark? You could easily disturb something!</text>
          <set var="damage" op="+">1</set>
        </else>
      </if>
      <abort/>
    </command>
  </room>

  <item id="message" loc="bar" article="a" name="scrawled message">
    <alias name="message"/>
    <alias name="floor"/>
    <alias name="sawdust"/>
    <invisible/>
    <!-- make it too heavy to take -->
    <weight value="9999"/>
    <look>
      <if><test var="damage" op="lt">2</test>
        <then>
          <score value="1"/>
          <text>The message, neatly marked in the sawdust, reads...
\n\n\t*** You have won ***\n</text>
        </then>
        <else>
          <text>The message has been carelessly trampled, making it difficult
          to read.  You can just distinguish the words...
\n\n\t*** You have lost ***\n</text>
        </else>
      </if>
      <gameover/>
    </look>
  </item>

</adventure>