models

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

SPDX-License-Identifier: GPL-3.0-only

Index

Constants

View Source
const (
	CallSuffixGoodCall         = "!"
	CallSuffixPoorCall         = "?"
	CallSuffixVeryGoodCall     = "!!"
	CallSuffixVeryPoorCall     = "??"
	CallSuffixSpeculativeCall  = "!?"
	CallSuffixQuestionableCall = "?!"
)
View Source
const (
	NAGNoAnnotation                 = "$0"
	NAGGoodCall                     = "$1"
	NAGPoorCall                     = "$2"
	NAGVeryGoodCall                 = "$3"
	NAGVeryPoorCall                 = "$4"
	NAGSpeculativeCall              = "$5"
	NAGQuestionableCall             = "$6"
	NAGGoodCard                     = "$7"
	NAGPoorCard                     = "$8"
	NAGVeryGoodCard                 = "$9"
	NAGVeryPoorCard                 = "$10"
	NAGSpeculativeCard              = "$11"
	NAGQuestionableCard             = "$12"
	NAGCallHasBeenCorrectedManually = "$13"
	NAGCardHasBeenCorrectedManually = "$14"
)
View Source
const (
	CallTokenAP   = "AP"
	CallTokenPass = "Pass"
	CallTokenX    = "X"
	CallTokenXX   = "XX"
)
View Source
const (
	RankTwo   = "2"
	RankThree = "3"
	RankFour  = "4"
	RankFive  = "5"
	RankSix   = "6"
	RankSeven = "7"
	RankEight = "8"
	RankNine  = "9"
	RankTen   = "T"
	RankJack  = "J"
	RankQueen = "Q"
	RankKing  = "K"
	RankAce   = "A"
)
View Source
const (
	SuitSpades   = "S"
	SuitHearts   = "H"
	SuitDiamonds = "D"
	SuitClubs    = "C"
)
View Source
const (
	RiskUndoubled = ""
	RiskDouble    = "X"
	RiskRedouble  = "XX"
)
View Source
const (
	DenominationSpades   = "S"
	DenominationHearts   = "H"
	DenominationDiamonds = "D"
	DenominationClubs    = "C"
	DenominationNoTrump  = "NT"
)
View Source
const (
	PairNoPair     = "None"
	PairEastWest   = "EW"
	PairNorthSouth = "NS"
	PairBoth       = "Both"
)
View Source
const (
	PlayCardSuffixGoodCard         = "!"
	PlayCardSuffixPoorCard         = "?"
	PlayCardSuffixVeryGoodCard     = "!!"
	PlayCardSuffixVeryPoorCard     = "??"
	PlayCardSuffixSpeculativeCard  = "!?"
	PlayCardSuffixQuestionableCard = "?!"
)
View Source
const (
	NoSeat = "None"
	West   = "W"
	North  = "N"
	East   = "E"
	South  = "S"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Auction

type Auction struct {
	Dealer Seat   `json:"dealer"`
	Calls  []Call `json:"calls"`
	Notes  []Note `json:"notes"`
}

func GetAuction

func GetAuction(dealer string, lines []string) (Auction, error)

type Call

type Call struct {
	Token            string     `json:"token"`
	SuffixAnnotation CallSuffix `json:"suffix_annotation,omitempty"`
	NoteReference    string     `json:"note_reference,omitempty"`
	NAGs             []string   `json:"nags,omitempty"`
}

type CallSuffix

type CallSuffix string

type CallToken

type CallToken string

type Card

type Card struct {
	Suit Suit `json:"suit"`
	Rank Rank `json:"rank"`
}

type Contract

type Contract struct {
	Tricks       int          `json:"tricks"`
	Denomination Denomination `json:"denomination"`
	Risk         Risk         `json:"risk"`
	Pass         bool         `json:"pass"`
}

func GetContract

func GetContract(s string) (Contract, error)

type Date

type Date struct {
	Year  int `json:"year"`
	Month int `json:"month"`
	Day   int `json:"day"`
}

func ParseDate

func ParseDate(s string) (Date, error)

type Deal

type Deal struct {
	West  []Card `json:"west"`
	North []Card `json:"north"`
	East  []Card `json:"east"`
	South []Card `json:"south"`
}

func GetDeal added in v1.0.1

func GetDeal(s string) (Deal, error)

type Declarer

type Declarer struct {
	Seat      Seat `json:"seat"`
	Irregular bool `json:"irregular"`
}

func GetDeclarer

func GetDeclarer(s string) (Declarer, error)

type Denomination

type Denomination string

type Game

type Game struct {
	// Mandatory tags.
	Event      string `json:"event"`
	Site       string `json:"site"`
	Date       Date   `json:"date"`
	Board      string `json:"board"`
	West       string `json:"west"`
	North      string `json:"north"`
	East       string `json:"east"`
	South      string `json:"south"`
	Dealer     Seat   `json:"seat"`
	Vulnerable Pair   `json:"vulnerable"`
	Deal       Deal   `json:"deal"`

	// Game related information.
	Competition string `json:"competition,omitempty"`
	DealId      string `json:"deal_id,omitempty"`
	Description string `json:"description,omitempty"`
	FrenchMP    bool   `json:"french_mp,omitempty"`
	Generator   string `json:"generator,omitempty"`
	Hidden      []Seat `json:"hidden,omitempty"`
	Room        string `json:"room,omitempty"`
	Termination string `json:"termination,omitempty"`

	// Score related information.
	Score           Score[int]     `json:"score,omitempty"`
	ScoreIMP        Score[int]     `json:"score_imp,omitempty"`
	ScoreMP         Score[int]     `json:"score_mp,omitempty"`
	ScorePercentage Score[float32] `json:"score_percentage,omitempty"`
	ScoreRubber     [2]int         `json:"score_rubber,omitempty"`

	// Player related information.
	BidSystemEW string `json:"bid_system_ew,omitempty"`
	BidSystemNS string `json:"bid_system_ns,omitempty"`
	PairEW      string `json:"pair_ew,omitempty"`
	PairNS      string `json:"pair_ns,omitempty"`
	WestNA      string `json:"west_na,omitempty"`
	NorthNA     string `json:"north_na,omitempty"`
	EastNA      string `json:"east_na,omitempty"`
	SouthNA     string `json:"south_na,omitempty"`
	WestType    string `json:"west_type,omitempty"`
	NorthType   string `json:"north_type,omitempty"`
	EastType    string `json:"east_type,omitempty"`
	SouthType   string `json:"south_type,omitempty"`

	// Event related information.
	EventDate    Date   `json:"event_date,omitempty"`
	EventSponsor string `json:"event_sponsor,omitempty"`
	HomeTeam     string `json:"home_team,omitempty"`
	Round        string `json:"round,omitempty"`
	Section      string `json:"section,omitempty"`
	Stage        string `json:"stage,omitempty"`
	Table        string `json:"table,omitempty"`
	VisitTeam    string `json:"visit_team,omitempty"`

	// Time and date related information.
	Time    Time `json:"time,omitempty"`
	UTCDate Time `json:"utc_date,omitempty"`
	UTCTime Time `json:"utc_time,omitempty"`

	// Time control.
	TimeControl TimeControl `json:"time_control,omitempty"`
	TimeCall    int         `json:"time_call,omitempty"`
	TimeCard    int         `json:"time_card,omitempty"`

	// Miscellaneous.
	Annotator   string `json:"annotator,omitempty"`
	AnnotatorNA string `json:"annotator_na,omitempty"`
	Application string `json:"application,omitempty"`
	Mode        string `json:"mode,omitempty"`

	// Auction
	Auction Auction `json:"auction"`
	Play    Play    `json:"play"`

	// Others.
	Declarer Declarer   `json:"declarer,omitempty"`
	Contract Contract   `json:"contract,omitempty"`
	Result   Score[int] `json:"result,omitempty"`
	Scoring  []string   `json:"scoring,omitempty"`
}

type MetaData

type MetaData struct {
	Version struct {
		Major int `json:"major"`
		Minor int `json:"minor"`
	} `json:"version"`
}

type NAG

type NAG string

type Note

type Note struct {
	Id   string `json:"id"`
	Text string `json:"text"`
}

type PBN

type PBN struct {
	MetaData MetaData `json:"meta_data"`
	Games    []Game   `json:"games"`
}

type Pair

type Pair string

type Play

type Play struct {
	Direction Seat    `json:"direction"`
	Tricks    []Trick `json:"tricks"`
	Notes     []Note  `json:"notes"`
}

func GetPlay

func GetPlay(direction string, lines []string) (Play, error)

type PlayCard

type PlayCard struct {
	Token            string         `json:"token"`
	SuffixAnnotation PlayCardSuffix `json:"suffix_annotation,omitempty"`
	NoteReference    string         `json:"note_reference,omitempty"`
	NAGs             []string       `json:"nags,omitempty"`
}

type PlayCardSuffix

type PlayCardSuffix string

type Rank

type Rank string

type Risk

type Risk string

type Score

type Score[T int | float32] struct {
	Declarer   T `json:"declarer"`
	EastWest   T `json:"east_west"`
	NorthSouth T `json:"north_south"`
}

func GetScore

func GetScore[T int | float32](s string) (Score[T], error)

type Seat

type Seat string

func GetHidden

func GetHidden(s string) ([]Seat, error)

type Suit

type Suit string

type Time

type Time struct {
	Hours   int `json:"hours"`
	Minutes int `json:"minutes"`
	Seconds int `json:"seconds"`
}

func ParseTime

func ParseTime(s string) (Time, error)

type TimeControl

type TimeControl struct {
	Games   int `json:"games,omitempty"`
	Minutes int `json:"minutes,omitempty"`
}

func GetTimeControl

func GetTimeControl(s string) (TimeControl, error)

type Trick

type Trick struct {
	PlayCards []PlayCard `json:"play_cards"`
}

Jump to

Keyboard shortcuts

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