Documentation ¶
Index ¶
- func Cleanup()
- func InitDB() error
- type Entity
- type NextTurnAction
- type Proposal
- type Rule
- type User
- func AddNewUser(fullname, displayname, username, password string) (*User, error)
- func Authenticate(username, password string) (*User, error)
- func FindUserByDisplayName(name string) (*User, bool)
- func FindUserByUsername(username string) (*User, bool)
- func SetFirstTurn() (*User, error)
- func SetNextTurn() (*User, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type NextTurnAction ¶
type NextTurnAction int
NextTurnAction represents the next action the acting user needs to take
const ( Submit NextTurnAction = iota Voting )
A list of actions the user takes in their actions
func (NextTurnAction) String ¶
func (i NextTurnAction) String() string
type Proposal ¶
type Proposal struct { gorm.Model Number int Text string SubmittedBy string // username of submitter RelatedToRule int VotesInFavor int VotesAgainst int VotingInProgress bool VotingStarted *time.Time VotingEnded *time.Time }
Proposal is the entity for proposed rule-changes
func (Proposal) IsVotingEnded ¶
IsVotingEnded determines if voting has ended on this proposal
func (Proposal) IsVotingStarted ¶
IsVotingStarted determines if voting has started on this proposal
func (*Proposal) StartVoting ¶
func (p *Proposal) StartVoting()
StartVoting starts voting on this proposal
type Rule ¶
Rule represents a single rule
func FindAllActiveRules ¶
func FindAllActiveRules() []Rule
FindAllActiveRules returns the list of active rules
type User ¶
type User struct { gorm.Model FullName string DisplayName string Username string Password []byte LastLogin time.Time Points int IsTurn bool EndOfTurn time.Time Action NextTurnAction }
User contains data for a user of the game
func AddNewUser ¶
AddNewUser creates a new user and inserts it into the DB
func Authenticate ¶
Authenticate authenticates the user
func FindUserByDisplayName ¶
FindUserByDisplayName returns a user based on the display name. It will return true if the user was found; false otherwise.
func FindUserByUsername ¶
FindUserByUsername finds the user based on the username. It will return true if the user was found; false otherwise.
func SetFirstTurn ¶
SetFirstTurn sets the turn to the first user by display name
func SetNextTurn ¶
SetNextTurn sets the turn indicator to true for the next user and false for all others
func (*User) HashAndSalt ¶
HashAndSalt converts password to hashed value
func (*User) Insert ¶
Insert inserts the record into the db This does not check to see if the records already exists; it assumes it does not.
func (*User) Save ¶
Save will insert or update the record, based on whether it has a primary key or not
func (*User) StartTurn ¶
func (u *User) StartTurn()
StartTurn will set the turn to active for this user and set the EndOfTurn appropriately, ending at 11:59 PM EST four days in the future. Note this doesn't update any other user, so caller is responsible for making sure no other user is set to active
func (User) VerifyPassword ¶
VerifyPassword will validate the given password