nightmare3_fluffos_v2/
nightmare3_fluffos_v2/bin/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/ChangeLog.old/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/Win32/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/compat/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/compat/simuls/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/include/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/clone/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/command/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/data/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/etc/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/include/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/inherit/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/inherit/master/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/log/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/tests/compiler/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/tests/efuns/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/tests/operators/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/u/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/tmp/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/windows/
nightmare3_fluffos_v2/lib/cmds/ambassador/
nightmare3_fluffos_v2/lib/cmds/database/
nightmare3_fluffos_v2/lib/cmds/hm/
nightmare3_fluffos_v2/lib/cmds/soul/
nightmare3_fluffos_v2/lib/daemon/cfg/
nightmare3_fluffos_v2/lib/daemon/cfg/mon_races/
nightmare3_fluffos_v2/lib/daemon/cfg/races/
nightmare3_fluffos_v2/lib/daemon/include/
nightmare3_fluffos_v2/lib/daemon/save/
nightmare3_fluffos_v2/lib/daemon/services/
nightmare3_fluffos_v2/lib/daemon/soul/
nightmare3_fluffos_v2/lib/doc/
nightmare3_fluffos_v2/lib/doc/TestPlans/
nightmare3_fluffos_v2/lib/doc/approval/
nightmare3_fluffos_v2/lib/doc/approval/QC/
nightmare3_fluffos_v2/lib/doc/approval/balance/
nightmare3_fluffos_v2/lib/doc/build/
nightmare3_fluffos_v2/lib/doc/build/armours/
nightmare3_fluffos_v2/lib/doc/build/economy/
nightmare3_fluffos_v2/lib/doc/build/etc/
nightmare3_fluffos_v2/lib/doc/build/monster/
nightmare3_fluffos_v2/lib/doc/build/room/
nightmare3_fluffos_v2/lib/doc/build/virtual/
nightmare3_fluffos_v2/lib/doc/build/weapon/
nightmare3_fluffos_v2/lib/doc/classes/
nightmare3_fluffos_v2/lib/doc/efun/
nightmare3_fluffos_v2/lib/doc/etc/
nightmare3_fluffos_v2/lib/doc/help/creator/
nightmare3_fluffos_v2/lib/doc/help/hm/
nightmare3_fluffos_v2/lib/doc/law/
nightmare3_fluffos_v2/lib/doc/lpc/basic/
nightmare3_fluffos_v2/lib/doc/lpc/data_types/
nightmare3_fluffos_v2/lib/doc/lpc/etc/
nightmare3_fluffos_v2/lib/doc/lpc/intermediate/
nightmare3_fluffos_v2/lib/doc/lpc/types/
nightmare3_fluffos_v2/lib/doc/mudlib/
nightmare3_fluffos_v2/lib/doc/mudlib/features/
nightmare3_fluffos_v2/lib/domains/Examples/etc/
nightmare3_fluffos_v2/lib/domains/Examples/room/
nightmare3_fluffos_v2/lib/domains/Examples/virtual/
nightmare3_fluffos_v2/lib/domains/Examples/virtual/exaA/
nightmare3_fluffos_v2/lib/domains/Examples/virtual/exaB/
nightmare3_fluffos_v2/lib/domains/Examples/weapon/
nightmare3_fluffos_v2/lib/domains/Praxis/
nightmare3_fluffos_v2/lib/domains/Praxis/adm/
nightmare3_fluffos_v2/lib/domains/Praxis/attic/
nightmare3_fluffos_v2/lib/domains/Praxis/cemetary/
nightmare3_fluffos_v2/lib/domains/Praxis/cemetary/mon/
nightmare3_fluffos_v2/lib/domains/Praxis/data/
nightmare3_fluffos_v2/lib/domains/Praxis/death/
nightmare3_fluffos_v2/lib/domains/Praxis/mountains/
nightmare3_fluffos_v2/lib/domains/Praxis/obj/armour/
nightmare3_fluffos_v2/lib/domains/Praxis/obj/magic/
nightmare3_fluffos_v2/lib/domains/Praxis/obj/weapon/
nightmare3_fluffos_v2/lib/domains/Praxis/orc_valley/
nightmare3_fluffos_v2/lib/domains/Praxis/quests/
nightmare3_fluffos_v2/lib/domains/Praxis/standardOld/
nightmare3_fluffos_v2/lib/include/
nightmare3_fluffos_v2/lib/log/
nightmare3_fluffos_v2/lib/log/errors/
nightmare3_fluffos_v2/lib/log/reports/
nightmare3_fluffos_v2/lib/log/watch/
nightmare3_fluffos_v2/lib/news/
nightmare3_fluffos_v2/lib/secure/cfg/
nightmare3_fluffos_v2/lib/secure/cmds/ambassador/
nightmare3_fluffos_v2/lib/secure/cmds/mortal/
nightmare3_fluffos_v2/lib/secure/save/users/d/
nightmare3_fluffos_v2/lib/secure/std/
nightmare3_fluffos_v2/lib/std/hm/
nightmare3_fluffos_v2/lib/std/living/
nightmare3_fluffos_v2/lib/std/room/
nightmare3_fluffos_v2/lib/std/user/
nightmare3_fluffos_v2/lib/std/virtual/
nightmare3_fluffos_v2/lib/www/
nightmare3_fluffos_v2/lib/www/errors/
nightmare3_fluffos_v2/lib/www/gateways/
nightmare3_fluffos_v2/win32/
/*    /domains/Praxis/order.c
 *    from Nightmare IV
 *    a deed for a high mortal room
 *    created by Descartes of Borg 940701
 */

