Documentation ¶
Index ¶
- Constants
- Variables
- func AddPack(pack *CardPack)
- func FilterEveryoneMentions(s string) string
- func GetCommonCahButtons() []discordgo.MessageComponent
- func HumanizeError(err error) string
- func NextCardCzar(players []*Player, current int64) int64
- type CardPack
- type ErrUnknownPack
- type Game
- func (g *Game) AddPlayer(id int64, username string) bool
- func (g *Game) Created() error
- func (g *Game) HandleInteractionAdd(ic *discordgo.InteractionCreate)
- func (g *Game) HandleMessageCreate(ic *discordgo.InteractionCreate)
- func (g *Game) RemovePlayer(id int64) bool
- func (g *Game) Stop()
- func (g *Game) Tick()
- type GameManager
- func (gm *GameManager) AdminKickUser(admin, playerID int64) error
- func (gm *GameManager) CreateGame(guildID int64, channelID int64, userID int64, username string, voteMode bool, ...) (*Game, error)
- func (gm *GameManager) FindGameFromChannelOrUser(id int64) *Game
- func (gm *GameManager) HandleCahInteraction(ic *discordgo.InteractionCreate)
- func (gm *GameManager) HandleInteractionCreate(ic *discordgo.InteractionCreate)
- func (gm *GameManager) LoadGameFromSerializedState(game *Game)
- func (gm *GameManager) PlayerTryJoinGame(gameID, playerID int64, username string) error
- func (gm *GameManager) PlayerTryLeaveGame(playerID int64) error
- func (gm *GameManager) RemoveGame(gameID int64) error
- func (gm *GameManager) TryAdminRemoveGame(admin int64) error
- type GameState
- type PickedResonse
- type Player
- type PromptCard
- type ResponseCard
- type SessionProvider
- type StaticSessionProvider
Constants ¶
Variables ¶
View Source
var ( ErrGameAlreadyInChannel = errors.New("Already a active game in this channel") ErrPlayerAlreadyInGame = errors.New("Player already in a game") ErrGameNotFound = errors.New("Game not found") ErrGameFull = errors.New("Game is full") ErrNoPacks = errors.New("No packs specified") ErrNotGM = errors.New("You're not the game master") ErrStoppedAlready = errors.New("Game already stopped") ErrPlayerNotInGame = errors.New("Player not in your game") ErrAllPacksResponseOnly = errors.New("The set of packs specified are all response-only; at least one pack that has prompts is needed to start a game") )
View Source
var ( CardSelectionEmojis = []string{ "🇦", "🇧", "🇨", "🇩", "🇪", "🇫", "🇬", "🇭", "🇮", "🇯", "🇰", } JoinEmoji = "➕" LeaveEmoji = "➖" PlayPauseEmoji = "⏯" CahGameJoined = "cah_game_joined" CahGameLeft = "cah_game_left" CahGamePlayPause = "cah_game_play" CahCardSelectMenu = "cah_card_select" CahBlankCardModal = "cah_blank_card" CahTextInput = "cah_text_input" )
View Source
var (
EscaperReplacer = strings.NewReplacer("*", "\\*", "_", "\\_")
)
View Source
var Packs = make(map[string]*CardPack)
Functions ¶
func FilterEveryoneMentions ¶
func GetCommonCahButtons ¶ added in v2.7.0
func GetCommonCahButtons() []discordgo.MessageComponent
func HumanizeError ¶
func NextCardCzar ¶
Types ¶
type CardPack ¶
type CardPack struct { Name string Description string Prompts []*PromptCard Responses []ResponseCard }
type ErrUnknownPack ¶
func (*ErrUnknownPack) Error ¶
func (e *ErrUnknownPack) Error() string
type Game ¶
type Game struct { sync.RWMutex `json:"-" msgpack:"-"` // Never chaged Manager *GameManager `json:"-" msgpack:"-"` Session *discordgo.Session `json:"-" msgpack:"-"` // The main channel this game resides in, never changes MasterChannel int64 // The server the game resides in, never changes GuildID int64 // The user that created this game GameMaster int64 // The current cardzar CurrentCardCzar int64 PlayerLimit int WinLimit int VoteMode bool Packs []string Players []*Player State GameState StateEntered time.Time // The time the most recent action was taken, if we go too long without a user action we expire the game LastAction time.Time CurrentPropmpt *PromptCard LastMenuMessage int64 Responses []*PickedResonse // contains filtered or unexported fields }
func (*Game) AddPlayer ¶
AddPlayer attempts to add a player to the game, if it fails (hit the limit for example) then it returns false
func (*Game) HandleInteractionAdd ¶ added in v2.7.0
func (g *Game) HandleInteractionAdd(ic *discordgo.InteractionCreate)
func (*Game) HandleMessageCreate ¶
func (g *Game) HandleMessageCreate(ic *discordgo.InteractionCreate)
func (*Game) RemovePlayer ¶
type GameManager ¶
type GameManager struct { sync.RWMutex SessionProvider SessionProvider ActiveGames map[int64]*Game NumActiveGames int }
func NewGameManager ¶
func NewGameManager(sessionProvider SessionProvider) *GameManager
func (*GameManager) AdminKickUser ¶
func (gm *GameManager) AdminKickUser(admin, playerID int64) error
func (*GameManager) CreateGame ¶
func (*GameManager) FindGameFromChannelOrUser ¶
func (gm *GameManager) FindGameFromChannelOrUser(id int64) *Game
func (*GameManager) HandleCahInteraction ¶ added in v2.7.0
func (gm *GameManager) HandleCahInteraction(ic *discordgo.InteractionCreate)
func (*GameManager) HandleInteractionCreate ¶ added in v2.7.0
func (gm *GameManager) HandleInteractionCreate(ic *discordgo.InteractionCreate)
func (*GameManager) LoadGameFromSerializedState ¶
func (gm *GameManager) LoadGameFromSerializedState(game *Game)
func (*GameManager) PlayerTryJoinGame ¶
func (gm *GameManager) PlayerTryJoinGame(gameID, playerID int64, username string) error
func (*GameManager) PlayerTryLeaveGame ¶
func (gm *GameManager) PlayerTryLeaveGame(playerID int64) error
func (*GameManager) RemoveGame ¶
func (gm *GameManager) RemoveGame(gameID int64) error
func (*GameManager) TryAdminRemoveGame ¶
func (gm *GameManager) TryAdminRemoveGame(admin int64) error
type GameState ¶
type GameState int
const ( GameStatePreGame GameState = 0 // Before the game starts GameStatePreRoundDelay GameState = 1 // Countdown before a round starts GameStatePickingResponses GameState = 2 // Players are picking responses for the prompt card GameStatePickingWinner GameState = 3 // Cardzar is picking the winning response GameStateEnded GameState = 4 // Game is over, someone won )
type PickedResonse ¶
type PickedResonse struct { Player *Player Selections []ResponseCard }
type Player ¶
type Player struct { ID int64 Username string Cards []ResponseCard SelectedCards []int Wins int FilingBlankCard bool VotedFor int64 ReceivedVotes int Channel int64 // Wether this user is playing this round, if the user joined in the middle of a round this will be false Playing bool InGame bool Banned bool LastReactionMenu int64 // contains filtered or unexported fields }
func (*Player) MadeSelections ¶
func (p *Player) MadeSelections(currentPrompt *PromptCard) bool
func (*Player) PlayingThisRound ¶
func (*Player) PresentBoard ¶
func (p *Player) PresentBoard(session *discordgo.Session, currentPrompt *PromptCard, currentCardCzar int64)
type PromptCard ¶
func (*PromptCard) PlaceHolder ¶
func (p *PromptCard) PlaceHolder() string
func (*PromptCard) WithCards ¶
func (p *PromptCard) WithCards(cards interface{}) string
type ResponseCard ¶
type ResponseCard string
type SessionProvider ¶
type StaticSessionProvider ¶
func (*StaticSessionProvider) SessionForGuild ¶
func (sp *StaticSessionProvider) SessionForGuild(guildID int64) *discordgo.Session
Source Files ¶
Click to show internal directories.
Click to hide internal directories.