[an error occurred while processing this directive]
[<a href="index.shtml">Package Index</a></code> | <a href="index_std.shtml">Mudlib Index</a></code> | <a href="index_eff.shtml">Effect Index</a></code>]<br><h2>File /std/room/inherit/voting_room.c</h2>
Generalised voting room intended to be inherited into rooms in the mud that
will setup the parameters and settings for votes.
<p>
The room does not inherantly support player initiated votes, however it is
a fairly simple matter to add this to your own room and have your room add
votes when players initiate them.
<p>Written by Ceres
<h2>Includes</h2>
This class includes the following files <a href="include.board.h.shtml">/include/board.h</a><h2>Class Index</h2>
<ul><li><a href="#class_election">election</a>
<br/>
 This class stores the essential information about an election during the
 setup phase.
<li><a href="#class_vote">vote</a>
<br/>
 This class stores the essential information about a vote.
</ul><h2>Method index</h2>
<dl><ul>
<li><a href="#add_our_election">add_our_election</a>(string, class election)<br/>
This method adds in a election.
<li><a href="#add_our_vote">add_our_vote</a>(int, class vote)<br/>
This method adds in a vote.
<li><a href="#add_vote">add_vote</a>(string, string, string *, int)<br/>
This function is called to add a vote to the system.
<li><a href="#cast_vote">cast_vote</a>(string, int)<br/>
This function is called when a player votes.
<li><a href="#delete_election">delete_election</a>(string)<br/>
This is an administrative function to allow the removal/cancellation
of an election.
<li><a href="#delete_vote">delete_vote</a>(int)<br/>
This is an administrative function to allow the removal/cancellation
of a vote.
<li><a href="#do_create_vote">do_create_vote</a>(string)<br/>
This is an option function which can be defined in upper level inherits.
<li><a href="#end_vote">end_vote</a>(int)<br/>
This function is called to terminate a vote.
<li><a href="#init_add_vote">init_add_vote</a>()<br/>
This is the init() which should be called as well as the default
init() if you wish to have player added votes.
<li><a href="#initiate_election">initiate_election</a>(string)<br/>
This function is used to initiate an election.
<li><a href="#list_elections">list_elections</a>()<br/>
This function is called when a player types 'elections'.
<li><a href="#list_votes">list_votes</a>()<br/>
This function is called when a player types 'list'.
<li><a href="#make_announcement">make_announcement</a>(string, string, string, string)<br/>
This function is provided for convenience to make it easy for your vote
end function to post to a board.
<li><a href="#query_election_in_progress">query_election_in_progress</a>(string)<br/>
This method determines if there is already an election of the
specified type in progress.
<li><a href="#query_open_voting">query_open_voting</a>(int)<br/>
This function queries if the votes should be open or not.
<li><a href="#query_our_elections">query_our_elections</a>()<br/>
This method is used to return the current elections.
<li><a href="#query_our_votes">query_our_votes</a>()<br/>
This method is used to return the current votes.
<li><a href="#query_save_file">query_save_file</a>()<br/>
This method returns the save file currently used for the room.
<li><a href="#query_vote_duration">query_vote_duration</a>()<br/>
This function is used to returns the normal vote and election duration.
<li><a href="#save_room">save_room</a>()<br/>
Private function to save the rooms data file.
<li><a href="#second_candidate">second_candidate</a>(string, string)<br/>
This function is used by players to second candidates for election.
<li><a href="#set_completion_action">set_completion_action</a>(mixed)<br/>
This function defines a function to be called when the vote is complete.
<li><a href="#set_election_announcement">set_election_announcement</a>(string, string, string, string, string)<br/>
This function defines the board, person and subject for announcements
of elections.
<li><a href="#set_no_elections">set_no_elections</a>(int)<br/>
This method sets the room to not allow elections and disable all the
election commands.
<li><a href="#set_open_voting">set_open_voting</a>(int)<br/>
This function setups if the votes should be open or not.
<li><a href="#set_proxy">set_proxy</a>(string)<br/>
This method sets up a proxy for the room.
<li><a href="#set_save_file">set_save_file</a>(string)<br/>
This method is called by the inheriting object to determine which save file
to use for votes.
<li><a href="#set_second_conditions">set_second_conditions</a>(mixed)<br/>
This function defines a function to be called to determine if a player
is eligible to second a canditate for election.
<li><a href="#set_stand_conditions">set_stand_conditions</a>(mixed)<br/>
This function defines a function to be called to determine if a player
is eligible to stand for election to a position.
<li><a href="#set_vote_conditions">set_vote_conditions</a>(mixed)<br/>
This function defines a function to be called to determine if a player
is eligible to vote.
<li><a href="#set_vote_duration">set_vote_duration</a>(int)<br/>
This function is used to set the normal vote and election duration.
<li><a href="#setup_after_load">setup_after_load</a>()<br/>
This setups all the stuff that  needs to be setup after the room has
been loaded.
<li><a href="#stand_for_election">stand_for_election</a>(string)<br/>
This function is used by players to stand for election.
<li><a href="#start_election_vote">start_election_vote</a>(string)<br/>
Once the candidacy phase is over this function starts the election vote
itself by taking all eligible candidates, setting them as choices in the
election and then posting an announcemment.
</ul><h2>Public Functions</h2>
These are functions that everyone can access.<p>
.<ul><a name="add_vote">
add_vote</a><pre>
void add_vote(string type,
              string description,
              string * choices,
              int ending)
