story

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

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

Go to latest
Published: Aug 21, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CaertsianCoordinateColor

type CaertsianCoordinateColor struct {
	Start DrawingPoint `bson:"start" json:"start"`
	End   DrawingPoint `bson:"end"   json:"end"`
	Color string       `bson:"color" json:"color"`
}

type CurrentStoryInput

type CurrentStoryInput struct {
	internal.GameParams
	StoryIDParams
}

type DrawingPoint

type DrawingPoint struct {
	X float32 `bson:"x" json:"x"`
	Y float32 `bson:"y" json:"y"`
}

type Drawlosseum

type Drawlosseum struct{}

func (Drawlosseum) NewStory

func (d Drawlosseum) NewStory(story StoryInOut) (Story, error)

func (Drawlosseum) NewStoryOut

func (d Drawlosseum) NewStoryOut(story Story) (StoryInOut, error)

type DrawlosseumAnswers

type DrawlosseumAnswers []CaertsianCoordinateColor

func (DrawlosseumAnswers) NewAnswer

func (d DrawlosseumAnswers) NewAnswer()

type DrawlosseumAnswersInOut

type DrawlosseumAnswersInOut []CaertsianCoordinateColor

type FibbingIt

type FibbingIt struct{}

func (FibbingIt) NewStory

func (f FibbingIt) NewStory(story StoryInOut) (Story, error)

func (FibbingIt) NewStoryOut

func (f FibbingIt) NewStoryOut(story Story) (StoryInOut, error)

type FibbingItAnswer

type FibbingItAnswer struct {
	Nickname string `bson:"nickname"`
	Answer   string `bson:"answer"`
}

type FibbingItAnswerInOut

type FibbingItAnswerInOut struct {
	Nickname string `json:"nickname"`
	Answer   string `json:"answer"`
}

type FibbingItAnswers

type FibbingItAnswers []FibbingItAnswer

func (FibbingItAnswers) NewAnswer

func (f FibbingItAnswers) NewAnswer()

type FibbingItAnswersInOut

type FibbingItAnswersInOut []FibbingItAnswerInOut

type Gamer

type Gamer interface {
	NewStory(story StoryInOut) (Story, error)
	NewStoryOut(story Story) (StoryInOut, error)
}

func GetGame

func GetGame(name string) (Gamer, error)

type NewStoryInput

type NewStoryInput struct {
	internal.GameParams
	StoryInOut
}

type Quibly

type Quibly struct{}

func (Quibly) NewStory

func (q Quibly) NewStory(story StoryInOut) (Story, error)

func (Quibly) NewStoryOut

func (q Quibly) NewStoryOut(story Story) (StoryInOut, error)

type QuiblyAnswer

type QuiblyAnswer struct {
	Nickname string `bson:"nickname"`
	Answer   string `bson:"answer"`
	Votes    int    `bson:"votes"`
}

type QuiblyAnswerInOut

type QuiblyAnswerInOut struct {
	Nickname string `json:"nickname"`
	Answer   string `json:"answer"`
	Votes    int    `json:"votes"`
}

type QuiblyAnswers

type QuiblyAnswers []QuiblyAnswer

func (QuiblyAnswers) NewAnswer

func (q QuiblyAnswers) NewAnswer()

type QuiblyAnswersInOut

type QuiblyAnswersInOut []QuiblyAnswerInOut

type Stories

type Stories []Story

func (*Stories) Add

func (stories *Stories) Add(db database.Database) error

func (Stories) Delete

func (stories Stories) Delete(db database.Database, filter map[string]interface{}) (bool, error)

func (*Stories) Get

func (stories *Stories) Get(db database.Database, filter map[string]interface{}) error

func (*Stories) GetWithLimit

func (stories *Stories) GetWithLimit(db database.Database, filter map[string]interface{}, limit int64) error

func (Stories) ToInterface

func (stories Stories) ToInterface() []interface{}

type Story

type Story struct {
	GameName string          `bson:"game_name"          json:"game_name"`
	ID       string          `bson:"id"`
	Question string          `bson:"question"`
	Round    string          `bson:"round,omitempty"`
	Nickname string          `bson:"nickname,omitempty"`
	Answers  StoryAnswerType `bson:"answers"`
}

Story struct to contain information about a user story

func (*Story) Add

func (story *Story) Add(db database.Database) (bool, error)

func (*Story) Get

func (story *Story) Get(db database.Database, filter map[string]interface{}) error

func (*Story) UnmarshalBSONValue

func (story *Story) UnmarshalBSONValue(t bsontype.Type, data []byte) error

UnmarshalBSONValue is a custom unmarshal function, that will unmarshal question pools differently, i.e. answers field depending on the game name. As each has it's own question structure. The main purpose is just to get the raw BSON data for the `Answers` field.

Then, we work out the type of game, using `GameName`. Depending on the game we unmarshal the data into different structs and assign that to the `Questions` field of that `story` variable, which is of type `Story`. The `story`, is what is returned when we get the `Story` data from the database.

func (*Story) UnmarshalJSON

func (story *Story) UnmarshalJSON(data []byte) error

UnmarshalJSON works almost the same way as the UnmarshalBSONValue method above.

func (*Story) Update

func (story *Story) Update(db database.Database, filter map[string]interface{}) (bool, error)

type StoryAPI

type StoryAPI struct {
	Conf   core.Conf
	Logger *log.Logger
	DB     database.Database
}

func (*StoryAPI) AddStory

func (env *StoryAPI) AddStory(_ *gin.Context, input *NewStoryInput) (string, error)

func (*StoryAPI) DeleteStory

func (env *StoryAPI) DeleteStory(_ *gin.Context, params *CurrentStoryInput) error

func (*StoryAPI) GetStory

func (env *StoryAPI) GetStory(_ *gin.Context, params *CurrentStoryInput) (StoryInOut, error)

type StoryAnswerType

type StoryAnswerType interface {
	NewAnswer()
}

type StoryAnswersInOut

type StoryAnswersInOut struct {
	Drawlosseum DrawlosseumAnswersInOut `json:"drawlosseum,omitempty"`
	Quibly      QuiblyAnswersInOut      `json:"quibly,omitempty"`
	FibbingIt   FibbingItAnswersInOut   `json:"fibbing_it,omitempty"`
}

func (StoryAnswersInOut) Answer

func (s StoryAnswersInOut) Answer()

type StoryIDParams

type StoryIDParams struct {
	StoryID string `description:"The id for the story." example:"2b45f6c6-d8be-4d13-9fc6-2f821c925774" path:"story_id"`
}

type StoryInOut

type StoryInOut struct {
	Question string `json:"question"`
	Round    string `json:"round,omitempty"`
	Nickname string `json:"nickname,omitempty"`
	StoryAnswersInOut
}

type StoryService

type StoryService struct {
	DB database.Database
}

func (*StoryService) Add

func (s *StoryService) Add(story Story) (string, error)

func (*StoryService) Delete

func (s *StoryService) Delete(storyID string, gameName string) error

func (*StoryService) Get

func (s *StoryService) Get(storyID string, gameName string) (Story, error)

Jump to

Keyboard shortcuts

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