#include <std.h>
#include <dirs.h>
#include <daemons.h>
#include <security.h>

inherit OBJECT;

int __Light, __Indoors;
string __Short, __Long, __Exit, __NewRoom, __EstateLong;

static private string create_file();

void create() {
    Object::create();
    set_name("deed");
    set_id( ({ "estate deed", "deed" }) );
    set_short("an estate deed");
    set_long("A deed to your very own high mortal estate, with a work "
      "order to have workers begin to create your estate "
      "to your desires.  In order to build your estate, go "
      "to the place where you want it built, and type: "
      "\"build estate\".  You will be asked some questions "
      "about the room which will serve as the entrance to your estate."
    );
    set_mass(10);
    set_value(99);
    set_destroy();
}

void init() {
    Object::init();
    add_action("cmd_build", "build");
}

static int cmd_build(string str) {
    if(str != "estate") return 0;
    if(!high_mortalp(this_player())) 
      return notify_fail("Only high mortals may build!\n");
    if((int)environment(this_player())->query_property("indoors")) {
        message("system", "You cannot build an estate indoors!", this_player());
        return 1;
    }
    if(sizeof(filter_array(all_inventory(environment(this_player())),
      "estates", this_object())) >=
      (int)environment(this_player())->query_property("allow estate")) {
        message("system", "This area cannot support an estate.",this_player());
        return 1;
    }
    if(file_size(ESTATES_DIRS+"/"+geteuid(this_player())) != -2) {
        seteuid(UID_ESTATES);
        mkdir(ESTATES_DIRS+"/"+geteuid(this_player()));
        seteuid(getuid());
    }
    __Exit = "$"+file_name(environment(this_player()))+";$exit";
    message("system", "Give a one to two line description of your estate:",
      this_player());
    input_to("input_long");
    return 1;
}

static void input_long(string str) {
    if(str == "") {
        message("system", "Invalid entry.", this_player());
        return;
    }
    __EstateLong = str;
    message("system", "Please give a short description for the room "
      "people will enter from here.  This is the description like "
      "\"the entrance to "+(string)this_player()->query_CapName()+"'s"
      " estate\" that is seen when in brief mode.", this_player());
    message("prompt", "Enter in a short description: ", this_player());
    input_to("input_short");
}

static void input_short(string str) {
    __Short = str;
    message("prompt", "Is the room 0) outdoors, or 1) indoors? ", this_player());
    input_to("input_indoors");
    return;
}

static void input_indoors(string str) {
    int x;

    x = to_int(str);
    if(x && x != 1) {
        message("system", "That was not a valid value.", this_player());
        return;
    }
    __Indoors = x;
    message("system", "How well lit is the room?", this_player());
    message("system", "    0 is darkest, 3 brightest", this_player());
    message("prompt", "\nEnter light value: ", this_player());
    input_to("input_light");
}

static void input_light(string str) {
    int x;

    x = to_int(str);
    if(x && x != 1 && x != 2 && x != 3) {
        message("system", "Invalid light number.", this_player());
        return;
    }
    __Light = x;
    message("system", "Enter in a long description for the room.  "
      "A long description is what people see when they enter a "
      "room in verbose mode.  A line showing obvious exits is automatically "
      "appended.  In addition, if you add any smells or sounds, the "
      "default ones are automatically appended.  So do not describe sounds or "
      "smells here.", this_player());
    message("system", "Enter in the long description like mail.", this_player());
    rm(DIR_TMP+"/"+geteuid(this_player())+".estate");
    this_player()->edit(DIR_TMP+"/"+geteuid(this_player())+".estate",
      "done_edit", this_object());
}

void abort() {
    rm(DIR_TMP+"/"+geteuid(this_player())+".estate");
    message("system", "Building aborted.", this_player());
}

void done_edit(mixed *unused) {
    string str;

    if(!(str = read_file(DIR_TMP+"/"+geteuid(this_player())+".estate"))) {
        message("system", "No long!", this_player());
        return;
    }
    __Long = replace_string(str, "\n", " ");
    __NewRoom= create_file();
    seteuid(UID_ESTATES);
    write_file(__NewRoom, "set_property: $indoors;#"+__Indoors+"\n");
    write_file(__NewRoom, "set_property: $light;#"+__Light+"\n");
    write_file(__NewRoom, "set_short: $"+__Short+"\n");
    write_file(__NewRoom, "set_long: $"+__Long+"\n");
    write_file(__NewRoom, "add_exit: "+__Exit+"\n");
    ESTATES_D->add_estate((string)this_player()->query_CapName(), __NewRoom,
      file_name(environment(this_player())), __EstateLong);
    seteuid(getuid());
    message("system", "Room begun.  You will see your addition "
      "appear later when the work is complete.", this_player());
    this_object()->remove();
}

static private string create_file() {
    string dir, str;
    int x;

    x = sizeof(get_dir((dir = ESTATES_DIRS+"/"+geteuid(this_player())+"/")));
    while(file_exists(str = dir+"room"+x)) x++;
    return str;
}

static int estates(object ob) {
    return (int)ob->id("estate");
}