</pre></br>
This function is called to add a vote to the system.

<br/><ul>
<li><b>Parameters:</b>
<br/>type - Freeform string giving the type of vote. This is typically used
by your completion function so that it can perform different actions for
different types of votes.

<br/>description - The description of the vote as shown to the player.

<br/>choices - An array of vote options eg. ({"Yes", "No" })

<br/>ending - An integer time of when the vote should be terminated.

<li><b>See also:</b>
<br/><a href="#set_completion_action">set_completion_action()
</a></dl>

<ul><a name="cast_vote">
cast_vote</a><pre>
int cast_vote(string which_str,
              int vote_id)
</pre></br>
This function is called when a player votes. The syntax is
"vote <choice> on <vote>".

<br/><ul>
<li><b>See also:</b>
<br/><a href="#set_vote_conditions">set_vote_conditions()
</a></dl>

<ul><a name="delete_election">
delete_election</a><pre>
int delete_election(string election)
</pre></br>
This is an administrative function to allow the removal/cancellation
of an election.
<br/><ul>
<li><b>Parameters:</b>
<br/>election - The name of the election to be cancelled
<li><b>Returns:</b>
<br/>Returns 1 for success, 0 for failure.

</dl>

<ul><a name="delete_vote">
delete_vote</a><pre>
int delete_vote(int vote_id)
</pre></br>
This is an administrative function to allow the removal/cancellation
of a vote.
<br/><ul>
<li><b>Parameters:</b>
<br/>vote_id - The id number of the vote to be cancelled.
<li><b>Returns:</b>
<br/>Returns 1 for success, 0 for failure.

</dl>

<ul><a name="do_create_vote">
do_create_vote</a><pre>
int do_create_vote(string choices)
</pre></br>
This is an option function which can be defined in upper level inherits.
It allows the players to create their own votes with their own choices.


<ul><a name="end_vote">
end_vote</a><pre>
void end_vote(int which)
</pre></br>
This function is called to terminate a vote. It calls your completion
action.

<br/><ul>
<li><b>See also:</b>
<br/><a href="#set_completion_action">set_completion_action()
</a></dl>

<ul><a name="init_add_vote">
init_add_vote</a><pre>
void init_add_vote()
</pre></br>
This is the init() which should be called as well as the default
init() if you wish to have player added votes.


<ul><a name="initiate_election">
initiate_election</a><pre>
void initiate_election(string position)
</pre></br>
This function is used to initiate an election.
It sets up the election class and adds it to the mapping.

<br/><ul>
<li><b>Parameters:</b>
<br/>position - The name of the position the election is for.

</dl>

<ul><a name="list_elections">
list_elections</a><pre>
int list_elections()
</pre></br>
This function is called when a player types 'elections'. It lists the
elections currently accepting candidates.


<ul><a name="list_votes">
list_votes</a><pre>
int list_votes()
</pre></br>
This function is called when a player types 'list'. It lists the currently
open votes.


<ul><a name="make_announcement">
make_announcement</a><pre>
void make_announcement(string board,
                       string name,
                       string subject,
                       string message)
</pre></br>
This function is provided for convenience to make it easy for your vote
end function to post to a board.

<br/><ul>
<li><b>Parameters:</b>
<br/>board - The name of the board to post to.
<br/>name - The name of the person to post as.
<br/>subject - The subject line to use.
<br/>message - The message to post.

