ds2.9a12/bin/
ds2.9a12/extra/
ds2.9a12/extra/crat/
ds2.9a12/extra/creremote/
ds2.9a12/extra/mingw/
ds2.9a12/extra/wolfpaw/
ds2.9a12/fluffos-2.14-ds13/
ds2.9a12/fluffos-2.14-ds13/Win32/
ds2.9a12/fluffos-2.14-ds13/compat/
ds2.9a12/fluffos-2.14-ds13/compat/simuls/
ds2.9a12/fluffos-2.14-ds13/include/
ds2.9a12/fluffos-2.14-ds13/testsuite/
ds2.9a12/fluffos-2.14-ds13/testsuite/clone/
ds2.9a12/fluffos-2.14-ds13/testsuite/command/
ds2.9a12/fluffos-2.14-ds13/testsuite/data/
ds2.9a12/fluffos-2.14-ds13/testsuite/etc/
ds2.9a12/fluffos-2.14-ds13/testsuite/include/
ds2.9a12/fluffos-2.14-ds13/testsuite/inherit/
ds2.9a12/fluffos-2.14-ds13/testsuite/inherit/master/
ds2.9a12/fluffos-2.14-ds13/testsuite/log/
ds2.9a12/fluffos-2.14-ds13/testsuite/single/
ds2.9a12/fluffos-2.14-ds13/testsuite/single/tests/compiler/
ds2.9a12/fluffos-2.14-ds13/testsuite/single/tests/efuns/
ds2.9a12/fluffos-2.14-ds13/testsuite/single/tests/operators/
ds2.9a12/fluffos-2.14-ds13/testsuite/u/
ds2.9a12/lib/cmds/admins/
ds2.9a12/lib/cmds/common/
ds2.9a12/lib/cmds/creators/include/
ds2.9a12/lib/daemon/services/
ds2.9a12/lib/daemon/tmp/
ds2.9a12/lib/doc/
ds2.9a12/lib/doc/bguide/
ds2.9a12/lib/doc/efun/all/
ds2.9a12/lib/doc/efun/arrays/
ds2.9a12/lib/doc/efun/buffers/
ds2.9a12/lib/doc/efun/compile/
ds2.9a12/lib/doc/efun/floats/
ds2.9a12/lib/doc/efun/functions/
ds2.9a12/lib/doc/efun/general/
ds2.9a12/lib/doc/efun/mixed/
ds2.9a12/lib/doc/efun/numbers/
ds2.9a12/lib/doc/efun/parsing/
ds2.9a12/lib/doc/hbook/
ds2.9a12/lib/doc/help/classes/
ds2.9a12/lib/doc/help/races/
ds2.9a12/lib/doc/lfun/
ds2.9a12/lib/doc/lfun/all/
ds2.9a12/lib/doc/lfun/lib/abilities/
ds2.9a12/lib/doc/lfun/lib/armor/
ds2.9a12/lib/doc/lfun/lib/bank/
ds2.9a12/lib/doc/lfun/lib/bot/
ds2.9a12/lib/doc/lfun/lib/clay/
ds2.9a12/lib/doc/lfun/lib/clean/
ds2.9a12/lib/doc/lfun/lib/clerk/
ds2.9a12/lib/doc/lfun/lib/client/
ds2.9a12/lib/doc/lfun/lib/combat/
ds2.9a12/lib/doc/lfun/lib/connect/
ds2.9a12/lib/doc/lfun/lib/container/
ds2.9a12/lib/doc/lfun/lib/corpse/
ds2.9a12/lib/doc/lfun/lib/creator/
ds2.9a12/lib/doc/lfun/lib/daemon/
ds2.9a12/lib/doc/lfun/lib/damage/
ds2.9a12/lib/doc/lfun/lib/deterioration/
ds2.9a12/lib/doc/lfun/lib/donate/
ds2.9a12/lib/doc/lfun/lib/door/
ds2.9a12/lib/doc/lfun/lib/equip/
ds2.9a12/lib/doc/lfun/lib/file/
ds2.9a12/lib/doc/lfun/lib/fish/
ds2.9a12/lib/doc/lfun/lib/fishing/
ds2.9a12/lib/doc/lfun/lib/flashlight/
ds2.9a12/lib/doc/lfun/lib/follow/
ds2.9a12/lib/doc/lfun/lib/ftp_client/
ds2.9a12/lib/doc/lfun/lib/ftp_data_connection/
ds2.9a12/lib/doc/lfun/lib/fuel/
ds2.9a12/lib/doc/lfun/lib/furnace/
ds2.9a12/lib/doc/lfun/lib/genetics/
ds2.9a12/lib/doc/lfun/lib/holder/
ds2.9a12/lib/doc/lfun/lib/id/
ds2.9a12/lib/doc/lfun/lib/interactive/
ds2.9a12/lib/doc/lfun/lib/lamp/
ds2.9a12/lib/doc/lfun/lib/leader/
ds2.9a12/lib/doc/lfun/lib/light/
ds2.9a12/lib/doc/lfun/lib/limb/
ds2.9a12/lib/doc/lfun/lib/living/
ds2.9a12/lib/doc/lfun/lib/load/
ds2.9a12/lib/doc/lfun/lib/look/
ds2.9a12/lib/doc/lfun/lib/manipulate/
ds2.9a12/lib/doc/lfun/lib/meal/
ds2.9a12/lib/doc/lfun/lib/messages/
ds2.9a12/lib/doc/lfun/lib/player/
ds2.9a12/lib/doc/lfun/lib/poison/
ds2.9a12/lib/doc/lfun/lib/position/
ds2.9a12/lib/doc/lfun/lib/post_office/
ds2.9a12/lib/doc/lfun/lib/potion/
ds2.9a12/lib/doc/lfun/lib/room/
ds2.9a12/lib/doc/lfun/lib/server/
ds2.9a12/lib/doc/lfun/lib/spell/
ds2.9a12/lib/doc/lfun/lib/torch/
ds2.9a12/lib/doc/lfun/lib/vendor/
ds2.9a12/lib/doc/lfun/lib/virt_sky/
ds2.9a12/lib/doc/lfun/lib/weapon/
ds2.9a12/lib/doc/lfun/lib/worn_storage/
ds2.9a12/lib/doc/lpc/basic/
ds2.9a12/lib/doc/lpc/concepts/
ds2.9a12/lib/doc/lpc/constructs/
ds2.9a12/lib/doc/lpc/etc/
ds2.9a12/lib/doc/lpc/intermediate/
ds2.9a12/lib/doc/lpc/types/
ds2.9a12/lib/doc/misc/
ds2.9a12/lib/doc/old/
ds2.9a12/lib/domains/
ds2.9a12/lib/domains/Praxis/adm/
ds2.9a12/lib/domains/Praxis/attic/
ds2.9a12/lib/domains/Praxis/cemetery/mon/
ds2.9a12/lib/domains/Praxis/data/
ds2.9a12/lib/domains/Praxis/death/
ds2.9a12/lib/domains/Praxis/mountains/
ds2.9a12/lib/domains/Praxis/obj/armour/
ds2.9a12/lib/domains/Praxis/obj/magic/
ds2.9a12/lib/domains/Praxis/obj/weapon/
ds2.9a12/lib/domains/Praxis/orc_valley/
ds2.9a12/lib/domains/Ylsrim/
ds2.9a12/lib/domains/Ylsrim/adm/
ds2.9a12/lib/domains/Ylsrim/armor/
ds2.9a12/lib/domains/Ylsrim/broken/
ds2.9a12/lib/domains/Ylsrim/fish/
ds2.9a12/lib/domains/Ylsrim/meal/
ds2.9a12/lib/domains/Ylsrim/npc/
ds2.9a12/lib/domains/Ylsrim/obj/
ds2.9a12/lib/domains/Ylsrim/virtual/
ds2.9a12/lib/domains/Ylsrim/weapon/
ds2.9a12/lib/domains/campus/adm/
ds2.9a12/lib/domains/campus/etc/
ds2.9a12/lib/domains/campus/meals/
ds2.9a12/lib/domains/campus/save/
ds2.9a12/lib/domains/campus/txt/ai/charles/
ds2.9a12/lib/domains/campus/txt/ai/charles/bak2/
ds2.9a12/lib/domains/campus/txt/ai/charles/bak2/bak1/
ds2.9a12/lib/domains/campus/txt/ai/charly/
ds2.9a12/lib/domains/campus/txt/ai/charly/bak/
ds2.9a12/lib/domains/campus/txt/jenny/
ds2.9a12/lib/domains/cave/doors/
ds2.9a12/lib/domains/cave/etc/
ds2.9a12/lib/domains/cave/meals/
ds2.9a12/lib/domains/cave/weap/
ds2.9a12/lib/domains/default/creator/
ds2.9a12/lib/domains/default/doors/
ds2.9a12/lib/domains/default/etc/
ds2.9a12/lib/domains/default/vehicles/
ds2.9a12/lib/domains/default/virtual/
ds2.9a12/lib/domains/default/weap/
ds2.9a12/lib/domains/town/txt/shame/
ds2.9a12/lib/domains/town/virtual/
ds2.9a12/lib/domains/town/virtual/bottom/
ds2.9a12/lib/domains/town/virtual/space/
ds2.9a12/lib/estates/
ds2.9a12/lib/ftp/
ds2.9a12/lib/lib/comp/
ds2.9a12/lib/lib/daemons/
ds2.9a12/lib/lib/daemons/include/
ds2.9a12/lib/lib/lvs/
ds2.9a12/lib/lib/user/
ds2.9a12/lib/lib/virtual/
ds2.9a12/lib/log/
ds2.9a12/lib/log/adm/
ds2.9a12/lib/log/archive/
ds2.9a12/lib/log/chan/
ds2.9a12/lib/log/errors/
ds2.9a12/lib/log/law/adm/
ds2.9a12/lib/log/law/email/
ds2.9a12/lib/log/law/names/
ds2.9a12/lib/log/law/sites-misc/
ds2.9a12/lib/log/law/sites-register/
ds2.9a12/lib/log/law/sites-tempban/
ds2.9a12/lib/log/law/sites-watch/
ds2.9a12/lib/log/open/
ds2.9a12/lib/log/reports/
ds2.9a12/lib/log/router/
ds2.9a12/lib/log/secure/
ds2.9a12/lib/log/watch/
ds2.9a12/lib/obj/book_source/
ds2.9a12/lib/obj/include/
ds2.9a12/lib/powers/prayers/
ds2.9a12/lib/powers/spells/
ds2.9a12/lib/realms/template/adm/
ds2.9a12/lib/realms/template/area/armor/
ds2.9a12/lib/realms/template/area/npc/
ds2.9a12/lib/realms/template/area/obj/
ds2.9a12/lib/realms/template/area/room/
ds2.9a12/lib/realms/template/area/weap/
ds2.9a12/lib/realms/template/bak/
ds2.9a12/lib/realms/template/cmds/
ds2.9a12/lib/save/kills/o/
ds2.9a12/lib/secure/cfg/classes/
ds2.9a12/lib/secure/cmds/builders/
ds2.9a12/lib/secure/cmds/creators/include/
ds2.9a12/lib/secure/cmds/players/
ds2.9a12/lib/secure/cmds/players/include/
ds2.9a12/lib/secure/daemon/imc2server/
ds2.9a12/lib/secure/daemon/include/
ds2.9a12/lib/secure/lib/
ds2.9a12/lib/secure/lib/include/
ds2.9a12/lib/secure/lib/net/include/
ds2.9a12/lib/secure/lib/std/
ds2.9a12/lib/secure/log/adm/
ds2.9a12/lib/secure/log/bak/
ds2.9a12/lib/secure/log/intermud/
ds2.9a12/lib/secure/log/network/
ds2.9a12/lib/secure/modules/
ds2.9a12/lib/secure/npc/
ds2.9a12/lib/secure/obj/include/
ds2.9a12/lib/secure/room/
ds2.9a12/lib/secure/save/
ds2.9a12/lib/secure/save/backup/
ds2.9a12/lib/secure/save/boards/
ds2.9a12/lib/secure/tmp/
ds2.9a12/lib/secure/upgrades/files/
ds2.9a12/lib/secure/verbs/creators/
ds2.9a12/lib/std/board/
ds2.9a12/lib/std/lib/
ds2.9a12/lib/tmp/
ds2.9a12/lib/verbs/admins/include/
ds2.9a12/lib/verbs/builders/
ds2.9a12/lib/verbs/common/
ds2.9a12/lib/verbs/common/include/
ds2.9a12/lib/verbs/creators/
ds2.9a12/lib/verbs/creators/include/
ds2.9a12/lib/verbs/rooms/
ds2.9a12/lib/verbs/rooms/include/
ds2.9a12/lib/www/client/
ds2.9a12/lib/www/errors/
ds2.9a12/lib/www/images/
ds2.9a12/lib/www/lpmuds/downloads_files/
ds2.9a12/lib/www/lpmuds/intermud_files/
ds2.9a12/lib/www/lpmuds/links_files/
ds2.9a12/win32/
/*
// File     :  /domains/Praxis/council.c
// Comment  :  Town Council Chambers
// 94-07-02 :  Pallando @ Nightmare wrote it
// 94-07-06 :  Manny @ Nightmare added descriptions
// 94-08-18 :  Forlock @ Nightmare added descriptions of plaque & law book
*/
#include <lib.h>
#include <dirs.h>
#include <objects.h>
#include <daemons.h>

