dsI/bin/
dsI/extra/creremote/
dsI/extra/mingw/
dsI/extra/wolfpaw/
dsI/fluffos-2.7-ds2.018/
dsI/fluffos-2.7-ds2.018/ChangeLog.old/
dsI/fluffos-2.7-ds2.018/Win32/
dsI/fluffos-2.7-ds2.018/compat/
dsI/fluffos-2.7-ds2.018/compat/simuls/
dsI/fluffos-2.7-ds2.018/testsuite/
dsI/fluffos-2.7-ds2.018/testsuite/clone/
dsI/fluffos-2.7-ds2.018/testsuite/command/
dsI/fluffos-2.7-ds2.018/testsuite/data/
dsI/fluffos-2.7-ds2.018/testsuite/etc/
dsI/fluffos-2.7-ds2.018/testsuite/include/
dsI/fluffos-2.7-ds2.018/testsuite/inherit/
dsI/fluffos-2.7-ds2.018/testsuite/inherit/master/
dsI/fluffos-2.7-ds2.018/testsuite/log/
dsI/fluffos-2.7-ds2.018/testsuite/single/
dsI/fluffos-2.7-ds2.018/testsuite/single/tests/compiler/
dsI/fluffos-2.7-ds2.018/testsuite/single/tests/efuns/
dsI/fluffos-2.7-ds2.018/testsuite/single/tests/operators/
dsI/fluffos-2.7-ds2.018/testsuite/u/
dsI/fluffos-2.7-ds2.018/tmp/
dsI/lib/cfg/
dsI/lib/cmds/common/
dsI/lib/cmds/creators/include/
dsI/lib/cmds/creators/include/SCCS/
dsI/lib/daemon/services/
dsI/lib/doc/
dsI/lib/domains/Ylsrim/
dsI/lib/domains/Ylsrim/adm/
dsI/lib/domains/Ylsrim/armour/
dsI/lib/domains/Ylsrim/broken/
dsI/lib/domains/Ylsrim/fish/
dsI/lib/domains/Ylsrim/meal/
dsI/lib/domains/Ylsrim/npc/
dsI/lib/domains/Ylsrim/virtual/
dsI/lib/domains/Ylsrim/weapon/
dsI/lib/domains/default/creator/
dsI/lib/domains/default/etc/
dsI/lib/domains/default/room/
dsI/lib/lib/comp/
dsI/lib/lib/lvs/
dsI/lib/lib/user/
dsI/lib/lib/virtual/
dsI/lib/obj/
dsI/lib/obj/include/
dsI/lib/realms/
dsI/lib/save/kills/a/
dsI/lib/save/kills/b/
dsI/lib/save/kills/f/
dsI/lib/save/kills/m/
dsI/lib/save/kills/q/
dsI/lib/save/kills/r/
dsI/lib/secure/cfg/
dsI/lib/secure/cfg/classes/
dsI/lib/secure/cfg/races/SCCS/
dsI/lib/secure/cmds/creators/include/
dsI/lib/secure/cmds/players/
dsI/lib/secure/cmds/players/include/
dsI/lib/secure/daemon/include/
dsI/lib/secure/lib/
dsI/lib/secure/lib/include/
dsI/lib/secure/lib/net/
dsI/lib/secure/lib/net/include/
dsI/lib/secure/lib/std/
dsI/lib/secure/obj/
dsI/lib/secure/obj/include/
dsI/lib/secure/save/
dsI/lib/spells/
dsI/lib/verbs/admins/include/
dsI/lib/verbs/common/
dsI/lib/verbs/common/include/
dsI/lib/verbs/creators/
dsI/lib/verbs/creators/include/
dsI/lib/verbs/players/include/SCCS/
dsI/lib/verbs/rooms/
dsI/lib/verbs/rooms/include/
dsI/lib/www/
dsI/v22.2b14/
dsI/win32/
/*
 *  /domains/Praxis/room/vote_hall.c
 *  from the Dead Souls mudlib
 *  So that players can vote
 *  by Kalinash on 961026
 */

#include <lib.h>
#include <daemons.h>
#include <voting.h>

inherit LIB_ROOM;

mixed ReadList();

