gathering

package module
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2019 License: MIT Imports: 12 Imported by: 0

README

Magic: The Gathering Arena Log Parser

Build Status GoDoc

Parser is a Go library and command line interface to parse the output_log.txt created by MTGA. Cross platform with minimal dependencies, the executable is small. The CLI is currently used to send the parsed data to Gathering.gg, and you need an account to use it. Future work can be done to parse the data to local files.

Usage

To use the parser, you'll need a Go dev environment. To use the parser locally:

$ go get github.com/gathering-gg/parser

If you want to install the CLI and use that:

$ go install github.com/gathering-gg/parser/cli

You can then execute it by running (You may need to add Go's bin to your path):

$ gathering -token=YOUR_GATHERING_GG_TOKEN

You can get your token from Gathering.gg.

Binaries

If you just want to execute a binary, you can get them from the releases page.

Development

Once you have your Go dev environment setup, fetch the library:

$ go get github.com/gathering-gg/parser
$ cd $GOPATH/src/github.com/gathering-gg/parser

You can the start hacking on the library. To build the library, you run go build, however there are some compile time variables that should be set. The current command used to build is:

go build -ldflags "-X 'github.com/gathering-gg/gathering/config.Root=https://api.gathering.gg' -X 'github.com/gathering-gg/gathering/config.Version=0.0.1'" -o gathering ./cli

You can also build for specific platforms by appending GOOS and GOARCH environment variables.

Tests:

$ go test -v ./...

Changelog

See the releases page.

Contributing

Please contribute! If you have a problem with the parser you can open an issue. Feel free to ask for new features as well!

Profiling

https://blog.golang.org/profiling-go-programs

var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
var memprofile = flag.String("memprofile", "", "write memory profile to this file")

// 

if *cpuprofile != "" {
  f, err := os.Create("cpu.prof")
    if err != nil {
      log.Fatal(err)
    }
  pprof.StartCPUProfile(f)
    defer pprof.StopCPUProfile()
}
if *memprofile != "" {
  f, err := os.Create(*memprofile)
    if err != nil {
      log.Fatal(err)
    }
  defer func() {
    pprof.WriteHeapProfile(f)
      f.Close()
  }()
}

// Add onChange(file) to bottom of main()

Documentation

Index

Constants

View Source
const LogDir = ""

LogDir on Linux

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is the error returned when a log item is not found

Functions

func Int

func Int(i int) *int

Int to pointer

func IsArenaRunning

func IsArenaRunning() (bool, error)

IsArenaRunning checks if Arena is running

func String

func String(s string) *string

String to pointer

Types

type ArenaAuthRequest

type ArenaAuthRequest struct {
	Payload ArenaAuthRequestPayload `json:"Payload"`
}

ArenaAuthRequest is the base structure which wraps a payload

type ArenaAuthRequestPayload

type ArenaAuthRequestPayload struct {
	PlayerName string `json:"PlayerName"`
}

ArenaAuthRequestPayload is the payload the Arena client sends when authenticating. We only are interested in the Player's name

type ArenaDeck

type ArenaDeck struct {
	ID          string               `json:"id"`
	Name        string               `json:"name"`
	Description string               `json:"description"`
	Format      string               `json:"format"`
	DeckTileID  int                  `json:"deckTileId"`
	MainDeck    []ArenaDeckCard      `json:"mainDeck"`
	Sideboard   []ArenaDeckCard      `json:"sideboard"`
	CardSkins   []*ArenaDeckCardSkin `json:"cardSkins"`
	CardBack    string               `json:"cardBack"`
}

ArenaDeck is our format for an Arena Deck Arena has changed the deck format, sometimes it has the old version of json objects for cards, sometimes it now contains a list of `ints`, pairs of card number and quantity. We handle both

func (*ArenaDeck) UnmarshalJSON added in v0.7.1

func (d *ArenaDeck) UnmarshalJSON(data []byte) error

UnmarshalJSON handles both strange cases of the deck format and normalizes it to what we expect

type ArenaDeckCard

type ArenaDeckCard struct {
	ID       int `json:"id"`
	Quantity int `json:"quantity"`
}

ArenaDeckCard is our representation of the card This is not always what the log has, but we normalize it to this structure when we parse the JSON

type ArenaDeckCardSkin added in v0.7.1

type ArenaDeckCardSkin struct {
	GrpID int    `json:"grpId"`
	CCV   string `json:"ccv"` // No idea what this is
}

ArenaDeckCardSkin contains which cards have which skins

type ArenaEvent

type ArenaEvent struct {
	ClaimPrize *ArenaEventClaimPrize `json:"claimPrize"`
	Prize      *ArenaInventoryUpdate `json:"prize"`
}

ArenaEvent encapsulates the various stages a player may be in an event. When the log is parsed, the player may have started an event, be in the middle of an event, or just signed on to finish an event. The server will use the ID to track individual events.

type ArenaEventClaimPrize added in v0.5.0

type ArenaEventClaimPrize struct {
	ID                 string                                  `json:"Id"`
	InternalEventName  string                                  `json:"InternalEventName"`
	ModuleInstanceData *ArenaEventClaimPrizeModuleInstanceData `json:"ModuleinstanceData"`
	CurrentEventState  string                                  `json:"CurrentEventState"`
	CurrentModule      string                                  `json:"CurrentModule"`
	CardPool           []int                                   `json:"Cardpool"`
	CourseDeck         *ArenaDeck                              `json:"CourseDeck"`
}

ArenaEventClaimPrize is what is sent to the client when the user claims their prize after finishing an event

type ArenaEventClaimPrizeModuleInstanceData added in v0.5.0

type ArenaEventClaimPrizeModuleInstanceData struct {
	HasPaidEntry string                           `json:"HasPaidEntry"`
	DeckSelected bool                             `json:"DeckSelected"`
	WinLossGate  *ArenaEventClaimPrizeWinLossGate `json:"WinLossGate"`
}

ArenaEventClaimPrizeModuleInstanceData has the data in claim prize about the event

type ArenaEventClaimPrizeRequest

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

ArenaEventClaimPrizeRequest is the inventory update from an event to know what the prizes are.

type ArenaEventClaimPrizeRequestParams

type ArenaEventClaimPrizeRequestParams struct {
	EventName *string `json:"eventName"`
}

ArenaEventClaimPrizeRequestParams are the params sent when a client requests the prize (Which prize does it request?)

type ArenaEventClaimPrizeWinLossGate added in v0.5.0

type ArenaEventClaimPrizeWinLossGate struct {
	MaxWins           int      `json:"MaxWins"`
	MaxLosses         int      `json:"MaxLosses"`
	CurrentWins       int      `json:"CurrentWins"`
	CurrentLosses     int      `json:"CurrentLosses"`
	ProcessedMatchIds []string `json:"ProcessedMatchIds"`
}

ArenaEventClaimPrizeWinLossGate has the player record for an event as well as max wins/losses and the matches played.

type ArenaEventGetPlayerCourse

type ArenaEventGetPlayerCourse struct {
	ID                 string
	InternalEventName  string
	ModuleInstanceData ArenaModuleInstanceData
	CurrentEventState  string
	CurrentModule      string
	CardPool           []int
	CourseDeck         *ArenaDeck
}

ArenaEventGetPlayerCourse is fired when the player goes to find a new match. JoinQueue typically follows

type ArenaEventJoin

type ArenaEventJoin struct {
	ID                string
	InternalEventName string
	CurrentEventState string
	CurrentModule     string
	CardPool          []int
	CourseDeck        ArenaDeck
}

ArenaEventJoin is the payload when a user joins an event CardPool: Used in draft to list the cards available in the deck

type ArenaEventPayEntry

type ArenaEventPayEntry struct {
	ID                 string
	InternalEventName  string
	ModuleInstanceData ArenaModuleInstanceData
	CurrentEventState  string
	CurrentModule      string
	CardPool           []int
	CourseDeck         *ArenaDeck
}

ArenaEventPayEntry is the payload when the user pays for an event

type ArenaGame added in v0.7.0

type ArenaGame struct {
	GameStart     *time.Time                     `json:"gameStart"`
	Number        *int                           `json:"number"`
	MatchID       *string                        `json:"matchId"`
	SeatID        *int                           `json:"seatId"`
	TeamID        *int                           `json:"teamId"`
	WinningTeamID *int                           `json:"winningTeamId"`
	WinningReason *string                        `json:"winningReason"`
	TurnCount     *int                           `json:"turnCount"`
	SecondsCount  *int                           `json:"secondsCount"`
	CourseDeck    *ArenaDeck                     `json:"CourseDeck"`
	SeenObjects   map[int][]ArenaMatchGameObject `json:"seenObjects"`
}

ArenaGame is a game within a match

type ArenaInventoryUpdate

type ArenaInventoryUpdate struct {
	Delta   *ArenaInventoryUpdateDelta `json:"delta"`
	Context string                     `json:"context"`
}

ArenaInventoryUpdate holds the incoming update for the player

type ArenaInventoryUpdateDelta

type ArenaInventoryUpdateDelta struct {
	GemsDelta          int                           `json:"gemsDelta"`
	BoosterDelta       []ArenaPlayerInventoryBooster `json:"boosterDelta"`
	CardsAdded         []int                         `json:"cardsAdded"`
	DecksAdded         []interface{}                 `json:"decksAdded"`
	VanityItemsAdded   []interface{}                 `json:"vanityItemsAdded"`
	VanityItemsRemoved []interface{}                 `json:"vanityItemsRemoved"`
	DraftTokensDelta   int                           `json:"draftTokensDelta"`
	GoldDelta          int                           `json:"goldDelta"`
	SealedTokensDelta  int                           `json:"sealedTokensDelta"`
	VaultProgressDelta float64                       `json:"vaultProgressDelta"`
	WcCommonDelta      int                           `json:"wcCommonDelta"`
	WcUncommonDelta    int                           `json:"wcUncommonDelta"`
	WcRareDelta        int                           `json:"wcRarreDelta"`
	WcMythicDelta      int                           `json:"wcMythicDelta"`
}

ArenaInventoryUpdateDelta holds the delta change in a players inventory

type ArenaMatch

type ArenaMatch struct {
	MatchID                        string       `json:"matchId"`
	Games                          []*ArenaGame `json:"games"`
	GameStart                      *time.Time   `json:"gameStart"`
	EventID                        string       `json:"eventId"`
	OpponentScreenName             string       `json:"opponentScreenName"`
	OpponentIsWotc                 bool         `json:"opponentIsWotc"`
	OpponentRankingClass           string       `json:"opponentRankingClass"`
	OpponentRankingTier            int          `json:"opponentRankingTier"`
	OpponentMythicPercentile       float64      `json:"opponentMythicPercentile"`
	OpponentMythicLeaderboardPlace int          `json:"opponentMythicLeaderboardPlace"`
	CourseDeck                     *ArenaDeck   `json:"CourseDeck"`
	// contains filtered or unexported fields
}

ArenaMatch is a match. A match contains at least one game, but in best of three, main contain up to 3.

func (*ArenaMatch) LogMatchEvent

func (a *ArenaMatch) LogMatchEvent(event *ArenaMatchEvent)

LogMatchEvent adds an event to the log

func (*ArenaMatch) UpdateGameEnd added in v0.7.0

func (a *ArenaMatch) UpdateGameEnd(end *ArenaGame)

UpdateGameEnd updates the latest game with the game result

func (*ArenaMatch) UpdateMatchCompleted added in v0.7.0

func (a *ArenaMatch) UpdateMatchCompleted(com *ArenaMatchCompleted)

UpdateMatchCompleted updates the match object with the completed status

type ArenaMatchCompleted added in v0.7.0

type ArenaMatchCompleted struct {
	TransactionID                  string                         `json:"transactionId"`
	Timestamp                      string                         `json:"timestamp"`
	MatchGameRoomStateChangedEvent MatchGameRoomStateChangedEvent `json:"matchGameRoomStateChangedEvent"`
}

ArenaMatchCompleted is when a match (and all games) is done

type ArenaMatchEnd

type ArenaMatchEnd struct {
	Params *ArenaMatchEndParams `json:"params"`
}

ArenaMatchEnd is the outer structure

type ArenaMatchEndParams

type ArenaMatchEndParams struct {
	PayloadObject *ArenaGame `json:"payloadObject"`
}

ArenaMatchEndParams are the params which hold the results of the match

type ArenaMatchEvent

type ArenaMatchEvent struct {
	TransactionID    string           `json:"transactionId"`
	Timestamp        string           `json:"timestamp"`
	GreToClientEvent GreToClientEvent `json:"greToClientEvent"`
}

ArenaMatchEvent is an event in the match

type ArenaMatchGameObject

type ArenaMatchGameObject struct {
	InstanceID  int    `json:"instanceId"`
	GrpID       int    `json:"grpId"`
	Type        string `json:"type"`
	ZoneID      int    `json:"zoneId"`
	Visibility  string `json:"visibility"`
	OwnerSeatID int    `json:"ownerSeatId"`
}

ArenaMatchGameObject is a game object in a match

func (ArenaMatchGameObject) Hash added in v0.3.0

func (a ArenaMatchGameObject) Hash() string

Hash returns a unique string for this object

type ArenaModuleInstanceData

type ArenaModuleInstanceData struct {
	HasPaidEntry string
	WinLossGate  *ArenaWinLossGate
}

ArenaModuleInstanceData is instance data in a request. This is used in: * ArenaEventPayEntry: To see how they paid.

type ArenaPlay

type ArenaPlay struct {
	MatchID                        string     `json:"matchId"`
	OpponentScreenName             string     `json:"opponentScreenName"`
	OpponentIsWotc                 bool       `json:"opponentIsWotc"`
	OpponentRankingClass           string     `json:"opponentRankingClass"`
	OpponentRankingTier            int        `json:"opponentRankingTier"`
	OpponentMythicPercentile       float64    `json:"opponentMythicPercentile"`
	OpponentMythicLeaderboardPlace int        `json:"opponentMythicLeaderboardPlace"`
	EventID                        string     `json:"eventId"`
	SeatID                         *int       `json:"seatId"`
	TeamID                         *int       `json:"teamId"`
	GameNumber                     *int       `json:"gameNumber"`
	WinningTeamID                  *int       `json:"winningTeamId"`
	WinningReason                  *string    `json:"winningReason"`
	TurnCount                      *int       `json:"turnCount"`
	SecondsCount                   *int       `json:"secondsCount"`
	CourseDeck                     *ArenaDeck `json:"CourseDeck"`
}

ArenaPlay :12494

type ArenaPlayerInventory

type ArenaPlayerInventory struct {
	PlayerID        string  `json:"playerId"`
	WcCommon        int     `json:"wcCommon"`
	WcUncommon      int     `json:"wcUncommon"`
	WcRare          int     `json:"wcRare"`
	WcMythic        int     `json:"wcMythic"`
	Gold            int     `json:"gold"`
	Gems            int     `json:"gems"`
	DraftTokens     int     `json:"draftTokens"`
	SealedTokens    int     `json:"sealedTokens"`
	WcTrackPosition int     `json:"wcTrackPosition"`
	VaultProgress   float64 `json:"vaultProgress"`
}

ArenaPlayerInventory is your player profile details

type ArenaPlayerInventoryBooster

type ArenaPlayerInventoryBooster struct {
	CollationID int
	Count       int
}

ArenaPlayerInventoryBooster is a struct which holds the type of booster and how many of that booster a player has.

type ArenaRankInfo

type ArenaRankInfo struct {
	PlayerID                 *string `json:"playerId"`
	ConstructedSeasonOrdinal *int    `json:"constructedSeasonOrdinal"`
	ConstructedClass         *string `json:"constructedClass"`
	ConstructedLevel         *int    `json:"constructedLevel"`
	ConstructedStep          *int    `json:"constructedStep"`
	ConstructedMatchesWon    *int    `json:"constructedMatchesWon"`
	ConstructedMatchesLost   *int    `json:"constructedMatchesLost"`
	ConstructedMatchesDrawn  *int    `json:"constructedMatchesDrawn"`
	LimitedSeasonOrdinal     *int    `json:"limitedSeasonOrdinal"`
	LimitedClass             *string `json:"limitedClass"`
	LimitedLevel             *int    `json:"limitedLevel"`
	LimitedStep              *int    `json:"limitedStep"`
	LimitedMatchesWon        *int    `json:"limitedMatchesWon"`
	LimitedMatchesLost       *int    `json:"limitedMatchesLost"`
	LimitedMatchesDrawn      *int    `json:"limitedMatchesDrawn"`
}

ArenaRankInfo contains a players rank info

func (*ArenaRankInfo) Update added in v0.4.0

func (a *ArenaRankInfo) Update(update *RankUpdated)

Update updates rank info with a server update

type ArenaWinLossGate

type ArenaWinLossGate struct {
	MaxWins           int
	MaxLosses         int
	CurrentWins       int
	CurrentLosses     int
	ProcessedMatchIDs []string
}

ArenaWinLossGate tracks your results as you go through an event

type Booster added in v0.4.0

type Booster struct {
	CardsOpened            []BoosterCard `json:"cardsOpened"`
	TotalVaultProgress     float64       `json:"totalVaultProgress"`
	WildCardTrackMoves     int           `json:"wildCardTrackMoves"`
	WildCardTrackPosition  int           `json:"wildCardTrackPosition"`
	WildCardTrackCommons   int           `json:"wildCardTrackCommons"`
	WildCardTrackUnCommons int           `json:"wildCardTrackUncommons"`
	WildCardTrackRares     int           `json:"wildCardTrackRares"`
	WildCardTrackMythics   int           `json:"wildCardTrackMythics"`
	OpenedAt               time.Time     `json:"openedAt"`
}

Booster is an opened Booster

type BoosterCard added in v0.4.0

type BoosterCard struct {
	GrpID       int    `json:"grpId"`
	GoldAwarded int    `json:"goldAwarded"`
	GemsAwarded int    `json:"gemsAwarded"`
	Set         string `json:"set"` // Empty
}

BoosterCard is a card opened in a booster

type GameInfo added in v0.7.0

type GameInfo struct {
	MatchID            string        `json:"matchID"`
	GameNumber         int           `json:"gameNumber"`
	Stage              string        `json:"stage"`
	Type               string        `json:"type"`
	MatchState         string        `json:"matchState"`
	MatchWinCondition  string        `json:"matchWinCondition"`
	MaxTimeoutCount    int           `json:"maxTimeoutCount"`
	MaxPipCount        int           `json:"maxPipCount"`
	TimeoutDurationSec int           `json:"timeoutDurationSec"`
	Results            []MatchResult `json:"results"`
	SuperFormat        string        `json:"superFormat"`
	MulliganType       string        `json:"mulliganType"`
}

GameInfo contains match info, such as which game this is

type GameStateMessage

type GameStateMessage struct {
	Type        string                 `json:"type"`
	GameObjects []ArenaMatchGameObject `json:"gameObjects"`
	TurnInfo    *TurnInfo              `json:"turnInfo"`
	Players     []PlayerState          `json:"players"`
	GameInfo    *GameInfo              `json:"gameInfo"`
}

GameStateMessage see log

type GreToClientEvent

type GreToClientEvent struct {
	GreToClientMessages []GreToClientMessages `json:"greToClientMessages"`
}

GreToClientEvent see log

type GreToClientMessages

type GreToClientMessages struct {
	Type             string           `json:"type"`
	GameStateMessage GameStateMessage `json:"gameStateMessage"`
}

GreToClientMessages see log

type Log

type Log struct {
	Segments []*Segment
}

Log is the well-structured format of the output_log.txt, parsed into Segments

func ParseLog

func ParseLog(f *os.File) (*Log, error)

ParseLog returns a log file parsed into Segments

func (*Log) Auth

func (l *Log) Auth() ([]byte, error)

Auth finds the player's ingame name

func (*Log) Boosters added in v0.4.0

func (l *Log) Boosters() ([]*Booster, error)

Boosters finds all the opened boosters

func (*Log) Collection

func (l *Log) Collection() (map[string]int, error)

Collection finds a collection

func (*Log) Decks

func (l *Log) Decks() ([]ArenaDeck, error)

Decks finds the player decks

func (*Log) Events added in v0.5.0

func (l *Log) Events() ([]*ArenaEvent, error)

Events finds Arena Events in the logs

func (*Log) Inventory

func (l *Log) Inventory() (*ArenaPlayerInventory, error)

Inventory finds the player inventory information

func (*Log) Matches

func (l *Log) Matches() ([]*ArenaMatch, error)

Matches finds the player matches This is a little more involved, since we really need 3 pieces of information and they are not together. First, we look for the start of a match. Once we find that, we look backward until we figure out what deck they are using. Finally, we look forward again to find the result of the match. The result may not be known when we start parsing, so those values are all optional. The server only needs the MatchID to tie together the data.

func (*Log) Rank

func (l *Log) Rank() (rank *ArenaRankInfo, err error)

Rank finds the rank information The game doesn't ask for the entire rank info often, so we go through the log and update the parsed rank with changes so we return the most up to date version

type LoggerType

type LoggerType int

LoggerType is the logger that created this segment (log section)

const (
	UnityLogger LoggerType = iota
	ClientGRE
)

The Available Log types

type MatchCompletedResult added in v0.7.0

type MatchCompletedResult struct {
	Scope         string `json:"scope"`
	Result        string `json:"result"`
	WinningTeamID int    `json:"winningTeamId"`
}

MatchCompletedResult contains the match results

type MatchFinalMatchResult added in v0.7.0

type MatchFinalMatchResult struct {
	MatchID              string                 `json:"matchId"`
	MatchCompletedReason string                 `json:"matchCompletedReason"`
	ResultList           []MatchCompletedResult `json:"resultList"`
}

MatchFinalMatchResult contains the final results

type MatchGameRoomConfig added in v0.7.0

type MatchGameRoomConfig struct {
	EventID string `json:"eventId"`
	MatchID string `json:"matchId"`
}

MatchGameRoomConfig contains info

type MatchGameRoomInfo added in v0.7.0

type MatchGameRoomInfo struct {
	GameRoomConfig   MatchGameRoomConfig   `json:"gameRoomConfig"`
	StateType        string                `json:"stateType"`
	FinalMatchResult MatchFinalMatchResult `json:"finalMatchResult"`
}

MatchGameRoomInfo contains the config

type MatchGameRoomStateChangedEvent added in v0.7.0

type MatchGameRoomStateChangedEvent struct {
	GameRoomInfo MatchGameRoomInfo `json:"gameRoomInfo"`
}

MatchGameRoomStateChangedEvent has info

type MatchResult added in v0.7.0

type MatchResult struct {
	Scope         string `json:" scope"`
	Result        string `json:"result"`
	WinningTeamID int    `json:"winningTeamId"`
	Reason        string `json:"reason"`
}

MatchResult has a list of who won the games in a match

type PlayerState

type PlayerState struct {
	LifeTotal        int `json:"lifeTotal"`
	SystemSeatNumber int `json:"systemSeatNumber"`
	TeamID           int `json:"teamId"`
	ControllerSeatID int `json:"controllerSeatId"`
}

PlayerState see log

type RankUpdated added in v0.4.0

type RankUpdated struct {
	PlayerID         string `json:"playerId"`
	SeasonOrdinal    int    `json:"seasonOrdinal"`
	NewClass         string `json:"newClass"`
	OldClass         string `json:"oldClass"`
	NewLevel         int    `json:"newLevel"`
	OldLevel         int    `json:"oldLevel"`
	NewStep          int    `json:"newStep"`
	OldStep          int    `json:"oldStep"`
	WasLossProtected bool   `json:"wasLossProtected"`
	RankUpdateType   string `json:"rankUpdateType"`
}

RankUpdated holds the rank update info from the server RankUpdateType: 'Constructed' | 'Limited'

type Segment

type Segment struct {
	LoggerType  LoggerType
	Time        *time.Time
	SegmentType SegmentType
	Text        []byte
	Range       []int
	Line        []byte
}

Segment is a piece of the log

func (*Segment) IsArenaDecks

func (s *Segment) IsArenaDecks() bool

IsArenaDecks checks if a segment contains Arena Decks

func (*Segment) IsClaimPrize added in v0.5.0

func (s *Segment) IsClaimPrize() bool

IsClaimPrize checks if this segment claims a prize

func (*Segment) IsCollection

func (s *Segment) IsCollection() bool

IsCollection checks if a segment contains the collection

func (*Segment) IsCrackBooster added in v0.4.0

func (s *Segment) IsCrackBooster() bool

IsCrackBooster checks to see if the user opened a booster

func (*Segment) IsEventDeckSubmit

func (s *Segment) IsEventDeckSubmit() bool

IsEventDeckSubmit does this segment contain a deck submit for the play queue

func (*Segment) IsEventGetPlayerCourse

func (s *Segment) IsEventGetPlayerCourse() bool

IsEventGetPlayerCourse does this segment contain the player course

func (*Segment) IsEventJoin

func (s *Segment) IsEventJoin() bool

IsEventJoin checks if a segment contains an Event Join

func (*Segment) IsInventoryUpdate added in v0.5.0

func (s *Segment) IsInventoryUpdate() bool

IsInventoryUpdate checks if a segment is an inventory update

func (*Segment) IsMatchCompleted added in v0.7.0

func (s *Segment) IsMatchCompleted() bool

IsMatchCompleted is a better metric for a match (including ALL games) being completed.

func (*Segment) IsMatchEnd

func (s *Segment) IsMatchEnd() bool

IsMatchEnd does this segment contain a match end

func (*Segment) IsMatchEvent

func (s *Segment) IsMatchEvent() bool

IsMatchEvent checks if this segment contains anything interesting about a currently parsing match

func (*Segment) IsMatchStart

func (s *Segment) IsMatchStart() bool

IsMatchStart does this segment contain match start

func (*Segment) IsPlayerAuth

func (s *Segment) IsPlayerAuth() bool

IsPlayerAuth checks if a segment contains an auth statement

func (*Segment) IsPlayerInventory

func (s *Segment) IsPlayerInventory() bool

IsPlayerInventory checks if a segment contains player inventory

func (*Segment) IsRankInfo

func (s *Segment) IsRankInfo() bool

IsRankInfo checks if a segment contains Rank Info

func (*Segment) IsRankUpdated added in v0.4.0

func (s *Segment) IsRankUpdated() bool

IsRankUpdated checks if a segment contains Rank Update

func (*Segment) IsSideboardStop added in v0.7.0

func (s *Segment) IsSideboardStop() bool

IsSideboardStop checks if this is a sideboard end event

func (*Segment) JSON

func (s *Segment) JSON(v interface{}) error

JSON parses the text as JSON

func (*Segment) JoinedEvent

func (s *Segment) JoinedEvent() bool

JoinedEvent is a higher level function to find if you joined any queue with a deck. Works with events and "play"

func (*Segment) ParseArenaDecks

func (s *Segment) ParseArenaDecks() ([]ArenaDeck, error)

ParseArenaDecks parses out arena decks from a segment if present. Note, it is the caller's responsibility to check if this segment contains ArenaDecks by calling `IsArenaDecks()`

func (*Segment) ParseAuth

func (s *Segment) ParseAuth() ([]byte, error)

ParseAuth returns the players username

func (*Segment) ParseCollection

func (s *Segment) ParseCollection() (map[string]int, error)

ParseCollection parses a collection from a Segment. It is up to the caller to check if this segment contains a Collection with `IsCollection()`

func (*Segment) ParseCrackBooster added in v0.4.0

func (s *Segment) ParseCrackBooster() (*Booster, error)

ParseCrackBooster parses a booster from the log

func (*Segment) ParseEventClaimPrize added in v0.5.0

func (s *Segment) ParseEventClaimPrize() (*ArenaEventClaimPrize, error)

ParseEventClaimPrize parses an event claim prize

func (*Segment) ParseEventJoin

func (s *Segment) ParseEventJoin() (*ArenaEventJoin, error)

ParseEventJoin parses out an event from JSON

func (*Segment) ParseEventPayEntry

func (s *Segment) ParseEventPayEntry() (*ArenaEventPayEntry, error)

ParseEventPayEntry parses out a pay entry value

func (*Segment) ParseInventoryUpdate added in v0.5.0

func (s *Segment) ParseInventoryUpdate() (*ArenaInventoryUpdate, error)

ParseInventoryUpdate parses an incoming inventory update

func (*Segment) ParseJoinedEvent

func (s *Segment) ParseJoinedEvent() (*ArenaEventGetPlayerCourse, error)

ParseJoinedEvent gets the player course, which is another good way to verify the deck the player is using going into a game.

func (*Segment) ParseMatchCompleted added in v0.7.0

func (s *Segment) ParseMatchCompleted() (*ArenaMatchCompleted, error)

ParseMatchCompleted parses the match completed. It means all games in a match are finished.

func (*Segment) ParseMatchEnd

func (s *Segment) ParseMatchEnd() (*ArenaMatchEnd, error)

ParseMatchEnd parses the match end. Contains the match ID

func (*Segment) ParseMatchEvent

func (s *Segment) ParseMatchEvent() (*ArenaMatchEvent, error)

ParseMatchEvent looks through the match segments and pulls out cards played by whom

func (*Segment) ParseMatchStart

func (s *Segment) ParseMatchStart() (*ArenaMatch, error)

ParseMatchStart parses out the match start (will return an incomplete ArenaMatch object)

func (*Segment) ParsePlayerInventory

func (s *Segment) ParsePlayerInventory() (*ArenaPlayerInventory, error)

ParsePlayerInventory parses the player inventory information from a segment

func (*Segment) ParseRankInfo

func (s *Segment) ParseRankInfo() (*ArenaRankInfo, error)

ParseRankInfo parses the rank information out of a segment.

func (*Segment) ParseRankUpdated added in v0.4.0

func (s *Segment) ParseRankUpdated() (*RankUpdated, error)

ParseRankUpdated parses the rank update

type SegmentType

type SegmentType int

SegmentType is the type of log info

const (
	Unknown SegmentType = iota
	PlayerInventoryGetPlayerInventory
	PlayerInventoryGetPlayerCards
	DeckGetDeckLists
	EventGetCombinedRankInfo
	EventJoin
	EventPayEntry
	EventGetPlayerCourse
	EventDeckSubmit
	EventMatchCreated
	PlayerAuth
	MatchStart
	MatchEnd
	MatchEvent
	CrackBooster
	InventoryRankUpdated
	EventClaimPrize
	IncomingInventoryUpdate
	DuelSceneSideboardingStart
	DuelSceneSideboardingStop
	MatchCompleted
)

The type of data you can expect to find in the text of the log

type TurnInfo

type TurnInfo struct {
	Phase        string `json:"phase"`
	Step         string `json:"step"`
	TurnNumber   int    `json:"turnNumber"`
	ActivePlayer int    `json:"activePlayer"`
}

TurnInfo see log

type UploadData

type UploadData struct {
	IsPlaying  bool                  `json:"isPlaying"`
	Collection map[string]int        `json:"collection"`
	Decks      []ArenaDeck           `json:"deck"`
	Inventory  *ArenaPlayerInventory `json:"inventory"`
	Rank       *ArenaRankInfo        `json:"rank"`
	Auth       *ArenaAuthRequest     `json:"auth"`
	Matches    []*ArenaMatch         `json:"matches"`
	Boosters   []*Booster            `json:"boosters"`
	Events     []*ArenaEvent         `json:"events"`
}

UploadData encapsulates the data to send to the server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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