event

package
v0.0.0-...-3dbe172 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const MaxTeamMembers = 9

MaxTeamMembers defines hard limit on team members.

View Source
const SuggestedTeamMembers = 6

SuggestedTeamMemberes defines how many members are shown by default.

Variables

View Source
var AspectDescriptions = []AspectDescription{
	{
		Name:        "Theme",
		Description: "How well does it interpret the theme?",
		Range:       Range{Min: 1, Max: 5, Step: 0.1},
		Options:     []string{"Not even close", "Resembling", "Related", "Spot on", "Novel Interpretation"},
	}, {
		Name:        "Enjoyment",
		Description: "How does the game generally feel?",
		Range:       Range{Min: 1, Max: 5, Step: 0.1},
		Options:     []string{"I want my time back", "Boring", "Nice", "Didn't want to stop", "Will play later"},
	}, {
		Name:        "Aesthetics",
		Description: "How well is the story, art and audio executed?",
		Range:       Range{Min: 1, Max: 5, Step: 0.1},
		Options:     []string{"None", "Needs tweaks", "Nice", "Really good", "Exceptional"},
	}, {
		Name:        "Innovation",
		Description: "Something novel in the game?",
		Range:       Range{Min: 1, Max: 5, Step: 0.1},
		Options:     []string{"Seen it a lot", "Interesting variation", "Interesting approach", "Never seen this before", "Exceptional"},
	}, {
		Name:        "Bonus",
		Description: "Anything exceptionally special about it?",
		Range:       Range{Min: 0, Max: 2.5, Step: 0.1},
		Options:     []string{"Nothing special", "Really liked *", "Really loved **"},
	},
}

AspectDescriptions contains information about aspects.

View Source
var AspectDescriptionsWithOverall = append(AspectDescriptions,
	AspectDescription{
		Name:        "Overall",
		Description: "Weighted average of topics.",
		Range:       Range{Min: 1, Max: 5, Step: 0.1},
	})

AspectDescriptionsWithOverall also includes the overall.

View Source
var AspectNames = []string{
	"Theme",
	"Enjoyment",
	"Aesthetics",
	"Innovation",
	"Bonus",
	"Overall",
}

AspectNames contains all names of aspects.

View Source
var DefaultAspects = Aspects{
	Theme:      Aspect{3, ""},
	Enjoyment:  Aspect{3, ""},
	Aesthetics: Aspect{3, ""},
	Innovation: Aspect{3, ""},
	Bonus:      Aspect{0, ""},
	Overall:    Aspect{0, ""},
}

DefaultAspects contains defaults for aspects.

View Source
var ErrExists = errors.New("already exists")

ErrExists is returned when an event already exists.

View Source
var ErrNotExists = errors.New("does not exist")

ErrNotExists is returned when an event doesn't exist.

Functions

This section is empty.

Types

type Aspect

type Aspect struct {
	Score   float64
	Comment string
}

Aspect is a single criteria with an optional comment.

func (Aspect) String

func (aspect Aspect) String() string

String pretty prints an aspect.

type AspectDescription

type AspectDescription struct {
	Name        string
	Description string
	Range
	Options []string
}

AspectDescription describes an aspect.

type AspectInfo

type AspectInfo struct {
	Scores       []float64
	MemberScores []float64
	Comments     []string
}

AspectInfo contains all scores for an aspect.

func (*AspectInfo) Add

func (aspect *AspectInfo) Add(other *Aspect, isMember bool)

Add includes other into aspect.

type Aspects

type Aspects struct {
	Theme      Aspect
	Enjoyment  Aspect
	Aesthetics Aspect
	Innovation Aspect
	Bonus      Aspect
	Overall    Aspect
}

Aspects contains criteria for scoring a game.

func AverageScores

func AverageScores(ballots []*Ballot, event *Event) (final, jammers, judges Aspects)

AverageScores returns averages for all aspects.

