Documentation ¶
Index ¶
- Constants
- Variables
- func GetAdminHelp() []string
- func GetCommands() (map[string]func(s *discordgo.Session, i *discordgo.InteractionCreate), ...)
- func GetMemberHelp() []string
- func GetModeNames(modes map[string]*Mode) ([]string, error)
- func LoadModes() map[string]*Mode
- func LoadServers()
- func SaveServer(server *Server)
- func Start(s *discordgo.Session)
- type Bettor
- type Character
- type Config
- type LifetimeResults
- type Mode
- type Player
- type Race
- type Racer
- type Server
Constants ¶
const (
MODE = "mode"
)
const (
RACE = "race"
)
Variables ¶
var ( Servers map[string]*Server Track = strings.Repeat("• ", 20) TrackLen = int64(utf8.RuneCountInString(Track)) )
var (
Modes map[string]*Mode
)
Functions ¶
func GetAdminHelp ¶
func GetAdminHelp() []string
GetAdminHelp returns help information about the race game for administrators.
func GetCommands ¶
func GetCommands() (map[string]func(s *discordgo.Session, i *discordgo.InteractionCreate), map[string]func(s *discordgo.Session, i *discordgo.InteractionCreate), []*discordgo.ApplicationCommand)
GetCommands ret urns the component handlers, command handlers, and commands for the Race game.
func GetMemberHelp ¶
func GetMemberHelp() []string
GetMemberHelp returns help information about the race game commands for regular members.
func GetModeNames ¶
GetModeNames returns a list of available race modes.
func SaveServer ¶
func SaveServer(server *Server)
SaveServer saves the race statistics for the server.
Types ¶
type Bettor ¶
type Bettor struct { ID string `json:"_id" bson:"_id"` // Member ID of the player who placed the bet Name string `json:"name" bson:"name"` // The nickname or username of the player who placed the bet Racer *Racer `json:"racer" bson:"racer"` // The racer the bet was placed on Bet int `json:"bet" bson:"bet"` // The amount of the bet placed Winnings int `json:"winnings" bson:"winnings"` // The amount won on the race }
Bettor is a member who has placed a bet on the outcome of the race.
type Character ¶
type Character struct { Emoji string `json:"emoji" bson:"emoji"` // The icon for the race character Movement string `json:"movement" bson:"movement"` // The movement for the race character }
Character is one of the characters that may be included in a race.
type Config ¶
type Config struct { BetAmount int `json:"bet_amount" bson:"bet_amount"` // The amount a player bets on the race Currency string `json:"currency" bson:"currency"` // Currency type used on the server Mode string `json:"mode" bson:"mode"` // The name of the race mode being used PrizeMin int `json:"prize_min" bson:"prize_min"` // The minimum prize for winning racer, multiplied by the number of racers PrizeMax int `json:"prize_max" bson:"prize_max"` // The maximum prize for the winning racer, multiplied by the numbe of racers WaitForJoin time.Duration `json:"wait_for_join" bson:"wait_for_join"` // Time to wait for people to join a race WaitForBetting time.Duration `json:"wati_for_betting" bson:"wait_for_betting"` // Time to wait for people to place bets WaitBetweenRaces time.Duration `json:"wait_between_races" bson:"wait_between_races"` // Time to wait between races MinRacers int `json:"min_racers" bson:"min_racers"` // Minimum number of racers required, including the bot MaxRacers int `json:"max_racers" bson:"max_racers"` // Maximum number of racers allowed, including the bot }
Config is the race configuration for a given guild/server.
type LifetimeResults ¶
type LifetimeResults struct { Win int `json:"win" bson:"win"` // Number of races a player came in first Place int `json:"place" bson:"place"` // Number of races a player came in second Show int `json:"show" bson:"show"` // Number of races a player came in third Losses int `json:"loses" bson:"loses"` // Number of races a player came in fourth or lower Earnings int `json:"earnings" bson:"earnings"` // Lifetime earnings for the player in races BetsPlaced int `json:"bets_placed" bson:"bets_placed"` // Number of bets a player has placed on races BetsWon int `json:"bets_won" bson:"bets_won"` // Number of bets a player has won BetEarnings int `json:"bet_earnings" bson:"bet_earnings"` // Lifetime earnings from placing bets }
LifetimeResults keeps track of the lifetime results for a given player.
type Mode ¶
type Mode struct { ID string `json:"_id" bson:"_id"` // Name of the mode (e.g., "clash") Beginning string `json:"beginning" bson:"beginning"` // The character or icon for the left-hand side of the race Characters []*Character `json:"characters" bson:"characters"` // The list of characters from which a racer is randomly assigned Ending string `json:"ending" bson:"ending"` // The character or icon for the right-hand side of the race }
Mode represents the type of characters and symbols used in the race.
type Player ¶
type Player struct { ID string `json:"_id" bson:"_id"` // ID of the player Name string `json:"name" bson:"name"` // Nickname of the user, or username if the member doesn't have a nickname NumRaces int `json:"num_races" bson:"num_races"` // Number of races the member has entered Results LifetimeResults `json:"results" bson:"results"` // Results of all previous races for the member }
Player is a member of the guild/server who partipates in races or bets on races.
type Race ¶
type Race struct { Bets []*Bettor `json:"bets" bson:"bets"` // Bets placed by members on the race Racers []*Racer `json:"racers" bson:"racers"` // Members who have entered the race Planned bool `json:"planned" bson:"planned"` // Waiting for members to join the race Started bool `json:"started" bson:"started"` // The race is now in progress Ended bool `json:"ended" bson:"ended"` // The race has ended StartTime time.Time `json:"start_time" bson:"start_time"` // Time the race will begin BetEndTime time.Time `json:"bet_end_time" bson:"bet_end_time"` // The time betting will close Interaction *discordgo.InteractionCreate `json:"-" bson:"-"` // Interaction for the initial race start message }
Race represents the race data for a given guild/server.
type Racer ¶
type Racer struct { Player *Player `json:"player" bson:"player"` // Player who is racing Character *Character `json:"character" bson:"character"` // Randomly selected character for the race LastMove int64 `json:"last_move" bson:"last_move"` // Distance moved on the last move LastPosition int64 `json:"last_position" bson:"last_position"` // Initialize to TrackLen Position int64 `json:"position" bson:"position"` // Initialize to TrackLen Speed float64 `json:"speed" bson:"speed"` // Calculate at end to sort the racers Current string `json:"current" bson:"current"` // Current position on the track Turn int64 `json:"turn" bson:"turn"` // How many turns it took to move from the starting position to 0 Prize int `json:"prize" bson:"prize"` // The amount of credits earned in the race }
Racer is a player who is entered into a race.
type Server ¶
type Server struct { ID string `json:"_id" bson:"_id"` // Guild ID Config *Config `json:"config" bson:"config"` // Server-specific configuration GamesPlayed int `json:"games_played" bson:"games_played"` // Number of race games played on the server Players map[string]*Player `json:"players" bson:"players"` // All members who have entered a race on the server LastRaceEnded time.Time `json:"last_race_ended" bson:"last_race_ended"` // Time the last race ended Race *Race `json:"-" bson:"-"` // The current race (don't save to the store) // contains filtered or unexported fields }
Server represents a guild/server where the Race game is played
func NewServer ¶
NewServer creates a new server with the default values set and stores it in the file store.