nomyx-library-1.0.0: Library of rules for Nomyx

Safe HaskellSafe
LanguageHaskell98

Nomyx.Library.Vote

Description

Voting system

Synopsis

Documentation

type AssessFunction = VoteStats -> Maybe Bool Source #

a vote assessing function (such as unanimity, majority...)

data VoteStats Source #

the vote statistics, including the number of votes per choice, the number of persons called to vote, and if the vote is finished (timeout or everybody voted)

data VoteEnd Source #

information broadcasted when a vote ends

unanimityVote :: Nomex () Source #

vote at unanimity every incoming rule

callVoteRule :: AssessFunction -> NominalDiffTime -> RuleInfo -> Nomex () Source #

call a vote on a rule for every players, with an assessing function and a delay

finishVote :: AssessFunction -> RuleInfo -> [(PlayerNumber, Maybe Bool)] -> Nomex () Source #

actions to do when the vote is finished

callVote :: AssessFunction -> UTCTime -> String -> RuleNumber -> ([(PlayerNumber, Maybe Bool)] -> Nomex ()) -> Nomex EventNumber Source #

call a vote for every players, with an assessing function, a delay and a function to run on the result

voteWith :: UTCTime -> AssessFunction -> String -> Event [(PlayerNumber, Maybe Bool)] Source #

vote with a function able to assess the ongoing votes. | the vote can be concluded as soon as the result is known.

displayVotes :: Nomex () Source #

display the votes (ongoing and finished)

unanimity :: AssessFunction Source #

assess the vote results according to a unanimity

majority :: AssessFunction Source #

assess the vote results according to an absolute majority (half voters plus one)

majorityWith :: Int -> AssessFunction Source #

assess the vote results according to a majority of x (in %)

numberVotes :: Int -> AssessFunction Source #

assess the vote results according to a fixed number of positive votes

withQuorum :: AssessFunction -> Int -> AssessFunction Source #

adds a quorum to an assessing function

counts :: (Eq a, Ord a) => [a] -> [(a, Int)] Source #

voteQuota :: Int -> VoteStats -> Maybe Bool Source #

Compute a result based on a quota of positive votes. the result can be positive if the quota if reached, negative if the quota cannot be reached anymore at that point, or still pending.

nbVoters :: VoteStats -> Int Source #

number of people that voted if the voting is finished, total number of people that should vote otherwise

displayOnGoingVote :: VoteBegin -> Nomex () Source #

display an on going vote

displayFinishedVote :: VoteEnd -> Nomex () Source #

display a finished vote