Documentation
¶
Index ¶
- Variables
- func AddQuestion(q Question) error
- func InitQuestion(dbPath string) (numQuestion int, err error)
- func SetLogger(l zap.Logger)
- func SetRedisPrefix(prefix string)
- func T(s string) string
- type Answer
- type Game
- type MemoryDB
- func (m *MemoryDB) ChannelConfig(chanID, key, defaultValue string) (string, error)
- func (m *MemoryDB) ChannelCount() (total int, err error)
- func (m *MemoryDB) ChannelRanking(chanID string, limit int) (ranking Rank, err error)
- func (m *MemoryDB) Channels() (channels map[string]string, err error)
- func (m *MemoryDB) GlobalConfig(key, defaultValue string) (string, error)
- func (m *MemoryDB) Init() (err error)
- func (m *MemoryDB) PlayerChannelScore(chanID string, playerID PlayerID) (PlayerScore, error)
- func (m *MemoryDB) PlayerCount() (total int, err error)
- func (m *MemoryDB) Reset() error
- type Message
- type Player
- type PlayerID
- type PlayerScore
- type QNAMessage
- type Question
- type QuestionDB
- type Rank
- type RankMessage
- type RedisDB
- func (r *RedisDB) ChannelConfig(chanID, key, defaultValue string) (config string, err error)
- func (r *RedisDB) ChannelCount() (total int, err error)
- func (r RedisDB) ChannelRanking(chanID string, limit int) (ranking Rank, err error)
- func (r *RedisDB) Channels() (channels map[string]string, err error)
- func (r *RedisDB) GlobalConfig(key, defaultValue string) (config string, err error)
- func (r *RedisDB) Init() (err error)
- func (r RedisDB) PlayerChannelScore(chanID string, playerID PlayerID) (PlayerScore, error)
- func (r *RedisDB) PlayerCount() (total int, err error)
- func (r *RedisDB) Reset() error
- type State
- type StateMessage
- type TextMessage
- type TickMessage
- type WrongAnswerMessage
Constants ¶
This section is empty.
Variables ¶
View Source
var ( RoundDuration = 90 * time.Second DelayBetweenRound = 5 * time.Second TickAfterWrongAnswer = false RoundPerGame = 3 DefaultQuestionLimit = 600 )
View Source
var ( // DB question database DefaultQuestionDB QuestionDB QuestionBucket = []byte("questions") // Add to the existing seed ExtraQuestionSeed = int64(0) )
View Source
var DefaultDB db
Functions ¶
func AddQuestion ¶
func InitQuestion ¶
func SetRedisPrefix ¶
func SetRedisPrefix(prefix string)
Types ¶
type Game ¶
type Game struct { ID int64 ChanID string ChanName string State State TotalRoundPlayed int In chan Message Out chan Message // contains filtered or unexported fields }
Game can consists of multiple round each round user will be asked question and gain points
func (*Game) CurrentQuestion ¶
type MemoryDB ¶
type MemoryDB struct { Seed int64 // contains filtered or unexported fields }
MemoryDb stores data in non persistence way
func (*MemoryDB) ChannelConfig ¶ added in v0.4.1
func (*MemoryDB) ChannelCount ¶ added in v0.4.1
func (*MemoryDB) ChannelRanking ¶
func (*MemoryDB) GlobalConfig ¶ added in v0.4.1
func (*MemoryDB) PlayerChannelScore ¶ added in v0.4.2
func (m *MemoryDB) PlayerChannelScore(chanID string, playerID PlayerID) (PlayerScore, error)
func (*MemoryDB) PlayerCount ¶ added in v0.4.1
type PlayerScore ¶ added in v0.4.2
type QNAMessage ¶
type QNAMessage struct { ChanID string Round int QuestionText string QuestionID int Answers []roundAnswers ShowUnanswered bool // reveal un-answered question (end of round) TimeLeft time.Duration }
QNAMessage represents question and answer for a round
type Question ¶
type Question struct { ID int Text string Answers []Answer // contains filtered or unexported fields }
Question for a round
func GetQuestion ¶
type QuestionDB ¶
func (*QuestionDB) AddQuestion ¶ added in v0.4.1
func (d *QuestionDB) AddQuestion(q Question) error
func (*QuestionDB) Close ¶ added in v0.4.1
func (d *QuestionDB) Close() error
func (*QuestionDB) GetQuestion ¶ added in v0.4.1
func (d *QuestionDB) GetQuestion(id string) (q Question, err error)
func (*QuestionDB) Initialize ¶ added in v0.4.1
func (d *QuestionDB) Initialize(dbPath string) error
type Rank ¶
type Rank []PlayerScore
type RedisDB ¶
type RedisDB struct {
// contains filtered or unexported fields
}
func (*RedisDB) ChannelConfig ¶ added in v0.4.1
func (*RedisDB) ChannelCount ¶ added in v0.3.3
func (RedisDB) ChannelRanking ¶
func (*RedisDB) GlobalConfig ¶ added in v0.4.1
func (RedisDB) PlayerChannelScore ¶ added in v0.4.2
func (r RedisDB) PlayerChannelScore(chanID string, playerID PlayerID) (PlayerScore, error)
func (*RedisDB) PlayerCount ¶ added in v0.3.3
type StateMessage ¶
type StateMessage struct { GameID int64 ChanID string Round int State State RoundText QNAMessage //question and answer }
StateMessage represents state change in the game
type TextMessage ¶
TextMessage represents a chat message
type TickMessage ¶
TickMessage represents time left notification
type WrongAnswerMessage ¶
type WrongAnswerMessage TickMessage
Click to show internal directories.
Click to hide internal directories.