</dl>

<ul><a name="query_election_in_progress">
query_election_in_progress</a><pre>
int query_election_in_progress(string position)
</pre></br>
This method determines if there is already an election of the
specified type in progress.
<br/><ul>
<li><b>Parameters:</b>
<br/>position - the name of the election in progress
<li><b>Returns:</b>
<br/>1 if there is an election in progress

</dl>

<ul><a name="query_open_voting">
query_open_voting</a><pre>
int query_open_voting(int open)
</pre></br>
This function queries if the votes should be open or not.  If a vote is
open then you know who voted for each thing.
<br/><ul>
<li><b>Returns:</b>
<br/>1 for an open system 0 for closed

</dl>

<ul><a name="query_save_file">
query_save_file</a><pre>
string query_save_file()
</pre></br>
This method returns the save file currently used for the room.
<br/><ul>
<li><b>Returns:</b>
<br/>the current save file

</dl>

<ul><a name="query_vote_duration">
query_vote_duration</a><pre>
int query_vote_duration()
</pre></br>
This function is used to returns the normal vote and election duration.
If it is not set and no duration is
given in add_vote then the default value of DEFAULT_VOTE_DURATION is used.

<br/><ul>
<li><b>Parameters:</b>
<br/>duraction - The number of seconds the vote should be open.

<li><b>See also:</b>
<br/><a href="#add_vote">add_vote()
</a></dl>

<ul><a name="second_candidate">
second_candidate</a><pre>
int second_candidate(string who,
                     string position)
</pre></br>
This function is used by players to second candidates for election. If a
candidates isn't seconded he/she won't be in the election. The syntax is:
"second <player> for <position>".

<br/><ul>
<li><b>See also:</b>
<br/><a href="#set_second_conditions">set_second_conditions()
</a></dl>

<ul><a name="set_completion_action">
set_completion_action</a><pre>
void set_completion_action(mixed cond)
</pre></br>
This function defines a function to be called when the vote is complete.
Typically your function will post the vote results somewhere or somesuch.
The parameters passedinto the function are:<br>
( string type, string description, string* choices, mapping votes, string* voted) <br>

<br/><ul>
<li><b>Parameters:</b>
<br/>cond - This will usually be a mixed array of an object and a function.
It could also be a function pointer.

</dl>

<ul><a name="set_election_announcement">
set_election_announcement</a><pre>
void set_election_announcement(string board,
                               string person,
                               string subject,
                               string prefix,
                               string suffix)
</pre></br>
This function defines the board, person and subject for announcements
of elections.

<br/><ul>
<li><b>Parameters:</b>
<br/>board - This is the board to post to.
<br/>person - This is who to post as.
<br/>subject - This is the subject line to use.
<br/>prefix - The text to preceed the message.  The default is
              "All eligible persons are requested to vote for the position "
              "of "
<br/>suffix - The text to follow the message.

</dl>

<ul><a name="set_no_elections">
set_no_elections</a><pre>
void set_no_elections(int no_elections)
</pre></br>
This method sets the room to not allow elections and disable all the
election commands.
<br/><ul>
<li><b>Parameters:</b>
<br/>no_elections - the flag

</dl>

<ul><a name="set_open_voting">
set_open_voting</a><pre>
void set_open_voting(int open)
</pre></br>
This function setups if the votes should be open or not.  If a vote is
open then you know who voted for each thing.
<br/><ul>
<li><b>Parameters:</b>
<br/>open - 1 for an open system 0 for closed

</dl>

<ul><a name="set_proxy">
set_proxy</a><pre>
void set_proxy(string proxy)
</pre></br>
This method sets up a proxy for the room.  A proxy is somewhere else
to get all the voting information from.
<br/><ul>
<li><b>Parameters:</b>
<br/>proxy - the proxy tpo setup

</dl>

<ul><a name="set_save_file">
set_save_file</a><pre>
void set_save_file(string file)
</pre></br>
This method is called by the inheriting object to determine which save file
to use for votes.

<br/><ul>
<li><b>Parameters:</b>
<br/>str - The name of the file you want the voting info saved to
(without the .o)

</dl>

<ul><a name="set_second_conditions">
set_second_conditions</a><pre>
void set_second_conditions(mixed cond)
</pre></br>
This function defines a function to be called to determine if a player
is eligible to second a canditate for election.

