My Project
 All Classes Namespaces Functions Variables
Public Member Functions | Public Attributes
Game.Poll Class Reference

List of all members.

Public Member Functions

def __init__
def computeVote
def getRank
def getWinner
def newTurn
def formattedstr
def introduction
def catchingUp

Public Attributes

 question
 The question for which the Poll is computing votes.
 data
 The list of possible answers, each one with a possible object attached and the number of votes received.
 turns
 The number of turns left before the Poll expires.
 isactive
 Boolean to indicate if the Poll is active.
 fformat
 Function to format the strings to be displayed.

Detailed Description

A class that represents a poll.
It has a question, a list of possible answers
and the means to compute votes to these answers

Constructor & Destructor Documentation

def Game.Poll.__init__ (   self,
  question,
  answersobjs,
  turns = INDEF,
  isactive = True,
  fformat = lambda x: None 
)
Poll.__init__(self, question, answersobjs, turns = INDEF, isactive = True,
 fformat = lambda x: None
)

Initialization function

question is the question to be asked to the participants of the poll

answersobjs is a list of tuples (answer, obj).
Each answer can have an attached reference to any object.

turns is the number of turns for which the poll will remain active.
-1 is indefinite

isActive indicates whether of not the Poll is active

fformat if a function to format the answers and has a single argument,
the poll object itself and returns a list of formatted strings

Member Function Documentation

def Game.Poll.catchingUp (   self)
Generates a JSON friendly dictionary with
all the object's attributes and values.
This function is intended as a update on the object's state,
sent to receivers that are already able to identify the object.
def Game.Poll.computeVote (   self,
  answer,
  votes = 1 
)
Poll.computeVote(self, answer, votes = 1)
Computes votes to one of the Polls answers
the answer can be either a string or the index in self.data
def Game.Poll.formattedstr (   self)
Poll.formattedstr(self)
Returns a list of the Poll's formatted strings.
The first one being the question and the others the answers, in order
def Game.Poll.getRank (   self)
Poll.getRank(self)
Returns the Poll's results ordered by most voted answers
def Game.Poll.getWinner (   self)
Poll.getWinner(self)
Returns the Poll's winning answer
def Game.Poll.introduction (   self)
Generates a JSON friendly dictionary with
all the object's attributes and values.
This function is intended as a first introduction of the object,
to receivers that are unaware of its existence.
def Game.Poll.newTurn (   self,
  turnnumber = 1 
)
Poll.newTurn(self, turnnumber = 1)
Function to compute a new turn

The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables