heist

package
v0.0.0-...-82a33b0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Overview

commands contains the list of commands and messages sent to Discord, or commands processed when received from Discord.

Index

Constants

View Source
const (
	FREE        = "Free"
	DEAD        = "Dead"
	APPREHENDED = "Apprehended"
)
View Source
const (
	HEIST = "heist"
)
View Source
const (
	TARGET = "target"
)
View Source
const (
	THEME = "theme"
)

Variables

View Source
var (
	ErrConfigNotFound = errors.New("configuration file not found")
	ErrNotAllowed     = errors.New("user is not allowed to perform command")
	ErrNoHeist        = errors.New("no heist could be found")
)

Functions

func GetAdminHelp

func GetAdminHelp() []string

GetAdminHelp returns help information about the heist bot for administrators.

func GetCommands

GetCommands ret urns the component handlers, command handlers, and commands for the Heist bot.

func GetMemberHelp

func GetMemberHelp() []string

GetMemberHelp returns help information about the heist bot commands for regular members.

func GetThemeNames

func GetThemeNames(map[string]*Theme) ([]string, error)

GetThemeNames returns a list of available themes.

func LoadServers

func LoadServers() map[string]*Server

LoadServers loads all the heist servers from the store.

func LoadTargets

func LoadTargets() map[string]*Targets

LoadTargets loads the targets that may be used by the heist bot.

func LoadThemes

func LoadThemes() map[string]*Theme

LoadThemes loads the themes that may be used by the heist bot.

func Start

func Start(s *discordgo.Session)

Start initializes anything needed by the heist bot.

Types

type BadMessage

type BadMessage struct {
	Message string `json:"message" bson:"message"`
	Result  string `json:"result" bson:"result"`
}

type Config

type Config struct {
	AlertTime    time.Time     `json:"alert_time" bson:"alert_time"`
	BailBase     int64         `json:"bail_base" bson:"bail_base"`
	CrewOutput   string        `json:"crew_output" bson:"crew_output"`
	DeathTimer   time.Duration `json:"death_timer" bson:"death_timer"`
	Hardcore     bool          `json:"hardcore" bson:"hardcore"`
	HeistCost    int64         `json:"heist_cost" bson:"heist_cost"`
	PoliceAlert  time.Duration `json:"police_alert" bson:"police_alert"`
	SentenceBase time.Duration `json:"sentence_base" bson:"sentence_base"`
	Theme        string        `json:"theme" bson:"theme"`
	Targets      string        `json:"targets" bson:"targets"`
	WaitTime     time.Duration `json:"wait_time" bson:"wait_time"`
}

Config is the configuration data for a given server.

func (*Config) String

func (c *Config) String() string

String returns a string representation of the server configuration.

type CriminalLevel

type CriminalLevel int
const (
	Greenhorn CriminalLevel = 0
	Renegade  CriminalLevel = 1
	Veteran   CriminalLevel = 10
	Commander CriminalLevel = 25
	WarChief  CriminalLevel = 50
	Legend    CriminalLevel = 75
	Immortal  CriminalLevel = 100
)

func (CriminalLevel) String

func (cl CriminalLevel) String() string

String returns a string representation of the criminal level.

type GoodMessage

type GoodMessage struct {
	Message string `json:"message" bson:"message"`
	Amount  int    `json:"amount" bson:"amount"`
}

type Heist

type Heist struct {
	Planner     string                       `json:"planner" bson:"planner"`
	Crew        []string                     `json:"crew" bson:"crew"`
	Planned     bool                         `json:"planned" bson:"planned"`
	Started     bool                         `json:"started" bson:"started"`
	MessageID   string                       `json:"message_id" bson:"message_id"`
	StartTime   time.Time                    `json:"start_time" bson:"start_time"`
	Interaction *discordgo.InteractionCreate `json:"-" bson:"-"`
	Mutex       sync.Mutex                   `json:"-" bson:"-"`
}

Heist is the data for a heist that is either planned or being executed.

func NewHeist

func NewHeist(server *Server, planner *Player) *Heist

NewHeist creates a new default heist.

type HeistMemberResult

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

HeistMemberResult is the result for a single player who is a member of the heist crew.

type HeistResult

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

HeistResult is the result of a heist.

type Player