#define TOWN_HALL "/domains/Praxis/town_hall"
#define HELP_FILE "/domains/Praxis/commands"
#define TMP_FILE DIR_TMP + "/" + (this_player()->query_name()) + ".proposal"
#define QUORUM 5
#define PASSES 5

inherit LIB_ROOM;

mapping policies = ([]);

void create()
{
    ::create();
    enable_commands(); // Used to echo tells to the Town Hall
    SetProperties( ([
        "mountable" : 1,
        "indoors" : 1,
        "light" : 2,
        "no castle" : 1,
        "no teleport" : 1,
        "no bump" : 1,
        "no attack" : 1,
        "no steal" : 1,
        "no magic" : 1,
      ]) );
    SetShort( "The Chambers of the High Council" );
    SetLong(
      "The lights are darkened in this room, a set of 12 candles set along a "
      "long, narrow table are the only light.  The table is constructed of the "
      "purest black obsidian, and is surrounded at all sides by wooden chairs, "
      "each covered in a bright pattern of rubies.  On the walls of the room hang "
      "the flags of each of the classes of Nightmare, each created by the best "
      "artists in the land.  The ceiling is covered in 4 ornate patterns, each "
      "a picture of one of the Head Archwizards of the land.  The pictures give "
      "the appearance of watching all that occurs within this chamber.  "
      "Sitting on a pedestal made completely of platinum is the Book of Law.  "
      "A plaque is attached to the west wall. "
    );
    SetExits( ([
        "down"  : "/domains/Praxis/town_hall",
      ]) );
    SetItems( ([
        "view" : "A magnificent panorama of all Praxis.",
        ({ "candles", "candle" }) : "Tall, thin white candles on a "+
        "long, narrow table.",
        "table" : "A brightly polished table of deep black obsidian",
        "obsidian" : "The obsidian is of the purest in the land.",
        ({ "chair", "chairs" }) : "Each of the chairs have a unique pattern of "+
        "rubies engrained within the body of the chair.",
        "rubies" : "Large rubies of the rarest kind.",
        "flags" : "6 flags, each representing the individual classes "
        "of the land.",
        "ceiling" : "A vast mural of the Four greatest in "
        "all the land, Forlock, Descartes, Lassondra, "
        "and Shadowwolf.",
        "plaque" : "A discreet piece of granite with finly etched words.",
        "book"   : "The Book of Law.  Its cover is made of pure solid gold "
        "and the pages of the finest leather.  Inside, one can find "
        "details of the Laws of the Land.",
        "forlock" : "The Great Enforcer, donning a great black robe "
        "lined with a deep red sheath.  The deep stare of "
        "Forlock fills you with all that is good and just.",
        "descartes" : "Descartes of Borg, in his most noble position "
        "upon a great white horse, is the embodiment of "
        "great wisdom and knowlege.",
        "lassondra" : "Long, black wavy hair drape down upon a "
        "great green cloak upon her broad sholders.  "
        "The warm smile and loving eyes depict equality "
        "and fairness for all.",
        "shadowwolf" : "Donning a long hooded robe, Shadowwolf is "
        "perhaps the most mysterious of the four.  "
        "Shadowwolf's eyes faintly pierce the darkness "
        "that surrounds him, seemingly staring "
        "directly at you."
      ]) );
}