func (*Aspects) Add

func (aspects *Aspects) Add(other *Aspects)

Add adds together two aspects.

func (*Aspects) ClearComments

func (aspects *Aspects) ClearComments()

ClearComments clears all comments in aspects.

func (*Aspects) Comment

func (aspects *Aspects) Comment(name string) string

Comment returns an aspect comment based on a name.

func (*Aspects) EnsureRange

func (aspects *Aspects) EnsureRange()

EnsureRange ensures that all scores are in the appropriate ranges.

func (*Aspects) Scale

func (aspects *Aspects) Scale(multiplier float64)

func (*Aspects) Score

func (aspects *Aspects) Score(name string) float64

Score returns an aspect score based on a name.

func (*Aspects) Total

func (aspects *Aspects) Total() float64

Total calculates total score.

func (*Aspects) UpdateTotal

func (aspects *Aspects) UpdateTotal()

UpdateTotal updates overall score.

type AspectsInfo

type AspectsInfo struct {
	Theme      AspectInfo
	Enjoyment  AspectInfo
	Aesthetics AspectInfo
	Innovation AspectInfo
	Bonus      AspectInfo
	Overall    AspectInfo
}

AspectsInfo contains all scores for aspects.

func (*AspectsInfo) Add

func (aspects *AspectsInfo) Add(other *Aspects, isMember bool)

Add includes other into aspects.

func (*AspectsInfo) Item

func (aspects *AspectsInfo) Item(name string) AspectInfo

Item fetches an aspect by name.

type Ballot

type Ballot struct {
	ID        *datastore.Key `datastore:"-"`
	Voter     user.UserID
	Team      TeamID
	Index     int64 `datastore:",noindex"`
	Completed bool  `datastore:",noindex"`
	Aspects
}

Ballot is all information for a single ballot.

type BallotInfo

type BallotInfo struct {
	*Team
	*Ballot
}

BallotInfo is a single ballot, but contains a reference to the target team.

type BallotRepo

type BallotRepo interface {
	Ballots(eventid EventID) ([]*Ballot, error)
	CreateIncompleteBallots(eventid EventID, userid user.UserID) (complete, incomplete []*BallotInfo, err error)
	SubmitBallot(eventid EventID, ballot *Ballot) error
	UserBallot(eventid EventID, userid user.UserID, teamid TeamID) (*Ballot, error)
	UserBallots(eventid EventID, userid user.UserID) ([]*BallotInfo, error)
	Results(eventid EventID) ([]*TeamResult, error)
	TeamBallots(eventid EventID, teamid TeamID) ([]*Ballot, error)
}

BallotRepo is used to manage ballots for an event.

type Context

type Context struct {
	Event  *Event
	Team   *Team
	Events Repo

	*user.Context
}

Context contains an event request.

type DB

type DB interface {
	Events(context context.Context) Repo
}

DB is the master database.

type Event

type Event struct {
	ID    EventID `datastore:"-"`
	Name  string
	Theme string `datastore:",noindex"`
	Info  string `datastore:",noindex"`

	// Created is the time when the event was created
	Created time.Time `datastore:",noindex"`
	// StartTime is the starting time of the event
	StartTime time.Time `datastore:",noindex"`
	// EndTime is the end time of the event
	EndTime time.Time `datastore:",noindex"`

	JudgePercentage float64 `datastore:",noindex"`

	// New Registration is allowed
	Registration bool `datastore:",noindex"`
	// Voting allow voting
	Voting bool `datastore:",noindex"`
	// Closed for new entries
	Closed bool `datastore:",noindex"`
	// Revealed, results are publicly viewable
	Revealed bool `datastore:",noindex"`

	VotingOpens  time.Time `datastore:",noindex"`
	VotingCloses time.Time `datastore:",noindex"`

	Organizers []user.UserID `datastore:",noindex"`
	Jammers    []user.UserID `datastore:",noindex"`
	Judges     []user.UserID `datastore:",noindex"`
}