type Player struct {
	ID            string        `json:"_id" bson:"_id"`
	BailCost      int64         `json:"bail_cost" bson:"bail_cost"`
	CriminalLevel CriminalLevel `json:"criminal_level" bson:"criminal_level"`
	DeathTimer    time.Time     `json:"death_timer" bson:"death_timer"`
	Deaths        int64         `json:"deaths" bson:"deaths"`
	JailCounter   int64         `json:"jail_counter" bson:"jail"`
	Name          string        `json:"name" bson:"name"`
	OOB           bool          `json:"oob" bson:"oob"`
	Sentence      time.Duration `json:"sentence" bson:"sentence"`
	Spree         int64         `json:"spree" bson:"spree"`
	Status        string        `json:"status" bson:"status"`
	JailTimer     time.Time     `json:"time_served" bson:"time_served"`
	TotalJail     int64         `json:"total_jail" bson:"total_jail"`
}

Player is a specific player of the heist game on a given server.

func NewPlayer

func NewPlayer(id string, username string, nickname string) *Player

NewPlayer creates a new player. It is typically called when a player first plans or joins a heist.

func (*Player) ClearJailAndDeathStatus

func (p *Player) ClearJailAndDeathStatus()

ClearJailAndDeathStatus removes the jail and death times. This is used if the player is no longer in jail or has been revived.

func (*Player) RemainingDeathTime

func (p *Player) RemainingDeathTime() time.Duration

RemainingDeathTime returns the amount of time before the player can be resurected.

func (*Player) RemainingJailTime

func (p *Player) RemainingJailTime() time.Duration

RemainingJailTime returns the amount of time remaining on the player's sentence has been served.

func (*Player) Reset

func (p *Player) Reset()

Reset clears the jain and death settings for a player.

func (*Player) String

func (p *Player) String() string

String returns a string representation of the player.

type Server

type Server struct {
	ID      string             `json:"_id" bson:"_id"`
	Config  Config             `json:"config" bson:"config"`
	Players map[string]*Player `json:"players" bson:"players"`
	Heist   *Heist             `json:"-" bson:"-"`
	Targets map[string]*Target `json:"targets" bson:"targets"`
	Mutex   sync.Mutex         `json:"-" bson:"-"`
}

Server contains the data for a given server with the specific ID.

func GetServer

func GetServer(servers map[string]*Server, guildID string) *Server

GetServer returns the server for the guild. If the server does not already exist, one is created.

func NewServer

func NewServer(guildID string) *Server

NewServer creates a new server with the specified ID. It is typically called when the first call from a server is made to the heist bot.

func (*Server) GetPlayer

func (s *Server) GetPlayer(id string, username string, nickname string) *Player

GetPlayer returns the player on the server. If the player does not already exist, one is created.

func (*Server) String

func (s *Server) String() string

String returns a string representation of the server.

type Target

type Target struct {
	ID       string  `json:"_id" bson:"_id"`
	CrewSize int64   `json:"crew" bson:"crew"`
	Success  float64 `json:"success" bson:"success"`
	Vault    int64   `json:"vault" bson:"vault"`
	VaultMax int64   `json:"vault_max" bson:"vault_max"`
}

Target is a target of a heist.

func NewTarget

func NewTarget(id string, maxCrewSize int64, success float64, vaultCurrent int64, maxVault int64) *Target

NewTarget creates a new target for a heist

func (*Target) String

func (t *Target) String() string

String returns a string representation of the target.

type Targets

type Targets struct {
	ID      string   `json:"_id" bson:"_id"`
	Targets []Target `json:"targets" bson:"targets"`
}

Targets is the set of targets for a given theme

func GetTargetSet

func GetTargetSet(targetName string) (*Targets, error)

GetTargetSet gets the specified target and returns.

func GetTargets

func GetTargets(targetName string) (*Targets, error)

GetTargets gets the specified list of targets and returns.

func (*Targets) String

func (t *Targets) String() string

String returns a string representation of the targets.

type Theme

type Theme struct {
	ID       string        `json:"_id" bson:"_id"`
	Good     []GoodMessage `json:"good"`
	Bad      []BadMessage  `json:"bad"`
	Jail     string        `json:"jail" bson:"jail"`
	OOB      string        `json:"oob" bson:"oob"`
	Police   string        `json:"police" bson:"police"`
	Bail     string        `json:"bail" bson:"bail"`
	Crew     string        `json:"crew" bson:"crew"`
	Sentence string        `json:"sentence" bson:"sentence"`
	Heist    string        `json:"heist" bson:"heist"`
	Vault    string        `json:"vault" bson:"vault"`
}

Theme is a heist theme.

func GetTheme

func GetTheme(themeName string) (*Theme, error)

GetTheme gets the specified theme and returns.

func (*Theme) String

func (t *Theme) String() string

String returns a string representation of the theme.

Jump to

Keyboard shortcuts

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