void init()
{
    ::init();
    add_action( "cmd_propose", "propose" );
    add_action( "cmd_repeal", "repeal" );
    add_action( "cmd_cast", "cast" );
    add_action( "cmd_read", "read" );
    add_action( "cmd_law", "law" );
}

int quorum()
{
    object *voters;

    voters = all_inventory( this_object() );
    voters = filter_array( voters, "leaderp", find_object( OB_SIMUL_EFUN ) );
    return sizeof( voters );
}

int votes_needed( string title )
{
    return PASSES + sizeof( policies[title]["Nay"] ) -
    sizeof( policies[title]["Aye"] );
}

int vetos_needed( string title )
{
    return PASSES + sizeof( policies[title]["Aye"] ) -
    sizeof( policies[title]["Nay"] );
}

varargs void display_policy( mapping policy, int as_law )
{
    int then;

    if( as_law )
    {
        then = policy["Time"];
        printf( "As of %s, %d %s, %d NM;  at the urging of %s\n\n\t\t\%s\n\n%s",
          day( then ), date( then ), month( then ), year( then ),
          capitalize( policy["Proposer"] ), policy["Title"], policy["Text"] );
        return;
    }
    printf(
      "Title: %s\nProposer: %s\n\n%s",
      policy["Title"],
      capitalize( policy["Proposer"] ),
      policy["Text"],
    );
    if( sizeof( policy["Aye"] ) )
        write( wrap( "In favour: " + implode( policy["Aye"], ", " ) ) );
    if( sizeof( policy["Nay"] ) )
        write( wrap( "Against: " + implode( policy["Nay"], ", " ) ) );
    if( sizeof( policy["Abs"] ) )
        write( wrap( "Abstentions: " + implode( policy["Abs"], ", " ) ) );
}

int cmd_law( string arg )
{
    mapping policy;

    if( arg )
    {
        if( undefinedp( policy = (mapping)POLITICS_D-> query_policy( arg ) ) )
            write( "There is no law: " + arg + "\n" );
        else
            display_policy( policy, 1 );
    } else {
        printf( "The book of law contains the following:\n  %s\n",
          wrap( implode( sort_array( keys(
                  POLITICS_D-> query_policies() ), 1 ), "\n  " ) ) );
    }
    return 1;
}

int cmd_read( string arg )
{
    mapping policy;

    if( arg )
    {
        if( arg == "book" || arg == "law" )
            write( "Use the \"law\" command.\n" );
        else if( arg == "plaque" )
            write( read_file( HELP_FILE ) );
        else if( undefinedp( policy = policies[arg] ) )
            write( "There is no proposal: " + arg + "\n" );
        else
            display_policy( policy );
    } else {
        if( !sizeof( policies ) )
            write( "There are no proposals waiting to be passed.\n" );
        else
            write( "The following proposals are waiting to be passed:\n" +
              wrap( implode( keys( policies ), ", " ) ) );
    }
    return 1;
}

int cmd_propose( string title )
{
    if( !title ) return notify_fail( "Syntax: propose <title>\n" );
    title = lower_case( title );
    if( policies[title] || POLITICS_D-> query_policy( title ) )
        return notify_fail( "That already exists.\n" );
    if( ( quorum() < QUORUM ) && !archp( this_player() ) )
        return notify_fail( "There are not " + QUORUM + " voters present.\n" );
    write( "Enter your proposal:\n" );
    this_player()-> edit( TMP_FILE,
      (: "callback_propose" :),
      (: "abort_propose" :),
      title,
    );
    return 1;
}

