game

package
v0.0.0-...-fb119ec Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchDictionary

func FetchDictionary(finderUrl string, query bson.M, limit int) (german.Dictionary, int, error)

func FetchWords

func FetchWords(finderUrl string, query bson.M, limit int) ([]entity.Word, int, error)

func Main

func Main(name, version, defaultPort string, gameServer GameServer)

func SaveAnswer

func SaveAnswer(id string, wordIds, right []string, mgoCollection *mgo.Collection) error

func ScoreWords

func ScoreWords(scorerUrl string, score int, ids []string)

Types

type Game

type Game interface {
	GetQuestion() string
	GetId() string
	SetDebugQuery(bool, *bson.M, *german.Dictionary, entity.Word, *bson.M)
	SetDebugResult(bool, []string, []entity.Meaning, []entity.Meaning)
}

type GameAnswer

type GameAnswer struct {
	GameDebug
	Question string `bson:"question" json:"question"`
	Id       string `json:"id,omitempty" bson:"id,omitempty"`
}

func NewGameAnswer

func NewGameAnswer() GameAnswer

func (GameAnswer) GetId

func (g GameAnswer) GetId() string

func (GameAnswer) GetQuestion

func (g GameAnswer) GetQuestion() string

type GameDebug

type GameDebug struct {
	Error      string             `json:"error,omitempty" bson:"error,omitempty"`
	Query      *bson.M            `json:"query,omitempty" bson:"query,omitempty"`
	Dictionary *german.Dictionary `json:"dictionary,omitempty" bson:"dictionary,omitempty"`
	Word       entity.Word        `json:"word,omitempty" bson:"word,omitempty"`
	Options    *bson.M            `json:"options,omitempty" bson:"options,omitempty"`
	Right      []string           `json:"right,omitempty" bson:"right,omitempty"`
	English    []entity.Meaning   `json:"english,omitempty" bson:",omitempty"`
	Third      []entity.Meaning   `json:"third,omitempty" bson:"third,omitempty"`
}

func (*GameDebug) SetDebugQuery

func (g *GameDebug) SetDebugQuery(debug bool, query *bson.M, dictionary *german.Dictionary, word entity.Word, options *bson.M)

func (*GameDebug) SetDebugResult

func (g *GameDebug) SetDebugResult(debug bool, right []string, english []entity.Meaning, third []entity.Meaning)

type GameOption

type GameOption struct {
	GameDebug
	Question string `json:"question" bson:"question"`
	Option1  string `json:"option1,omitempty" bson:"option1,omitempty"`
	Option2  string `json:"option2,omitempty" bson:"option2,omitempty"`
	Option3  string `json:"option3,omitempty" bson:"option3,omitempty"`
	Option4  string `json:"option4,omitempty" bson:"option4,omitempty"`
	Id       string `json:"id,omitempty" bson:"id,omitempty"`
}

func NewGameOption

func NewGameOption() GameOption

func (GameOption) GetId

func (g GameOption) GetId() string

func (GameOption) GetQuestion

func (g GameOption) GetQuestion() string

type GameServer

type GameServer interface {
	MakeGameHandle(finderUrl string, mgoCollection *mgo.Collection, isDebug bool) func(*gin.Context)
	MakeCheckAnswerHandle(finderUrl, scorerUrl string, mgoCollection *mgo.Collection, isDebug bool) func(*gin.Context)
}

type Tracker

type Tracker struct {
	Id        string    `json:"_id,omitempty" bson:"_id,omitempty"`
	WordIds   []string  `json:"wordIds,omitempty" bson:"wordIds,omitempty"`
	Right     []string  `json:"right,omitempty" bson:"right,omitempty"`
	CreatedAt time.Time `json:"createdAt,omitempty" bson:"createdAt,omitempty"`
}

func FindAnswer

func FindAnswer(id string, mgoCollection *mgo.Collection) (Tracker, error)

Jump to

Keyboard shortcuts

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