Class Poll

java.lang.Object
net.flectone.pulse.module.command.poll.model.Poll

public class Poll extends Object
A running poll and the votes cast so far.
  • Constructor Details

    • Poll

      public Poll(int id, int creator, long endTime, long repeatTime, boolean multipleVote, String title, List<String> answers)
      Creates a poll.
      Parameters:
      id - the database id
      creator - the player who started it
      endTime - when voting closes, in milliseconds
      repeatTime - how often it is re-announced, in milliseconds
      multipleVote - whether a voter may pick several answers
      title - the question
      answers - the options to vote on
  • Method Details

    • vote

      public int vote(FEntity fPlayer, int numberVote)
      Records a vote, withdrawing the voter's previous one when only a single choice is allowed.
      Parameters:
      fPlayer - the voter
      numberVote - the chosen option
      Returns:
      whether the vote was cast, changed or withdrawn
    • getCountAnswers

      public int[] getCountAnswers()
      How many votes each option has.
      Returns:
      the tallies, in option order
    • isEnded

      public boolean isEnded()
      Whether voting has closed.
      Returns:
      true if the poll is over
    • repeat

      public boolean repeat()
      Whether the poll is due to be announced again.
      Returns:
      true if it should be re-announced now
    • getId

      public int getId()
    • getCreator

      public int getCreator()
    • getEndTime

      public long getEndTime()
    • getRepeatTime

      public long getRepeatTime()
    • isMultipleVote

      public boolean isMultipleVote()
    • getTitle

      public String getTitle()
    • getAnswers

      public List<String> getAnswers()
    • getVotesMap

      public Map<UUID, boolean[]> getVotesMap()
    • getNextRepeat

      public long getNextRepeat()