<br/><ul>
<li><b>Parameters:</b>
<br/>cond - This will usually be a mixed array of an object and a function.
It could also be a function pointer.

Your function should return 1 if the player is eligible to second or 0 if
they are not.

</dl>

<ul><a name="set_stand_conditions">
set_stand_conditions</a><pre>
void set_stand_conditions(mixed cond)
</pre></br>
This function defines a function to be called to determine if a player
is eligible to stand for election to a position.

<br/><ul>
<li><b>Parameters:</b>
<br/>cond - This will usually be a mixed array of an object and a function.
It could also be a function pointer.

Your function should return 1 if the player is eligible to stand or 0 if
they are not.

</dl>

<ul><a name="set_vote_conditions">
set_vote_conditions</a><pre>
void set_vote_conditions(mixed cond)
</pre></br>
This function defines a function to be called to determine if a player
is eligible to vote.

<br/><ul>
<li><b>Parameters:</b>
<br/>cond - This will usually be a mixed array of an object and a function.
It could also be a function pointer.

Your function should return 1 if the player is eligible to vote or 0 if
they are not.

</dl>

<ul><a name="set_vote_duration">
set_vote_duration</a><pre>
void set_vote_duration(int duration)
</pre></br>
This function is used to set the normal vote and election duration. It can
be overridden when calling add_vote. If it is not set and no duration is
given in add_vote then the default value of DEFAULT_VOTE_DURATION is used.

<br/><ul>
<li><b>Parameters:</b>
<br/>duraction - The number of seconds the vote should be open.

<li><b>See also:</b>
<br/><a href="#add_vote">add_vote()
</a></dl>

<ul><a name="setup_after_load">
setup_after_load</a><pre>
void setup_after_load()
</pre></br>
This setups all the stuff that  needs to be setup after the room has
been loaded.  Makes all the callouts for the right amount of time
and so on.


<ul><a name="stand_for_election">
stand_for_election</a><pre>
int stand_for_election(string position)
</pre></br>
This function is used by players to stand for election. The syntax is:
"stand for <position>".

<br/><ul>
<li><b>See also:</b>
<br/><a href="#set_stand_conditions">set_stand_conditions()
</a></dl>

<ul><a name="start_election_vote">
start_election_vote</a><pre>
void start_election_vote(string post)
</pre></br>
Once the candidacy phase is over this function starts the election vote
itself by taking all eligible candidates, setting them as choices in the
election and then posting an announcemment.



<h2>Protected Functions</h2>
These are functions that only objects inheriting the class can access.<p>
<ul><a name="add_our_election">
add_our_election</a><pre>
void add_our_election(string name,
                      class election data)
</pre></br>
This method adds in a election.
<br/><ul>
<li><b>Parameters:</b>
<br/>name - the name of the election to add
<br/>data - the election data

</dl>

<ul><a name="add_our_vote">
add_our_vote</a><pre>
void add_our_vote(int id,
                  class vote data)
</pre></br>
This method adds in a vote.
<br/><ul>
<li><b>Parameters:</b>
<br/>id - the id of the vote
<br/>data - the vote data

</dl>

<ul><a name="query_our_elections">
query_our_elections</a><pre>
mapping query_our_elections()
</pre></br>
This method is used to return the current elections.  This can be
overridden in hgiher inherits to control things better.
<br/><ul>
<li><b>Returns:</b>
<br/>the elections

</dl>

<ul><a name="query_our_votes">
query_our_votes</a><pre>
mapping query_our_votes()
</pre></br>
This method is used to return the current votes.  This can be overridden
in higher functions to get the votes from somewhere else if nessessary.
<br/><ul>
<li><b>Returns:</b>
<br/>the votes

</dl>

<ul><a name="save_room">
save_room</a><pre>
void save_room()
</pre></br>
Private function to save the rooms data file.



<h2>Classes</h2>
These are nice data types for dealing with...  Data!<p>
<ul>
<li><a name="class_election">
election</a><pre>
class election {
                 mixed * candidates;
                 int closes;
}

</pre><br/>
 This class stores the essential information about an election during the
 setup phase. It is only used internally to the voting room.
<p>

<li><a name="class_vote">
vote</a><pre>
class vote {
             string type;
             string desc;
             string * choices;
             mixed * votes;
             int ending;
             string * voted;
}

</pre><br/>
 This class stores the essential information about a vote. It is only used
 internally to the voting room.<p>

</ul>
[an error occurred while processing this directive]