Event contains all information about an event.

func (*Event) AddRemoveJammers

func (event *Event) AddRemoveJammers(added, removed []user.UserID)

AddRemoveJammers adds and removes jammers from the event.

func (*Event) AddRemoveJudges

func (event *Event) AddRemoveJudges(added, removed []user.UserID)

AddRemoveJudges adds and removes judges from the event.

func (*Event) CanRegister

func (event *Event) CanRegister(u *user.User) bool

CanRegister returns whether u can register to the event.

func (*Event) CanVote

func (event *Event) CanVote() bool

CanVote returns whether it's possible to vote in this event.

func (*Event) HasJammer

func (event *Event) HasJammer(u *user.User) bool

HasJammer checks whether u has registered.

func (*Event) HasJudge

func (event *Event) HasJudge(u *user.User) bool

func (*Event) HasJudgeById

func (event *Event) HasJudgeById(userId *user.UserID) bool

func (*Event) JudgesExist

func (event *Event) JudgesExist() bool

func (*Event) Less

func (event *Event) Less(other *Event) bool

Less compares events based on start time.

func (*Event) Path

func (event *Event) Path(subroutes ...any) string

Path returns a proper route for an event.

type EventID

type EventID string

EventID is a unique identifier for an event.

func (EventID) String

func (id EventID) String() string

String returns printable event id.

func (EventID) Valid

func (id EventID) Valid() bool

Valid checks whether event is valid.

type EventTeam

type EventTeam struct {
	Event Event
	Team
}

EventTeam contains information about the event and team.

type Game

type Game struct {
	Name string
	Info string `datastore:",noindex"`

	Noncompeting bool `datastore:",noindex"`

	Link struct {
		Jam      string `datastore:",noindex"`
		Download string `datastore:",noindex"`
		Facebook string `datastore:",noindex"`
	} `datastore:",noindex"`
}

Game contains all information about a game.

type Member

type Member struct {
	ID   user.UserID // can be zero
	Name string
}

Member is a team member. There may not be a registered user.

type Range

type Range struct{ Min, Max, Step float64 }

Range is an aspect range.

type Repo

type Repo interface {
	List() ([]*Event, error)

	Create(event *Event) error
	ByID(id EventID) (*Event, error)
	Update(event *Event) error

	TeamRepo
	BallotRepo
}

Repo describes interaction with the database.

type Server

type Server struct {
	Site *site.Server
	DB   DB

	Users *user.Server
}

Server handles pages related to an event.

func (*Server) BallotsCSV

func (server *Server) BallotsCSV(context *Context)

BallotsCSV returns all ballots for analysis.

func (*Server) Context

func (server *Server) Context(w http.ResponseWriter, r *http.Request) *Context

Context creates a new context for the given request.

func (*Server) CreateEvent

func (server *Server) CreateEvent(context *Context)

CreateEvent handles page for creating a new event.

func (*Server) CreateTeam

func (server *Server) CreateTeam(context *Context)

CreateTeam handles page for creating a new team.

func (*Server) Dashboard

func (server *Server) Dashboard(context *Context)

Dashboard returns main page for an event.

func (*Server) DeleteTeam

func (server *Server) DeleteTeam(context *Context)

DeleteTeam handles page for deleting a team.

func (*Server) EditEvent

func (server *Server) EditEvent(context *Context)

EditEvent handles page for editing an event.

func (*Server) EditTeam

func (server *Server) EditTeam(context *Context)

EditTeam handles page for editing a team.

func (*Server) FillQueue

func (server *Server) FillQueue(context *Context)

FillQueue fills voting queue for a user.

func (*Server) Handler

func (server *Server) Handler(fn func(*Context)) http.HandlerFunc

Handler wraps fn with Context, however a valid event id is required.

func (*Server) HandlerMaybe

