xfcc

package module
v0.0.0-...-90d526b Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2022 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-chess-xfcc

Golang support for XML web services for correspondence chess.

Configuration

Create a configuration file to you home directory:

mkdir -p "${HOME}/.config/go-chess-xfcc"

and a file named go-chess-xfcc.xml with contents:

<configuration>
	<user>REPLACE_WITH_YOUR_USERNAME</user>
	<password>REPLACE_WITH_YOUR_PASSWORD</password>
</configuration>

ICCF

International Correspondence Chess Federation supports XFCC. For practical examples see

Syzygy tables

Lichess API

Documentation

Overview

Package xfcc provides methods for communicating correspondence chess sites with XFCC protocol.

POST /xfccbasic.asmx HTTP/1.1 Host: www.iccf.com Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://www.bennedik.com/webservices/XfccBasic/GetMyGames"

<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Body>
  <GetMyGames xmlns="http://www.bennedik.com/webservices/XfccBasic">
    <username>string</username>
    <password>string</password>
  </GetMyGames>
</soap:Body>

</soap:Envelope>

Package xfcc provides methods for communicating correspondence chess sites with XFCC protocol.

Index

Constants

View Source
const DateRegularExpressionString = `^(\d\d\d\d|\?\?\?\?)[.-](\d\d?|\?\?)[.-](\d\d?|\?\?)$`

DateRegularExpressionString is the string that is used to create DateRegularExpression.

View Source
const FewPiecesGame2b = `` /* 4488-byte string literal not displayed */

FewPiecesGame2b is something to be fixed

View Source
const GetMyGamesSOAPXML = `` /* 404-byte string literal not displayed */

GetMyGamesSOAPXML is the SOAP request template for GetMyGames.

View Source
const ICCFBaseURL = "https://www.iccf.com/XfccBasic.asmx"

ICCFBaseURL is the base URL for the XFCC endpoint of International Correspondence Chess Federation (ICCF).

View Source
const ICCFSOAPMIMEType = "text/xml"

ICCFSOAPMIMEType is the MIME type ICCF uses.

View Source
const ISO8601Layout = "2006-01-02"

ISO8601Layout is date layout for ISO8601 standard.

View Source
const MaximumMoveTextLength = 78

MaximumMoveTextLength defines the maximum length of lines of the movetext of a game.

View Source
const PGNLayout = "2006.01.02"

PGNLayout is date layout for PGN tags.

View Source
const PGNTemplate = `` /* 128-byte string literal not displayed */

PGNTemplate is a template for Portable Game Notation.

View Source
const ResultBlackWins = "0-1"

ResultBlackWins is the string value for a Black win.

View Source
const ResultDraw = "1/2-1/2"

ResultDraw is the string value for a draw.

View Source
const ResultUnknown = "*"

ResultUnknown is the string value for an unknown result.

View Source
const ResultWhiteWins = "1-0"

ResultWhiteWins is the string value for a White win.

View Source
const SOAPMIMEType = "application/soap+xml"

SOAPMIMEType is the MIME type for SOAP requests.

Variables

View Source
var DateRegularExpression *regexp.Regexp

DateRegularExpression is used for parsin Dates from strings.

Functions

func GetMyGamesXML

func GetMyGamesXML(url, MIMEType, username, password string) ([]byte, error)

GetMyGamesXML returns the XML of your games.

Types

type Body

type Body struct {
	XMLName  xml.Name
	Response GetMyGamesResponse `xml:"GetMyGamesResponse"`
}

Body is just for parsing the XML.

type Date

type Date struct {
	Year  *int
	Month *int
	Day   *int
}

Date models the date.

func NewDate

func NewDate(year, month, day *int) *Date

NewDate returns a pointer to a new Date.

func Now

func Now() *Date

Now returns a pointer to the current day.

func Parse

func Parse(s string) (*Date, error)

Parse returns a pointer to a new Date from string which is formatted like "1916.01.07", "1916-01-07", 1916-1-7 or "1916.1.7" and an error.

func (*Date) PGN

func (d *Date) PGN() string

PGN returns the date in PGN format.

func (Date) String

func (d Date) String() string

String implements the Stringer interface

func (*Date) Time

func (d *Date) Time() (tm time.Time, err error)

Time returns the Date as time.Time in some semi-sensible way, if applicable.

type Envelope

type Envelope struct {
	XMLName xml.Name
	Body    Body
}

Envelope is just for parsing the XML.

type Game

type Game struct {
	XMLName     xml.Name `xml:"XfccGame"`
	ID          uint64   `xml:"id"`
	Event       string   `xml:"event"`
	Site        string   `xml:"site"`
	Date        string   `xml:"date"`
	EventDate   string   `xml:"eventDate"`
	White       Player   `xml:"white"`
	Black       Player   `xml:"black"`
	Result      Result   `xml:"result"`
	Movetext    Movetext `xml:"moves"`
	WhiteElo    int      `xml:"whiteElo"`
	BlackElo    int      `xml:"blackElo"`
	DrawOffered bool     `xml:"drawOffered"`
	MyTurn      bool     `xml:"myTurn"`
}

Game models a correspondence chess game.

func GetMyGames

func GetMyGames(url, MIMEType, username, password string) ([]Game, error)

GetMyGames returns your games.

func (*Game) PGN

func (g *Game) PGN() (string, error)

PGN returns the game as a PGN string.

type GetMyGamesResponse

type GetMyGamesResponse struct {
	XMLName xml.Name         `xml:"GetMyGamesResponse"`
	Result  GetMyGamesResult `xml:"GetMyGamesResult"`
}

GetMyGamesResponse models the result of GetMyGames SOAP query.

type GetMyGamesResult

type GetMyGamesResult struct {
	XMLName xml.Name `xml:"GetMyGamesResult"`
	Games   []Game   `xml:"XfccGame"`
}

GetMyGamesResult models the result containg the games.

type Movetext

type Movetext string

Movetext models the movetext of the game.

func (*Movetext) Wrap

func (mt *Movetext) Wrap() string

Wrap returns the movetext as a wrapped string, see MaximumMoveTextLength.

type Player

type Player string

Player models a chess player.

type Result

type Result string

Result models the result of the game. It can have following values: - "Ongoing" - "WhiteWins" - "BlackWins" - "Draw" - "WhiteWinAdjudicated" - "BlackWinAdjudicated" - "DrawAdjudicated" - "WhiteDefaulted" - "BlackDefaulted" - "BothDefaulted" - "Cancelled" - "AdjudicationPending"

func (*Result) PGN

func (r *Result) PGN() string

PGN returns the result of the game as a PGN string.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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