Version: v0.0.6 Latest Latest

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

Go to latest
Published: Jul 2, 2019 License: MIT Imports: 18 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Challenge

type Challenge struct {
	// UsersShown is the list of all IDs shown
	UsersShown []string
	// RightAnswerIndex holds the index in `UsersShown` that is the
	// person we're looking for.
	RightAnswerIndex int
	// Replies holds the first replies for each user ID, only first
	// response is accounted for.
	Replies map[string]int
	// FirstCorrectReply holds the user ID of the first user that
	// replied correctly.
	FirstCorrectReply string
	// ImageURL is the image URL to show
	ImageURL string

Challenge is one shot of images being shown, and replies being gathered for 10 seconds before declaring a winner.

func (*Challenge) BuildImage

func (c *Challenge) BuildImage(profileURLs []string) ([]byte, error)

BuildImage builds a new image with 4 square images and overlays numbers on top (translucent). It sends to S3 and returns the public URL.

func (*Challenge) HandleUserReply

func (c *Challenge) HandleUserReply(userID string, index int)

func (*Challenge) PickUsers

func (c *Challenge) PickUsers(users map[string]*User)

PickUsers set `UsersShown` and `RightAnswerIndex`

type Faceoff

type Faceoff struct {
	// contains filtered or unexported fields

Faceoff contains configuration for running faceoff

func (*Faceoff) ComputeUserScores

func (p *Faceoff) ComputeUserScores()

func (*Faceoff) InitPlugin

func (p *Faceoff) InitPlugin(bot *bawt.Bot)

InitPlugin establishes the regex and listeners

func (*Faceoff) UpdateUsersWithChallengeResults

func (p *Faceoff) UpdateUsersWithChallengeResults(c *Challenge)

type Game

type Game struct {
	// Channel in which the game is running
	Faceoff         *Faceoff
	OriginalMessage *bawt.Message
	Channel         *bawt.Channel
	Started         time.Time
	GameCount       int // number of games we did
	Challenges      []*Challenge

Game is a run of multiple challenges in channel

func (*Game) Launch

func (g *Game) Launch()

type User

type User struct {
	// `bawt.GetUser` ID
	ID string
	// Count of good answers, fastest or not.
	RightAnswers int
	// Count of bad answers,
	WrongAnswers int
	// Number of times the user was right and was the fastest.
	Fastest int

	// FoundUsers is a map to be used for completeness score, in next
	// version.
	FoundUsers map[string]bool

	// Number of times this user was looked for
	LookedFor int
	// Number of times this user was shown but wasn't the person we looked for.
	Shown int
	// Number of times this user was found
	Found int

	// PerformanceScore is a score composed of accuracy and speed
	// (successRate and fastest), relatively to others.
	PerformanceScore int
	// RankPosition is the position of this user relatively to other
	// users.  It is possible that several users are at the same
	// ranking position, if they have the same score.
	RankPosition int
	// RankAgainst is the total number of players
	RankAgainst int

	// Whether this users is excluded from the game.
	Excluded bool

func (*User) ScoreLine

func (user *User) ScoreLine() (out string)

func (*User) SuccessRate

func (u *User) SuccessRate() int

SuccessRate returns a percentage of the time the user was right, as compared to his bad answers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL