/// @title A single ballot contract which allows certain
/// @title accounts to vote (one single vote).
/// @author soliditycookbook.com & Robert Martin-Legene
/// @notice A Chairman will deploy the contract, setting up initial
/// @notice conditions. Before the voting period starts the Chairman
/// @notice must also tell the contract who is allowed to vote.
contract Ballot
{
/// @dev This is a struct for a single voter.
/// @dev Voter.vote is the index of the voted proposal or -1 if
/// @dev the account has not voted yet.
struct Voter
{
address voter;
uint[] votedProposals;
uint votesLeft;
}
string public ballotTitle;
address payable public ballotChairman;
uint public ballotVoteStarts;
uint public ballotVoteBefore;
uint public ballotPercentOfRegisteredVotersReqToBeValid;
uint public ballotPercentOfVotesCastToWin;
/// @dev Counting registered voters who do not vote as blank
/// @dev votes, has the effect that it is more difficult
/// @dev to acquire the desired votes.
bool public ballotCountNonvotesAsBlanks;
uint public ballotMaxVotesPerVoter;
uint public ballotMaxVotesPerProposal;
/// @dev The votermap points to the index(number) that the struct of the
/// @dev account can be found.
mapping( address => uint )
public voterMap;
Voter[] public voterList;
/// @dev Short name (up to 32 bytes)
bytes32[] public proposalList;
uint[] private emptyuintlist;
/// @notice When the SC is being deployed, you must define initial conditions. When specifying percentages they are to have been multiplied with 100 million (5% is written as 5 million, since 5% is actially 0.05).
/// @param title Name of the things being voted for.
/// @param voteStarts Time in seconds (since Unix Epoch) when the voting starts (note that voters must be defined before voting starts).
/// @param voteBefore Time in seconds (since Unix Epoch) at/after which it is too late to vote. After this point, the Ballot is effectively readonly.
/// @param percentOfRegisteredVotersReqToBeValid How many of the registered voters must vote before the result of the Ballot can be considered valid. E.g. if 50% is set and only 40% votes, then the result of the Ballot can not be used.
/// @param percentOfVotesCastToWin How many of the votes that are cast are required to win. This is often 50.000001% ("more than half"), 67.777778% ("two thirds") or 0% (proposal with most votes - e.g. voting for most popular fruit).
/// @param countNonvotesAsBlanks Whether or not to count voters whom did not vote, as having voted blank.
/// @param maxVotesPerVoter How many votes can a voter cast. Often this is 1 (one).
/// @param maxVotesPerProposal How many votes one voter can cast on each proposal. I.e. can (s)he vote use all his votes on one proposal?
/// @param proposalNames 32 char "strings" listing all the options available to vote for.