merentha_fluffos_v2/
merentha_fluffos_v2/bin/
merentha_fluffos_v2/fluffos-2.9-ds2.03/
merentha_fluffos_v2/fluffos-2.9-ds2.03/ChangeLog.old/
merentha_fluffos_v2/fluffos-2.9-ds2.03/Win32/
merentha_fluffos_v2/fluffos-2.9-ds2.03/compat/
merentha_fluffos_v2/fluffos-2.9-ds2.03/compat/simuls/
merentha_fluffos_v2/fluffos-2.9-ds2.03/include/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/clone/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/command/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/data/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/etc/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/include/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/inherit/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/inherit/master/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/log/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/single/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/single/tests/compiler/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/single/tests/efuns/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/single/tests/operators/
merentha_fluffos_v2/fluffos-2.9-ds2.03/testsuite/u/
merentha_fluffos_v2/fluffos-2.9-ds2.03/tmp/
merentha_fluffos_v2/fluffos-2.9-ds2.03/windows/
merentha_fluffos_v2/lib/cfg/
merentha_fluffos_v2/lib/cfg/races/
merentha_fluffos_v2/lib/cmds/abilities/
merentha_fluffos_v2/lib/cmds/actions/
merentha_fluffos_v2/lib/cmds/spells/
merentha_fluffos_v2/lib/daemon/include/
merentha_fluffos_v2/lib/daemon/services/
merentha_fluffos_v2/lib/doc/
merentha_fluffos_v2/lib/doc/building/
merentha_fluffos_v2/lib/doc/help/classes/
merentha_fluffos_v2/lib/doc/help/general/
merentha_fluffos_v2/lib/doc/help/races/
merentha_fluffos_v2/lib/doc/help/skills/
merentha_fluffos_v2/lib/doc/help/stats/
merentha_fluffos_v2/lib/doc/man/efuns/
merentha_fluffos_v2/lib/doc/man/lfuns/
merentha_fluffos_v2/lib/doc/news/
merentha_fluffos_v2/lib/doc/old/
merentha_fluffos_v2/lib/doc/old/concepts/
merentha_fluffos_v2/lib/doc/old/lpc/constructs/
merentha_fluffos_v2/lib/doc/old/lpc/types/
merentha_fluffos_v2/lib/domains/ROOMS/
merentha_fluffos_v2/lib/domains/obj/armour/
merentha_fluffos_v2/lib/domains/obj/monsters/
merentha_fluffos_v2/lib/domains/obj/other/
merentha_fluffos_v2/lib/domains/obj/weapons/
merentha_fluffos_v2/lib/realms/petrarch/
merentha_fluffos_v2/lib/save/daemons/
merentha_fluffos_v2/lib/save/rid/
merentha_fluffos_v2/lib/save/users/a/
merentha_fluffos_v2/lib/save/users/p/
merentha_fluffos_v2/lib/save/users/t/
merentha_fluffos_v2/lib/std/login/
merentha_fluffos_v2/lib/std/obj/
merentha_fluffos_v2/win32/
// Petrarch
// Merentha Lib 1.0
// room.c

#include <std.h>
#include "room.h"

inherit CONTAINER;

mapping __Smells=([]), __Sounds=([]), __Exits=([]), __Items=([]);
string *__InvisExits=({});

int is_room() { return 1; }

void create() {
    ::create();
}

void init() {
    ::init();
    add_action("cmd_go", ({"go", "enter"}));
}

varargs int cmd_go(string str) {
    if(!str) return 0;
    if(!__Exits || sizeof(__Exits)==0) return 0;
    if(member_array(str, keys(__Exits))==-1) return 0;
if(!file_exists(__Exits[str]) && !file_exists(__Exits[str]+".c"))
message("movement", "As you attempt to move there a massive force pushes you back.\nThe world does not exist past this point.", this_player());
else
    this_player()->move_player(__Exits[str]);
    return 1;
}

string get_long_exits() {
string *exits=keys(__Exits);
string ret="";
int j,i;
exits-=__InvisExits;
i=sizeof(exits);
if (i==0) return 0;
if (i==1) ret="is one";
else ret="are "+formal_number(i);
ret="There "+ret+" visible exits:%^BOLD%^%^GREEN%^";
j=i;
while(i--) {
  if(i==0) {
     if(j>1) ret+=" and "+exits[i]+".";
     else ret+=" "+exits[i];
  } else {
  if(i+1!=j) ret+=", "+exits[i];
  else ret+=" "+exits[i];
  }
}
  return ret;
}

string describe_room(int verbose) {
    string desc="";
    string exits;
    if(this_player())
        if(admin_p(this_player())) desc+=file_name(this_object())+"\n";
    if(verbose) {
        desc+=query_long()+"\n";
        if(__Smells["default"]) desc+="%^ORANGE%^"+__Smells["default"]+"%^RESET%^\n";
        if(__Sounds["default"]) desc+="%^CYAN%^"+__Sounds["default"]+"%^RESET%^\n";
    } else {
        desc+=query_short()+"\n";
    }
    desc+="%^BOLD%^%^RED%^"+get_living_contents();
    desc+="%^MAGENTA%^\n"+get_nonliving_contents();
    if(exits=get_long_exits()) desc+="%^RESET%^%^GREEN%^"+exits;
    return desc;
}

void set_smells(mapping args) { __Smells=args; }
void set_smell(string item, string smell) { __Smells[item]=smell; }
void add_smell(string item, string smell) { set_smell(item, smell); }
void remove_smell(string item) { map_delete(__Smells, item); }
mapping query_smells() { return __Smells; }
string query_smell(string item) {
    if(!item) item="default";
    return __Smells[item];
}

void set_sounds(mapping args) { __Sounds=args; }
void set_sound(string item, string sound) { __Sounds[item]=sound; }
void add_sound(string item, string sound) { set_sound(item, sound); }
void remove_sound(string item) { map_delete(__Sounds, item); }
mapping query_sounds() { return __Sounds; }
string query_sound(string item) {
    if(!item) item="default";
    return __Sounds[item];
}

void set_exits(mapping args) { __Exits=args; }
void add_exit(string dir, string dest) { __Exits[dir]=dest; }
void remove_exit(string dir) { map_delete(__Exits, dir); }
string query_exit(string dir) { return __Exits[dir]; }
string *query_exits() { return keys(__Exits); }
void set_exit_invis(string dir) { __InvisExits+=({dir}); }
void set_exit_vis(string dir) { __InvisExits-=({dir}); }

void set_items(mapping args) { __Items=args; }
void add_item(string item, string desc) { __Items[item]=desc; }
void remove_item(string item) { map_delete(__Items, item); }
string query_item(string item) { 
  if (!item) return 0;
  if (__Items[item]) return __Items[item]; 
  if (__Items[item+"s"]) return __Items[item+"s"]; 
  if (__Items[item+"es"]) return __Items[item+"es"]; 
  if (__Items[item[0..<2]]) return __Items[item[0..<2]]; 
  if (__Items[item[0..<3]]) return __Items[item[0..<3]]; 
}