func (server *Server) HandlerMaybe(fn func(*Context)) http.HandlerFunc

HandlerMaybe wraps fn with automatic Context creation.

func (*Server) Jammers

func (server *Server) Jammers(context *Context)

Jammers handles managing registered jammers for an event.

func (*Server) Linking

func (server *Server) Linking(context *Context)

Linking displays information about users who have not been linked to their users.

func (*Server) LinkingApproveAll

func (server *Server) LinkingApproveAll(context *Context)

LinkingApproveAll tries to associate all team members with appropriate teams and users.

func (*Server) List

func (server *Server) List(context *Context)

List lists all events.

func (*Server) Progress

func (server *Server) Progress(context *Context)

Progress displays page for voting progress.

func (*Server) Register

func (server *Server) Register(router *http.ServeMux)

Register registers all endpoints to router.

func (*Server) Results

func (server *Server) Results(context *Context)

Results displays all the results.

func (*Server) Reveal

func (server *Server) Reveal(context *Context)

Reveal handles page for revealing the final result.

func (*Server) Team

func (server *Server) Team(context *Context)

Team displays team information.

func (*Server) Teams

func (server *Server) Teams(context *Context)

Teams displays all teams.

func (*Server) Vote

func (server *Server) Vote(context *Context)

Vote handles page for casting a ballot.

func (*Server) Voting

func (server *Server) Voting(context *Context)

Voting displays voting queue.

type Team

type Team struct {
	EventID EventID `datastore:"-"`
	ID      TeamID  `datastore:"-"`

	Name    string
	Members []Member
	Game    Game `datastore:",noindex"`
}

Team contains all information about a team.

func (*Team) HasEditor

func (team *Team) HasEditor(user *user.User) bool

HasEditor checks whether user can edit the team.

func (*Team) HasMember

func (team *Team) HasMember(user *user.User) bool

HasMember checks whether user is a member of the team.

func (*Team) HasMemberID

func (team *Team) HasMemberID(userid user.UserID) bool

HasMemberID checks whether user is a member by userid.

func (*Team) HasSubmitted

func (team *Team) HasSubmitted() bool

HasSubmitted checks whether team has all information necessary.

func (*Team) IsCompeting

func (team *Team) IsCompeting() bool

IsCompeting returns whether team is part of the prizes.

func (*Team) Less

func (team *Team) Less(other *Team) bool

Less compares teams by name.

func (*Team) MembersForEdit

func (team *Team) MembersForEdit(isAdmin bool) []Member

MembersForEdit returns slice with additional empty members if needed.

func (*Team) MembersWithEmpty

func (team *Team) MembersWithEmpty() []Member

MembersWithEmpty returns slice with additional empty members if needed.

func (*Team) Verify

func (team *Team) Verify() error

Verify verifies whether team has valid state.

type TeamID

type TeamID int64

TeamID is a unique identifier for a team.

func (TeamID) String

func (id TeamID) String() string

String is the string representation of the team id.

type TeamRepo

type TeamRepo interface {
	CreateTeam(id EventID, team *Team) (TeamID, error)
	UpdateTeam(id EventID, team *Team) error
	DeleteTeam(id EventID, teamid TeamID) error
	TeamByID(id EventID, teamid TeamID) (*Team, error)
	Teams(id EventID) ([]*Team, error)
	TeamsByUser(id user.UserID) ([]*EventTeam, error)
}

TeamRepo contains team management in an event.

type TeamResult

type TeamResult struct {
	*Team
	Ballots []*Ballot

	Average       Aspects
	JudgeAverage  Aspects
	JammerAverage Aspects

	Pending  int
	Complete int

	MemberBallots []*Ballot
}

TeamResult contains all information about a single teams result.

func (*TeamResult) HasReviewer

func (info *TeamResult) HasReviewer(userid user.UserID) bool

HasReviewer checks whether team results contains userid.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL