gcgio

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: GPL-3.0 Imports: 16 Imported by: 1

Documentation

Overview

Package gcgio implements a GCG parser. It might also implement other io methods.

Index

Constants

View Source
const (
	PlayerRegex               = `#player(?P<p_number>[1-2])\s+(?P<nick>\S+)\s+(?P<real_name>.+)`
	TitleRegex                = `#title\s*(?P<title>.*)`
	DescriptionRegex          = `#description\s*(?P<description>.*)`
	IDRegex                   = `#id\s*(?P<id_authority>\S+)\s+(?P<id>\S+)`
	Rack1Regex                = `#rack1 (?P<rack>\S+)`
	Rack2Regex                = `#rack2 (?P<rack>\S+)`
	MoveRegex                 = `>(?P<nick>\S+):\s+(?P<rack>\S+)\s+(?P<pos>\w+)\s+(?P<play>\S+)\s+\+(?P<score>\d+)\s+(?P<cumul>\d+)`
	NoteRegex                 = `#note (?P<note>.+)`
	LexiconRegex              = `#lexicon (?P<lexicon>.+)`
	CharacterEncodingRegex    = `#character-encoding (?P<encoding>[[:graph:]]+)`
	GameTypeRegex             = `#game-type (?P<gameType>.*)`
	TileSetRegex              = `#tile-set (?P<tileSet>.*)`
	GameBoardRegex            = `#game-board (?P<gameBoard>.*)`
	BoardLayoutRegex          = `#board-layout (?P<boardLayoutName>.*)`
	TileDistributionNameRegex = `#tile-distribution (?P<tileDistributionName>.*)`
	ContinuationRegex         = `#- (?P<continuation>.*)`
	PhonyTilesReturnedRegex   = `>(?P<nick>\S+):\s+(?P<rack>\S+)\s+--\s+-(?P<lost_score>\d+)\s+(?P<cumul>\d+)`
	PassRegex                 = `>(?P<nick>\S+):\s+(?P<rack>\S+)\s+-\s+\+0\s+(?P<cumul>\d+)`
	ChallengeBonusRegex       = `>(?P<nick>\S+):\s+(?P<rack>\S*)\s+\(challenge\)\s+\+(?P<bonus>\d+)\s+(?P<cumul>\d+)`
	ExchangeRegex             = `>(?P<nick>\S+):\s+(?P<rack>\S+)\s+-(?P<exchanged>\S+)\s+\+0\s+(?P<cumul>\d+)`
	EndRackPointsRegex        = `>(?P<nick>\S+):\s+\((?P<rack>\S+)\)\s+\+(?P<score>\d+)\s+(?P<cumul>-?\d+)`
	TimePenaltyRegex          = `>(?P<nick>\S+):(?:\s+(?P<rack>\S*))?\s+\(time\)\s+\+?\-(?P<penalty>\d+)\s+(?P<cumul>-?\d+)`
	PtsLostForLastRackRegex   = `>(?P<nick>\S+):\s+(?P<rack>\S+)\s+\((?P<rack>\S+)\)\s+\-(?P<penalty>\d+)\s+(?P<cumul>-?\d+)`
	IncompleteRegex           = "#incomplete.*"
	TileDeclarationRegex      = `#tile (?P<uppercase>\S+)\s+(?P<lowercase>\S+)`
)

Variables

View Source
var GCGRegexes []gcgdatum

Functions

func GameHistoryToGCG added in v0.4.2

func GameHistoryToGCG(h *pb.GameHistory, addlHeaderInfo bool) (string, error)

GameHistoryToGCG returns a string GCG representation of the GameHistory.

func ParseGCG

func ParseGCG(cfg *config.Config, filename string) (*pb.GameHistory, error)

ParseGCG parses a GCG file into a GameHistory.

func ParseGCGFromReader

func ParseGCGFromReader(cfg *config.Config, reader io.Reader) (*pb.GameHistory, error)

Types

type Token

type Token uint8

A Token is an event in a GCG file.

const (
	UndefinedToken Token = iota
	PlayerToken
	TitleToken
	DescriptionToken
	IDToken
	Rack1Token
	Rack2Token
	EncodingToken
	MoveToken
	NoteToken
	LexiconToken
	PhonyTilesReturnedToken
	PassToken
	ChallengeBonusToken
	ExchangeToken
	EndRackPointsToken
	TimePenaltyToken
	LastRackPenaltyToken
	GameTypeToken
	TileSetToken
	GameBoardToken
	BoardLayoutToken
	TileDistributionNameToken
	ContinuationToken
	IncompleteToken
	TileDeclarationToken
)

Jump to

Keyboard shortcuts

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