quest

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2018 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 AnswerResult

type AnswerResult struct {
	Active   bool
	Correct  bool
	Finished bool
}

type Quest

type Quest struct {
	// contains filtered or unexported fields
}

func NewQuest

func NewQuest() Quest

func (*Quest) AddStage

func (q *Quest) AddStage(stageID string, stage Stage)

func (Quest) CheckAnswer

func (q Quest) CheckAnswer(answer string, state State) (newState *State)

func (Quest) CreateInitialState

func (q Quest) CreateInitialState() State

func (Quest) GetPicture

func (q Quest) GetPicture(state State) []byte

func (Quest) GetQuestion

func (q Quest) GetQuestion(state State) string

type QuestEngine

type QuestEngine interface {
	StartQuest(userID tgbotbase.UserID, questID string) error
	CheckAnswer(userID tgbotbase.UserID, answer string) AnswerResult
	GetCurrentQuestion(userID tgbotbase.UserID) tgbotapi.Chattable
	AddQuest(questID string, quest Quest)
}

func NewQuestEngine

func NewQuestEngine(pool tgbotbase.RedisPool, resmon ResultMonitor) QuestEngine

type QuestRecord

type QuestRecord struct {
	// contains filtered or unexported fields
}

func NewQuestRecord

func NewQuestRecord(questID string, quest Quest) *QuestRecord

type QuestStorage

type QuestStorage interface {
	StoreQuest(quest QuestRecord) error
	StoreStage(questID string, stage StageRecord) error

	LoadAll() ([]QuestRecord, error)
	LoadQuest(questID string) (*Quest, error)
	LoadStage(questID, stageID string) (*Stage, error)
}

func NewRedisQuestStorage

func NewRedisQuestStorage(pool tgbotbase.RedisPool) QuestStorage

type ResultMonitor

type ResultMonitor interface {
	QuestStarted(questID string, userID tgbotbase.UserID, t time.Time)
	QuestFinished(questID string, userID tgbotbase.UserID, t time.Time)
	QuestionAnsweredCorrectly(questID string, userID tgbotbase.UserID, t time.Time)
	QuestionAnsweredIncorrectly(questID string, userID tgbotbase.UserID, t time.Time)

	// TODO: remove this piece of code somewhere else - it is not the correct place for this code
	SendStats(questID string)
}

func NewTGResultMonitor

func NewTGResultMonitor(tgbot *tgbotbase.Bot, owners []tgbotbase.UserID, usernames *sync.Map) ResultMonitor

type Stage

type Stage struct {
	// contains filtered or unexported fields
}

func NewStage

func NewStage(question string, answers []string) Stage

func (*Stage) AddPicture

func (s *Stage) AddPicture(pic []byte)

type StageRecord

type StageRecord struct {
	// contains filtered or unexported fields
}

type State

type State struct {
	// contains filtered or unexported fields
}

func (State) GetStageID

func (s State) GetStageID() string

func (State) IsFinished

func (s State) IsFinished() bool

func (State) Next

func (s State) Next() *State

Jump to

Keyboard shortcuts

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