models

package
v0.0.0-...-abd2ee0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlayersInATeam    = 4
	TeamsInAMatch     = 4
	QuestionsInAMatch = 20
)

Variables

This section is empty.

Functions

func NewTeamName

func NewTeamName(idx int) (name string)

func ScoreAnswer

func ScoreAnswer(matchPoints int, roundNo int) int

Types

type AddQuestionRequest

type AddQuestionRequest struct {
	Questions []NewQuestion `json:"questions"`
	Tag       string        `json:"tag"`
}

func DecodeAddQuestionRequest

func DecodeAddQuestionRequest(r *http.Request) (request AddQuestionRequest, err error)

type AddQuestionResponse

type AddQuestionResponse struct {
	QuestionId string `json:"question_id"`
	AnswerId   string `json:"answer_id"`
}

func InitAddQuestionResponse

func InitAddQuestionResponse(question Question, answer Answer) (response AddQuestionResponse)

type Answer

type Answer struct {
	Id         string   `json:"id" bson:"_id"`
	QuestionId string   `json:"question_id" bson:"question_id"`
	Answer     []string `json:"answer" bson:"answer"`
	Hint       []string `json:"hints" bson:"hints"`
}

func InitNewAnswer

func InitNewAnswer(question Question, newQuestion NewQuestion) (answer Answer)

type AuthenticationResponse

type AuthenticationResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

type CreateGameRequest

type CreateGameRequest struct {
	Quizmaster Player `json:"quizmaster"`
	Specs      Specs  `json:"specs"`
}

func DecodeCreateGameRequestJsonString

func DecodeCreateGameRequestJsonString(content string) (request CreateGameRequest, err error)

type Creator

type Creator struct{}

func (Creator) InitSubscriber

func (creator Creator) InitSubscriber(tag string, player Player, role string) (subscriber Subscriber)

type EnterGameRequest

type EnterGameRequest struct {
	Person Player `json:"person"`
	QuizId string `json:"quiz_id"`
	TeamId string `json:"team_id"`
}

func DecodeEnterGameRequestJsonString

func DecodeEnterGameRequestJsonString(content string) (request EnterGameRequest, err error)

type Game

type Game struct {
	Id            string   `json:"id" bson:"_id"`
	QuizMaster    Player   `json:"quizmaster" bson:"quizmaster"`
	Tags          []string `bson:"tags"`
	Specs         Specs    `json:"specs" bson:"specs"`
	Active        bool     `json:"active" bson:"active"`
	Started       bool     `json:"started" bson:"started"`
	CanJoin       bool     `json:"can_join"`
	PlayersJoined int      `json:"players_joined"`
}

func InitNewMatch

func InitNewMatch(quizmaster Player, specs Specs) (match Game)

type GameResponse

type GameResponse struct {
	Quiz     Game     `json:"quiz"`
	Snapshot Snapshot `json:"snapshot"`
	Role     string   `json:"role"`
}

func DecodeGameResponseJsonString

func DecodeGameResponseJsonString(content string) (request GameResponse, err error)

type GameSnapRequest

type GameSnapRequest struct {
	QuizId     string `json:"quiz_id"`
	TeamSTurn  string `json:"team_s_turn"`
	QuestionId string `json:"question_id"`
}

func DecodeGameSnapRequestJsonString

func DecodeGameSnapRequestJsonString(content string) (request GameSnapRequest, err error)

type Index

type Index struct {
	Id  string `json:"id" bson:"_id"`
	Tag string `json:"tag" bson:"tag"`
}

func InitNewIndex

func InitNewIndex(tag string) (index Index)

type IndexStore

type IndexStore struct {
	Indexes []string `json:"indexes" bson:"indexes"`
}

type LoginResponse

type LoginResponse struct {
	Player     Player                 `json:"player"`
	Tokens     AuthenticationResponse `json:"tokens"`
	Quizmaster bool                   `json:"quizmaster"`
}

func DecodeLoginResponseJsonString

func DecodeLoginResponseJsonString(content string) (request LoginResponse, err error)

type NewQuestion

type NewQuestion struct {
	Statements []string `json:"statements"`
	Answer     []string `json:"answer"`
}

type NextQuestionRequest

type NextQuestionRequest struct {
	QuizId         string `json:"quiz_id"`
	TeamSTurn      string `json:"team_s_turn"`
	LastQuestionId string `json:"question_id"`
}

type Permission

type Permission struct {
	PlayerId string `json:"player_id" bson:"player_id"`
}

type Player

type Player struct {
	Id    string `json:"id" bson:"_id"`
	Name  string `json:"name" bson:"name"`
	Email string `json:"email" bson:"email"`
}

func InitNewPlayer

func InitNewPlayer(playerRequest Player) (player Player)

type Question

type Question struct {
	Id         string   `json:"id" bson:"_id"`
	Statements []string `json:"statements" bson:"statements"`
	Tag        string   `json:"-" bson:"tag"`
}

func InitNewQuestion

func InitNewQuestion(index Index, newQuestion NewQuestion) (question Question)

type QuestionBank

type QuestionBank struct {
	Questions []NewQuestion `json:"questions"`
}

type Request

type Request struct {
	Action     string `json:"action"`
	Specs      Specs  `json:"specs,omitempty"`
	Person     Player `json:"person,omitempty"`
	QuizId     string `json:"quiz_id,omitempty"`
	TeamId     string `json:"team_id,omitempty"`
	QuestionId string `json:"question_id,omitempty"`
}

