Documentation ¶
Index ¶
- Constants
- func MakeUnboundedChannel[K any]() (chan<- *K, <-chan *K)
- type Command
- type Connection
- type ConnectionDetails
- type ConnectionEvent
- type ConnectionEventType
- type ConnectionSettings
- type ConnectionStatus
- type DashbackFix
- type DolphinConnection
- func (c *DolphinConnection) Connect(ip string, port uint16) (<-chan *ConnectionEvent, error)
- func (c *DolphinConnection) Disconnect()
- func (c *DolphinConnection) GetDetails() ConnectionDetails
- func (c *DolphinConnection) GetSettings() ConnectionSettings
- func (c *DolphinConnection) GetStatus() ConnectionStatus
- type DolphinMessage
- type DolphinMessageType
- type EventPayloadsPayload
- type FrameBookendPayload
- type FrameEntry
- type FrameStartPayload
- type FrameUpdate
- type FrameUpdatePayload
- type FrameUpdateType
- type FrameUpdates
- type GameEndMethod
- type GameEndPayload
- type GameInfo
- type GameInfoBlock
- type GameStartPayload
- type GeckoListPayload
- type HurtboxCollisionState
- type InputType
- type ItemSpawnBehavior
- type ItemUpdatePayload
- type LCancelStatus
- type Language
- type MessageSplitterPayload
- type Metadata
- type Names
- type ParserEvent
- type PlayerInfo
- type PlayerMetadata
- type PlayerType
- type Port
- type PostFrameUpdatePayload
- type PreFrameUpdatePayload
- type Rollbacks
- type ShieldDropFix
- type SlpCalculator
- type SlpEvent
- type SlpEventResult
- type SlpGame
- func (g *SlpGame) AddCalculator(c SlpCalculator)
- func (g *SlpGame) Close()
- func (g *SlpGame) GetFrames() (map[int32]FrameEntry, error)
- func (g *SlpGame) GetGameEnd() (*GameEndPayload, error)
- func (g *SlpGame) GetGameInfo() (*GameInfo, error)
- func (g *SlpGame) GetLatestFrame() (*FrameEntry, error)
- func (g *SlpGame) GetMetadata() (*Metadata, error)
- func (g *SlpGame) GetRollbackFrames() (map[int32][]FrameEntry, error)
- func (g *SlpGame) RemoveAllCalculators()
- func (g *SlpGame) RemoveCalculator(c SlpCalculator)
- type SlpParser
- func (p *SlpParser) AddHandler(event ParserEvent, handler chan interface{})
- func (p *SlpParser) GetGameInfo() (*GameInfo, bool)
- func (p *SlpParser) GetLatestFrame() *FrameEntry
- func (p *SlpParser) GetPlayableFrameCount() int32
- func (p *SlpParser) ParseReplay(eventResults <-chan *SlpEventResult) error
- func (p *SlpParser) RemoveAllHandlers(event ParserEvent)
- func (p *SlpParser) RemoveHandler(event ParserEvent, toRemove chan interface{})
- func (p *SlpParser) Reset()
- func (p *SlpParser) Trigger(event ParserEvent, payload interface{})
- type SlpParserOpts
- type SlpReader
- type SlpSource
- type TeamID
- type TeamShade
Constants ¶
const ( Connect ConnectionEventType = "connect" Message = "message" Handshake = "message" StatusChange = "statusChange" Data = "data" Error = "error" )
ConnectionEvents
const ( Default Port = 51441 Legacy = 666 RelayStart = 53741 )
Ports
const ( ConnectReply DolphinMessageType = "connect_reply" ConnectRequest = "connect_request" MenuEvent = "menu_event" GameEvent = "game_event" StartGame = "start_game" EndGame = "end_game" )
DolphinMessageTypes
const ( ItemsVeryLow = iota ItemsLow ItemsMedium ItemsHigh ItemsVeryHigh Items5 Items6 Items7 Items8 ItemsOff ItemSpawnBehavior = -1 )
ItemSpawnBehaviors
const ( Unresolved GameEndMethod = 0 Time = 1 Game = 2 Resolved = 3 NoContest = 7 )
GameEndMethods
const MaxPeers = 32
const MaxRollbackFrames = 7
Variables ¶
This section is empty.
Functions ¶
func MakeUnboundedChannel ¶
func MakeUnboundedChannel[K any]() (chan<- *K, <-chan *K)
Types ¶
type Connection ¶
type Connection interface { GetStatus() ConnectionStatus GetSettings() ConnectionSettings GetDetails() ConnectionDetails Connect(ip string, port uint16) error Disconnect() }
type ConnectionDetails ¶
type ConnectionEvent ¶
type ConnectionEvent struct { Type ConnectionEventType Payload interface{} }
type ConnectionEventType ¶
type ConnectionEventType string
ConnectionEventType enumerates the possible connection events emitted by a connection
type ConnectionSettings ¶
type ConnectionStatus ¶
type ConnectionStatus uint8
ConnectionStatus enumerates the possible states of a connection
const ( Disconnected ConnectionStatus = iota Connecting Connected ReconnectWait )
ConnectionStatuses
type DashbackFix ¶
type DashbackFix uint32
DashbackFix enumerates the controller fixes for dashback.
const ( DBOff DashbackFix = iota DBUCF DBDween )
DashbackFixes
type DolphinConnection ¶
type DolphinConnection struct { IpAddress string Port uint16 ConnectionStatus ConnectionStatus GameCursor int Nickname string Version string Peer enet.ENetPeer // contains filtered or unexported fields }
DolphinConnection represents a connection to an instance of Dolphin.
func NewDolphinConnection ¶
func NewDolphinConnection() *DolphinConnection
NewDolphinConnection returns a new DolphinConnection instance.
func (*DolphinConnection) Connect ¶
func (c *DolphinConnection) Connect(ip string, port uint16) (<-chan *ConnectionEvent, error)
Connect connects to a Dolphin instance on the given IP and port.
func (*DolphinConnection) Disconnect ¶
func (c *DolphinConnection) Disconnect()
func (*DolphinConnection) GetDetails ¶
func (c *DolphinConnection) GetDetails() ConnectionDetails
GetDetails gets the current details of the DolphinConnection.
func (*DolphinConnection) GetSettings ¶
func (c *DolphinConnection) GetSettings() ConnectionSettings
GetSettings gets the current settings of the DolphinConnection.
func (*DolphinConnection) GetStatus ¶
func (c *DolphinConnection) GetStatus() ConnectionStatus
GetStatus gets the current state of the DolphinConnection.
type DolphinMessage ¶
type DolphinMessage struct { Type DolphinMessageType `json:"type"` Nick string `json:"nick,omitempty"` Version string `json:"version,omitempty"` Cursor int `json:"cursor"` NextCursor int `json:"next_cursor,omitempty"` Payload string `json:"payload,omitempty"` }
DolphinMessage represents a message sent from Dolphin to a client.
type DolphinMessageType ¶
type DolphinMessageType string
DolphinMessageType enumerates the types of messages Dolphin sends to a client.
type EventPayloadsPayload ¶
EventPayloadsPayload represents the EventPayloads Slippi event.
type FrameBookendPayload ¶
FrameBookendPayload represents the FrameBookend Slippi event.
type FrameEntry ¶
type FrameEntry struct { Players map[uint8]FrameUpdates Followers map[uint8]FrameUpdates Items []ItemUpdatePayload IsTransferComplete bool }
A FrameEntry contains all relevant updates from a given frame.
type FrameStartPayload ¶
FrameStartPayload represents the FrameStart Slippi event.
type FrameUpdate ¶
type FrameUpdate struct { FrameNumber int32 PlayerIndex uint8 IsFollower bool ActionStateID uint16 XPosition float32 YPosition float32 FacingDirection float32 Percent float32 }
FrameUpdate contains fields generic to pre- and post-frame update Slippi events.
type FrameUpdatePayload ¶
type FrameUpdatePayload interface {
GetFrameUpdate() FrameUpdate
}
The FrameUpdatePayload is the interface that abstract pre- and post-frame updates to their shared FrameUpdate field.
type FrameUpdateType ¶
type FrameUpdateType string
FrameUpdateType enumerates the types of frame updates.
const ( Pre FrameUpdateType = "pre" Post = "post" )
FrameUpdateTypes
type FrameUpdates ¶
type FrameUpdates struct { Pre *PreFrameUpdatePayload Post *PostFrameUpdatePayload }
FrameUpdates holds pre- and post-frame updates.
type GameEndMethod ¶
type GameEndMethod uint8
GameEndMethod enumerates the game end methods in Melee.
type GameEndPayload ¶
type GameEndPayload struct { GameEndMethod GameEndMethod LRASInitiator int8 }
GameEndPayload represents the GameEnd Slippi event.
type GameInfo ¶
type GameInfo struct { Version semver.Version Teams bool PAL bool Stage uint16 Players []PlayerInfo MajorScene uint8 MinorScene uint8 }
GameInfo contains the general information about a game of Melee.
type GameInfoBlock ¶
type GameInfoBlock struct { GameBitfield1 uint8 GameBitfield2 uint8 GameBitfield3 uint8 GameBitfield4 uint8 BombRain uint8 IsTeams bool ItemSpawnBehavior ItemSpawnBehavior SelfDestructScoreValue int8 Stage uint16 GameTimer uint32 ItemSpawnBitfield1 uint8 ItemSpawnBitfield2 uint8 ItemSpawnBitfield3 uint8 ItemSpawnBitfield4 uint8 ItemSpawnBitfield5 uint8 DamageRatio float32 }
GameInfoBlock contains the Melee game info block.
type GameStartPayload ¶
type GameStartPayload struct { Version semver.Version GameInfoBlock GameInfoBlock Players [4]PlayerInfo RandomSeed uint32 PAL bool FrozenPS bool MajorScene uint8 MinorScene uint8 LanguageOption Language }
GameStartPayload represents the GameStart Slippi event.
type GeckoListPayload ¶
type GeckoListPayload struct {
GeckoCodes []byte
}
GeckoListPayload represents the GeckoList Slippi event.
type HurtboxCollisionState ¶
type HurtboxCollisionState uint8
HurtboxCollisionState enumerates possible hurtbox collision states.
const ( Vulnerable HurtboxCollisionState = iota Invulnerable Intangible )
HurtboxCollisionStates
type ItemSpawnBehavior ¶
type ItemSpawnBehavior int8
ItemSpawnBehavior enumerates item spawn frequencies.
type ItemUpdatePayload ¶
type ItemUpdatePayload struct { FrameNumber int32 TypeID uint16 State uint8 FacingDirection float32 XVelocity float32 YVelocity float32 XPosition float32 YPosition float32 DamageTaken uint16 ExpirationTimer float32 SpawnID uint32 SamusMissileType uint8 PeachTurnipFace uint8 IsLaunched uint8 ChargedPower uint8 Owner int8 }
ItemUpdatePayload represents the ItemUpdate Slippi event.
type LCancelStatus ¶
type LCancelStatus uint8
LCancelStatus enumerates possible L-Cancel statuses.
const ( None LCancelStatus = iota Successful Unsuccessful )
LCancelStatuses
type MessageSplitterPayload ¶
type MessageSplitterPayload struct { Data [512]uint8 DataLength uint16 InternalCommand uint8 LastMessage bool }
MessageSplitterPayload represents the MessageSplitter Slippi event.
type Metadata ¶
type Metadata struct { StartAt string `ubjson:"startAt"` LastFrame int32 `ubjson:"lastFrame"` Players map[string]PlayerMetadata `ubjson:"players"` PlayedOn string `ubjson:"playedOn"` ConsoleNick string `ubjson:"consoleNick"` }
A Metadata contains metadata about a Slippi game.
type ParserEvent ¶
type ParserEvent uint8
ParserEvent enumerates events sent by a SlpParser
const ( Started ParserEvent = iota Frame FinalizedFrame RollbackFrame Ended )
ParserEvents
type PlayerInfo ¶
type PlayerInfo struct { Index uint8 Port uint8 CharacterID uint8 PlayerType PlayerType StockStartCount uint8 CostumeIndex uint8 TeamShade TeamShade Handicap uint8 TeamID TeamID PlayerBitfield uint8 CPULevel uint8 OffenseRatio float32 DefenseRatio float32 ModelScale float32 DashbackFix DashbackFix ShieldDropFix ShieldDropFix Nametag string DisplayName string ConnectCode string SlippiUID string }
PlayerInfo contains information about a player in Melee.
type PlayerMetadata ¶
type PlayerMetadata struct { Characters map[string]int32 `ubjson:"characters"` Names Names `ubjson:"names"` }
A PlayerMetadata contains metadata about a player.
type PlayerType ¶
type PlayerType uint8
PlayerType enumerates the different player types in Melee.
const ( Human PlayerType = iota CPU Demo Empty )
PlayerTypes
type PostFrameUpdatePayload ¶
type PostFrameUpdatePayload struct { FrameUpdate InternalCharacterID uint8 ShieldSize float32 LastHittingAttackID uint8 CurrentComboCount uint8 LastHitBy uint8 StocksRemaining uint8 ActionStateFrameCounter float32 StateBitFlags1 uint8 StateBitFlags2 uint8 StateBitFlags3 uint8 StateBitFlags4 uint8 StateBitFlags5 uint8 MiscAS float32 Airborne bool LastGroundID uint16 JumpsRemaining uint8 LCancelStatus LCancelStatus HurtboxCollisionState HurtboxCollisionState SelfInducedAirXSpeed float32 SelfInducedYSpeed float32 AttackBasedXSpeed float32 AttackBasedYSpeed float32 SelfInducedGroundXSpeed float32 HitlagFramesRemaining float32 AnimationIndex uint32 }
PostFrameUpdatePayload represents the PostFrameUpdate Slippi event.
func (PostFrameUpdatePayload) GetFrameUpdate ¶
func (u PostFrameUpdatePayload) GetFrameUpdate() FrameUpdate
GetFrameUpdate implements the FrameUpdatePayload interface.
type PreFrameUpdatePayload ¶
type PreFrameUpdatePayload struct { FrameUpdate RandomSeed uint32 JoystickX float32 JoystickY float32 CStickX float32 CStickY float32 Trigger float32 ProcessedButtons uint32 PhysicalButtons uint16 PhysicalLTrigger float32 PhysicalRTrigger float32 XAnalogUCF uint8 }
PreFrameUpdatePayload represents the PreFrameUpdate Slippi event.
func (PreFrameUpdatePayload) GetFrameUpdate ¶
func (u PreFrameUpdatePayload) GetFrameUpdate() FrameUpdate
GetFrameUpdate implements the FrameUpdatePayload interface.
type Rollbacks ¶
type Rollbacks struct { Frames map[int32][]FrameEntry Count int Lengths []int // contains filtered or unexported fields }
Rollbacks tracks the rollbacks within a replay.
type ShieldDropFix ¶
type ShieldDropFix uint32
ShieldDropFix enumerates the controller fixes for shield drops.
const ( SDFixOff ShieldDropFix = iota SDUCF SDDween )
ShieldDropFixes
type SlpCalculator ¶
type SlpCalculator interface {
// contains filtered or unexported methods
}
SlpCalculator is the interface to represent calculators
type SlpEvent ¶
type SlpEvent struct { Command Command Payload interface{} }
SlpEvent contains the command of an event and its associated data.
type SlpEventResult ¶
type SlpGame ¶
type SlpGame struct {
// contains filtered or unexported fields
}
A SlpGame contains information about a Slippi game.
func NewSlpGameFromBytes ¶
func NewSlpGameFromBytes(b []byte, calculators []SlpCalculator) (*SlpGame, error)
NewSlpGameFromBytes creates a new SlpGame from the provided bytes.
func NewSlpGameFromFile ¶
func NewSlpGameFromFile(f *os.File, calculators []SlpCalculator) (*SlpGame, error)
NewSlpGameFromFile creates a new SlpGame from the provided file.
func (*SlpGame) AddCalculator ¶
func (g *SlpGame) AddCalculator(c SlpCalculator)
AddCalculator adds a calculator to the SlpGame.
func (*SlpGame) GetFrames ¶
func (g *SlpGame) GetFrames() (map[int32]FrameEntry, error)
GetFrames gets the frames from the SlpGame.
func (*SlpGame) GetGameEnd ¶
func (g *SlpGame) GetGameEnd() (*GameEndPayload, error)
GetGameEnd gets the game end event from the SlpGame.
func (*SlpGame) GetGameInfo ¶
GetGameInfo gets the game info of the SlpGame.
func (*SlpGame) GetLatestFrame ¶
func (g *SlpGame) GetLatestFrame() (*FrameEntry, error)
GetLatestFrame gets the latest frame in the SlpGame.
func (*SlpGame) GetMetadata ¶
GetMetadata gets the SlpGame's metadata.
func (*SlpGame) GetRollbackFrames ¶
func (g *SlpGame) GetRollbackFrames() (map[int32][]FrameEntry, error)
GetRollbackFrames gets the rollback frames from the SlpGame.
func (*SlpGame) RemoveAllCalculators ¶
func (g *SlpGame) RemoveAllCalculators()
RemoveAllCalculators removes all calculators from the SlpGame.
func (*SlpGame) RemoveCalculator ¶
func (g *SlpGame) RemoveCalculator(c SlpCalculator)
RemoveCalculator removes a calculator from the SlpGame.
type SlpParser ¶
type SlpParser struct { Options SlpParserOpts Frames map[int32]FrameEntry Rollbacks Rollbacks GameEnd *GameEndPayload // contains filtered or unexported fields }
A SlpParser parses a replay into frames.
func NewSlpParser ¶
func NewSlpParser(options SlpParserOpts) *SlpParser
NewSlpParser creates a new SlpParser with the given SlpParserOpts.
func (*SlpParser) AddHandler ¶
func (p *SlpParser) AddHandler(event ParserEvent, handler chan interface{})
AddHandler attaches an event handler channel to a ParseEvent.
func (*SlpParser) GetGameInfo ¶
GetGameInfo gets the current parsed game info, as well as a boolean indicating if the full game info has been parsed yet.
func (*SlpParser) GetLatestFrame ¶
func (p *SlpParser) GetLatestFrame() *FrameEntry
GetLatestFrame gets the latest frame parsed by the SlpParser.
func (*SlpParser) GetPlayableFrameCount ¶
GetPlayableFrameCount returns the number of playable frames parsed so far.
func (*SlpParser) ParseReplay ¶
func (p *SlpParser) ParseReplay(eventResults <-chan *SlpEventResult) error
ParseReplay processes events from the given SlpEventResult channel and updates the SlpParser's state accordingly.
func (*SlpParser) RemoveAllHandlers ¶
func (p *SlpParser) RemoveAllHandlers(event ParserEvent)
RemoveAllHandlers removes all event handler channels from a ParseEvent.
func (*SlpParser) RemoveHandler ¶
func (p *SlpParser) RemoveHandler(event ParserEvent, toRemove chan interface{})
RemoveHandler removes an event handler channel from a ParseEvent.
func (*SlpParser) Reset ¶
func (p *SlpParser) Reset()
Reset resets the SlpParser's state. This does not reset parser options or remove event handler channels.
func (*SlpParser) Trigger ¶
func (p *SlpParser) Trigger(event ParserEvent, payload interface{})
Trigger triggers the given ParserEvent with the given payload, sending it to all attached handler channels.
type SlpParserOpts ¶
type SlpParserOpts struct {
Strict bool
}
SlpParserOpts contains options that determine how a SlpParser behaves.
type SlpReader ¶
type SlpReader struct { Source SlpSource RawStart int64 RawLength int64 MetadataStart int64 MetadataLength int64 PayloadSizes map[byte]uint16 // contains filtered or unexported fields }
A SlpReader reads data from Source and emits event payloads and metadata.
func NewSlpReader ¶
NewSlpReader returns a SlpReader that reads from the provided SlpSource s.
func (SlpReader) GetMetadata ¶
GetMetadata gets metadata from the replay SlpReader is reading.
func (*SlpReader) SetInclude ¶
SetInclude sets whether a given event (as specified by its command byte) will be read and emitted when YieldEvents is called on the SlpReader.
func (*SlpReader) YieldEvents ¶
func (r *SlpReader) YieldEvents(stopYielding func(*SlpEvent) bool) (<-chan *SlpEventResult, error)
YieldEvents returns a channel to which it sends the events from the SlpSource.
type SlpSource ¶
type SlpSource struct { io.ReadSeeker InputType InputType // contains filtered or unexported fields }
A SlpSource wraps a reader and the type of the reader, used to determine its length.
func NewSlpSourceBytes ¶
NewSlpSourceBytes returns a SlpSource wrapping the provided *bytes.Reader r.
func NewSlpSourceFile ¶
NewSlpSourceFile returns a SlpSource wrapping the provided *os.File f.
func (*SlpSource) GetLength ¶
GetLength gets the length of the underlying data source of the SlpSource. If recalculate is true, the length will be recalculated. Otherwise, the length is only calculated on the first call to GetLength for a given SlpSource. If there is an error getting the length of the data source, a length of 0 is returned along with the error.