static void create() {
    ::create();
    SetTown("Ylsrim");
    SetClimate("indoors");
    SetProperties( ([ "no kill" : 1, "no attack" : 1, "no steal" : 1,
      "no magic" : 1, "light" : 3, "no bump" : 1, "no teleport" : 1 ]) );
    SetShort("voting hall");
    SetLong("You are in the voting hall of Dead Souls.  This is where "
      "people come to nominate candidates for class leader and to "
      "cast their vote.  There is a list posted on the wall here.");
    SetItems( ([ "list" : "This is the list of candidates." ]) );
    SetRead( "list", (: ReadList :) );
    SetObviousExits("d");
    SetExits( ([ "down" : "/domains/Ylsrim/room/bazaar" ]) );
}

mixed ReadList() {
    string msg;

    if( VOTING_D->GetStatus() == VOTE_NOT_RUNNING ) {
        this_player()->eventPrint("Since the elections are not "
          "currently running, the list is blank.");
        return 1;
    }

    msg = "\tCandidates for Dead Souls Offices\n\n";
    
    foreach( string sClass in CLASSES_D->GetClasses() ) {
        msg += capitalize( sClass ) + " : ";
        foreach( string sName in VOTING_D->GetCandidates(sClass) )
            msg += capitalize(sName) + ", ";
        if( msg[strlen(msg)-2] == ',' )        
            msg = msg[0..strlen(msg)-3];
        msg += "\n";
    }
    
    this_player()->eventPrint( msg );
    return 1;
}

mixed CanNominate( object who ) { return 1; }
mixed CanVote( object who ) { return 1; }
mixed CanWithdraw( object who ) { return 1; }

mixed eventNominate( object who, string str ) {
    int iErr;

    if( creatorp( who ) ) {
        who->eventPrint("Creators cannot vote!");
        return 1;
    }

    iErr = VOTING_D->eventAddCandidate( who->GetClass(), str );

    switch( iErr ) {
        case VOTE_NOT_RUNNING :
            this_player()->eventPrint("The elections are not running now!");
            break;

        case VOTE_MODE_VOTING :
            this_player()->eventPrint("The time for nominating "
              "candidates is past, cast your vote instead.");
            break;

        case VOTE_ERROR :
            this_player()->eventPrint("There was an error, you cannot "
              "nominate someone at this time.");
            break;

        case VOTE_NOT_CLASS_MEMBER :
            this_player()->eventPrint( capitalize(str) + " is not a member
of "
            "the " + pluralize( who->GetClass() ) + ".");
            break;

        case VOTE_ALREADY_RUNNING :
            this_player()->eventPrint( capitalize(str) + " is already
running." );
            break;
    }
    return 1;
}

mixed eventVote( object who, string str ) {
    int    iErr;
    string sClass;

    sClass = who->GetClass();
    iErr = VOTING_D->eventCastVote( sClass, who->GetName(), str );

    switch( iErr ) {
        case VOTE_NOT_RUNNING :
            this_player()->eventPrint("The elections are not running
now!");
            break;

        case VOTE_MODE_CANDIDATES :
            this_player()->eventPrint("Voting has not yet started, "
              "nominate a candidate instead.");
            break;

        case VOTE_NOT_PRIMARY :
            this_player()->eventPrint("Only your primary character can
vote.");
            break;

        case VOTE_NOT_CLASS_MEMBER :
            this_player()->eventPrint( str + " is not a candidate for "
              "the " + pluralize(who->GetClass()) + ".");
            break;

        case VOTE_ALREADY_VOTED :
            this_player()->eventPrint("You have already cast your vote!");
            break;

        case VOTE_SUCCESS :
            this_player()->eventPrint("You cast your vote!");
            break;        
    }

    return 1;
}

mixed eventWithdraw( object who ) {
    int iErr;

    iErr = VOTING_D->eventRemoveCandidate( who->GetClass(), who->GetName()
);

    switch( iErr ) {
        case VOTE_NOT_RUNNING :
            this_player()->eventPrint("The elections are not running
now!");
            break;

        case VOTE_MODE_VOTING :
            this_player()->eventPrint("The elections have begun, it is "
              "too late to withdraw.");
            break;

        case VOTE_NOT_CANDIDATE :
            this_player()->eventPrint("You are not a candidate.");
            break;
    }

    return 1;
}
void init(){
::init();
}