type ScoreRequest

type ScoreRequest struct {
	QuizId string `json:"quiz_id"`
}

func DecodeScoreRequestJsonString

func DecodeScoreRequestJsonString(content string) (request ScoreRequest, err error)

type ScoreResponse

type ScoreResponse struct {
	QuizId    string     `json:"quiz_id"`
	Snapshots []Snapshot `json:"snapshots"`
}

func InitScoreResponse

func InitScoreResponse(quizId string, snapshots []Snapshot) (response ScoreResponse)

type Snapshot

type Snapshot struct {
	QuizId     string       `json:"quiz_id" bson:"quiz_id"`
	RoundNo    int          `json:"round_no" bson:"round_no"`
	Roster     []TeamRoster `json:"teams" bson:"teams"`
	TeamSTurn  string       `json:"team_s_turn" bson:"team_s_turn"`
	QuestionNo int          `json:"question_no" bson:"question_no"`
	QuestionId string       `json:"question_id" bson:"question_id"`
	EventType  string       `json:"event_type" bson:"event_type"`
	Score      int          `json:"score" bson:"score"`
	Timestamp  string       `json:"timestamp" bson:"timestamp"`
	Question   []string     `json:"question" bson:"question"`
	Answer     []string     `json:"answer" bson:"answer"`
	Hint       []string     `json:"hint" bson:"hint"`
	CanPass    bool         `json:"can_pass"`
}

func DecodeSnapshotJsonString

func DecodeSnapshotJsonString(content string) (request Snapshot, err error)

func InitialSnapshot

func InitialSnapshot(quizId string, teams []TeamRoster) (response Snapshot)

func SnapshotWithAnswer

func SnapshotWithAnswer(snapshot Snapshot, answer []string, matchPoints int, teams []TeamRoster) (response Snapshot)

func SnapshotWithDropPlayer

func SnapshotWithDropPlayer(snapshot Snapshot, teams []TeamRoster) (response Snapshot)

func SnapshotWithFinish

func SnapshotWithFinish(snapshot Snapshot, teams []TeamRoster) (response Snapshot)

func SnapshotWithHint

func SnapshotWithHint(snapshot Snapshot, hint []string, teams []TeamRoster) (response Snapshot)

func SnapshotWithJoinPlayer

func SnapshotWithJoinPlayer(snapshot Snapshot, teams []TeamRoster) (response Snapshot)

func SnapshotWithNext

func SnapshotWithNext(snapshot Snapshot, teams []TeamRoster, team_s_turn string, question Question) (response Snapshot)

func SnapshotWithPass

func SnapshotWithPass(snapshot Snapshot, teams []TeamRoster, team_s_turn string, roundNo int) (response Snapshot)

func SnapshotWithStart

func SnapshotWithStart(snapshot Snapshot, teams []TeamRoster, question Question, teamsTurn string) (response Snapshot)

type SnapshotResponse

type SnapshotResponse struct {
	Action   string   `json:"action"`
	Snapshot Snapshot `json:"snapshot"`
}

type Specs

type Specs struct {
	Name      string `json:"name" bson:"name"`
	Teams     int    `json:"teams" bson:"teams"`
	Players   int    `json:"players" bson:"players"`
	Questions int    `json:"questions" bson:"questions"`
	Rounds    int    `json:"rounds" bson:"rounds"`
	Points    int    `json:"points" bson:"points"`
}

type StartGameRequest

type StartGameRequest struct {
	QuizId string `json:"quiz_id"`
}

func DecodeStartGameRequestJsonString

func DecodeStartGameRequestJsonString(content string) (request StartGameRequest, err error)

type Subscriber

type Subscriber struct {
	Tag      string `json:"tag" bson:"tag"`
	PlayerId string `json:"player_id" bson:"player_id"`
	Role     string `json:"role" bson:"role"`
	Active   bool   `json:"active" bson:"active"`
}

type Team

type Team struct {
	Id     string `json:"id" bson:"_id"`
	QuizId string `json:"quiz_id" bson:"quiz_id"`
	Name   string `json:"name" bson:"name"`
	Score  int    `json:"score" bson:"score"`
}

func InitNewTeam

func InitNewTeam(name string, quizId string) (team Team)

func InitNewTeams

func InitNewTeams(match Game) (teams []Team)

type TeamRoster

type TeamRoster struct {
	Id      string   `json:"id"`
	Name    string   `json:"name"`
	Players []Player `json:"players"`
	Score   int      `json:"score" bson:"score"`
}

type WebsocketMessage

type WebsocketMessage struct {
	Action  string `json:"action"`
	Content string `json:"content"`
}

func DecodeWebSocketRequest

func DecodeWebSocketRequest(input []byte) (request WebsocketMessage, err error)

type WebsocketMessageCreator

type WebsocketMessageCreator struct{}

func (WebsocketMessageCreator) InitWebSocketMessage

func (creator WebsocketMessageCreator) InitWebSocketMessage(action actions.Action, content string) (response WebsocketMessage)

func (WebsocketMessageCreator) InitWebSocketMessageFailure

func (creator WebsocketMessageCreator) InitWebSocketMessageFailure() (response WebsocketMessage)

func (WebsocketMessageCreator) WebSocketsResponse

func (creator WebsocketMessageCreator) WebSocketsResponse(action actions.Action, v interface{}) (res WebsocketMessage)

Jump to

Keyboard shortcuts

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