void abort_propose( string title ) { write( "Aborting proposal.\n" ); }

void callback_propose( string title )
{
    string proposal;

    proposal = read_file( TMP_FILE );
    rm( TMP_FILE );
    if( !proposal )
    {
        write( "Aborting proposal.\n" );
        return;
    }

    policies[title] = ([
      "Title" : title,
      "Proposer" : this_player()-> query_name(),
      "Time" : time(),
      "Text" : proposal,
      "Voted" : ([]),
      "Aye" : ({}),
      "Nay" : ({}),
      "Abs" : ({}),
    ]);
    display_policy( policies[title] );
    write( "You have 1/2 hr to get " + votes_needed( title ) + "\n" );
    call_out( "last_warning", 1500, title );
}

void last_warning( string title )
{
    object proposer;

    if( !policies[title] ) return;
    call_out( "delete_proposal", 300, title );
    if( !proposer = find_player( policies[title]["Proposer"] ) ) return;
    tell_object( proposer,
      "***** LAST WARNING *****\n"+
      "Proposal " + title + " will be deleted in 5 minutes\nunless "+
      "you can find " + votes_needed( title ) + " votes before then.\n" );
}

void delete_proposal( string title )
{
    map_delete( policies, title );
}

int cmd_repeal( string title )
{
    mapping policy;

    if( !title ) return notify_fail( "Syntax: repeal <title>\n" );
    title = lower_case( title );
    if( !policy = POLITICS_D-> query_policy( title ) )
        return notify_fail( "There is no law: " + title + ".\n" );
    if( ( quorum() < QUORUM ) && !archp( this_player() ) )
        return notify_fail( "There are not " + QUORUM + " voters present.\n" );
    policy["Proposer"] = this_player()-> query_name();
    policy["Repeal"] = 1;
    policies[title] = policy;
    call_out( "delete_proposal", 1800, title );
    write( "You have 1/2 hour to get the votes needed to repeal " +
      title + ".\n" );
    return 1;
}

int cmd_cast( string arg )
{
    string vote, title, name;

    if( !arg ||
      ( ( 2 != sscanf( arg, "%s on %s", vote, title ) ) &&
        ( 2 != sscanf( arg, "%s %s", vote, title ) )      ) )
        return notify_fail( "Syntax: cast <vote> on <title>\n" );
    if( !policies[title] )
        return notify_fail( "There is no proposal: " + title + ".\n" );
    name = this_player()-> query_name();
    if( policies[title]["Voted"][name] )
        policies[title][policies[title]["Voted"][name]] -= ({ name });
    vote = lower_case( vote[0..2] );
    switch( vote )
    {
    case "aye":
        policies[title]["Aye"] += ({ name }); break;
    case "nay":
        policies[title]["Nay"] += ({ name }); break;
    case "abs":
        policies[title]["Abs"] += ({ name }); break;
    default:
        return notify_fail( "You vote must be 'aye', 'nay' or 'abs'.\n" );
    }
    policies[title]["Voted"][name] = capitalize( vote );
    if( policies[title]["Repeal"] )
    {
        if( vetos_needed( title ) < 1 )
        {
            say( title + " is no longer law.\n" );
            POLITICS_D-> repeal_policy( title );
            delete_proposal( title );
            return 1;
        }
    }
    else if( votes_needed( title ) < 1 )
    {
        say( "Proposal: " + title + " is writ large in the book of law.\n" );
        POLITICS_D-> set_policy( title, policies[title] );
        delete_proposal( title );
        return 1;
    }
    write( "Ok.\n" );
    return 1;
}

void receive_message( string msg_class, string msg )
{
    /*
    write( "class = " + msg_class + "\n" );
    */
    message( msg_class, msg, all_inventory( this_object() ), ({ this_player() }) );
    TOWN_HALL-> receive_message( msg_class, msg );
}

// Wizard test functions

mixed query_policies() { return policies; }

void alter_proposal( string title, string field, mixed value )
{
    policies[title][field] = value;
}

void make_law( string title )
{
    POLITICS_D-> set_policy( title, policies[title] );
    delete_proposal( title );
}

void repeal_law( string title )
{
    POLITICS_D-> repeal_policy( title );
    delete_proposal( title );
}

/* EOF */