bombparty

package module
v0.0.0-...-a2bfd49 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 12 Imported by: 0

README

Bomb Party API

An unofficial, reverse engineered API wrapper for bomb party.

⚠ THIS PACKAGE IS A WIP ⚠

Documentation

Index

Constants

View Source
const BASE_URL = "https://jklm.fun/api"

Variables

View Source
var (
	ErrNotConnected = errors.New("NotConnected")
	ErrNoRoom       = errors.New("NoSuchRoom")
)

Functions

This section is empty.

Types

type BeginCountdown

type BeginCountdown struct {
}

TODO: Idr what the fuck this is???

type Client

type Client struct {
	// Username of the client
	Username string
	// Token used to identify the client
	Token string

	Room *Room
	// contains filtered or unexported fields
}

func NewGuestClient

func NewGuestClient(username string) *Client

func (*Client) AddEventHandler

func (c *Client) AddEventHandler(handler interface{})

func (*Client) Close

func (c *Client) Close()

func (*Client) JoinRoom

func (c *Client) JoinRoom(Code string) error

func (*Client) JoinRound

func (c *Client) JoinRound() error

func (*Client) LeaveRoom

func (c *Client) LeaveRoom() error

TODO:

func (*Client) LeaveRound

func (c *Client) LeaveRound() error

TODO:

func (*Client) MakeRoom

func (c *Client) MakeRoom(name string, public bool) error

TODO:

func (*Client) RemoveEventHandler

func (c *Client) RemoveEventHandler(event Event)

func (*Client) SetGuess

func (c *Client) SetGuess(guess string, submit bool)

type Event

type Event string

All the events that could happen

const (
	JOINED_GAME              Event = "setup"
	PLAYER_JOINED_ROUND      Event = "addPlayer"
	PLAYER_LEFT_ROUND        Event = "removePlayer"
	CHATTER_JOINED           Event = "chatterAdded"
	CHATTER_LEFT             Event = "chatterRemoved"
	COUNTDOWN                Event = "setStartTime"
	ROUND_START              Event = "round"
	ROUND_END                Event = "seating"
	TURN_CHANGE              Event = "nextTurn"
	PLAYER_INPUT             Event = "setPlayerWord"
	WORD_CORRECT             Event = "correctWord"
	WORD_FAIL                Event = "failWord"
	BONUS_ALPHABET_COMPLETED Event = "bonusAlphabetCompleted"
	KICKED                   Event = "kicked"
	CHAT                     Event = "chat"
)

TODO: Change these from numbers to stuff like JoinGame!!!

type EventBonusAlphabetComplete

type EventBonusAlphabetComplete struct {
	Player *RoundPlayer
}

type EventChat

type EventChat struct {
	Author  *Player
	Message string
}

type EventChatterJoined

type EventChatterJoined struct {
	*Player
}

type EventCountdown

type EventCountdown struct {
	ScheduledStart time.Time
}

Start the 15 second countdown

type EventJoinedGame

type EventJoinedGame struct {
	*Room
}

type EventLivesLost

type EventLivesLost struct {
	Player     *RoundPlayer
	AmountLost int
}

Used whenever a player looses lives

type EventPlayerInput

type EventPlayerInput struct {
	*RoundPlayer
}

Whenever a player updates their guess

type EventPlayerJoinedRound

type EventPlayerJoinedRound struct {
	*Player
}

type EventPlayerLeftRound

type EventPlayerLeftRound struct {
	*Player
}

type EventRoundEnd

type EventRoundEnd struct {
	Winner *RoundPlayer
}

type EventRoundStart

type EventRoundStart struct {
	*TurnChange
}

type EventSelfKicked

type EventSelfKicked struct {
	Reason string
}

type EventTurnChange

type EventTurnChange struct {
	*TurnChange
}

Whenever the turn changes

type EventWordCorrect

type EventWordCorrect struct {
	*RoundPlayer
}

type EventWordFail

type EventWordFail struct {
	Player *RoundPlayer
	Reason FailReason
}

type FailReason

type FailReason int

The reason why a guess failed. Used as an enum with constants starting with FR_

const (
	// The guess made isn't a recognised word
	FR_NOT_IN_DICTIONARY FailReason = iota
	// The guess didn't contain the prompt
	FR_NO_PROMPT
	// The guess has been used already
	FR_ALREADY_USED
)

type Player

type Player struct {
	Username string
	PFP      string
	Auth     *PlayerAuth
	IsLeader bool
	IsMod    bool
	ID       string
}

type PlayerAuth

type PlayerAuth struct {
	Service  string `json:"service"`
	Username string `json:"username"`
	ID       string `json:"id"`
}

type Room

type Room struct {
	// A WebSocket connection to a room
	WS     *websocket.Conn
	WSAuth *websocket.Conn

	// The room code. An all-caps 4 letter string.
	Code string

	// Room rules
	Rules RoomRules
	// If Round == nil, there is no active round in this room.
	Round *Round
	// LastWinner will be nil if a a roung is being played, or if there is no previous round
	LastWinner *Player

	// The prefix that is used for a connection to this room.
	// I believe it's used for load balancing.
	Server string
	// This player's ID.
	Self *Player
	// All the connected chatters. This should be used as a repository of available players.
	Chatters map[string]*Player
	// Players waiting for the next round. To add your own player, see Client.JoinRound().
	// If a round is happening, this will be an empty map. This should not be used for verifying if a round is happening.
	PlayersWaiting map[string]*Player
	// contains filtered or unexported fields
}

Room (refered to as 'milestone' by the API) describes the room the player is in.

func (*Room) SendChat

func (r *Room) SendChat(msg string)

type RoomRules

type RoomRules struct {
	// The name of the dictionary used
	Dictionary string
	// An array of letters needed to recover a life
	BonusAlphabet []string
	// The minimum turn duration, in seconds
	MinTurnDuration int
	// If PromptDifficulty < 0, then this is at most X words per prompt.
	// Otherwise, this is at least X words per prompt.
	PromptDifficulty int
	// If this many players fail, the prompt changes.
	MaxPromptAge int
	// Starting amount of lives
	StartingLives int
	// Maximum lives
	MaxLives int
}

Rules for this room

type Round

type Round struct {
	Order         []string
	CurrentPlayer *RoundPlayer
	Self          *RoundPlayer
	Prompt        string
	Players       map[string]*RoundPlayer
	PromptAge     int
	BonusAlphabet []rune
}

type RoundPlayer

type RoundPlayer struct {
	*Player
	Lives int
	Guess string
	// This will always be false when it is this player's turn.
	// The tells the client after their turn is over if they ended up with a correct guess or not.
	GuessWasRight bool
	BonusLetters  map[rune]bool
}

type TurnChange

type TurnChange struct {
	LastPlayer        *RoundPlayer
	LastPlayerWasHurt bool
	LastPrompt        string

	CurrentPlayer *RoundPlayer
	Prompt        string
}

Jump to

Keyboard shortcuts

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