boards

package
v0.1.131 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 15 Imported by: 1 module, 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.

Documentation

Overview

Package boards holds the rules for the boards a mod declares in its manifest: which declarations a build may carry, and which partition values a score may name. A host that serves the scores service checks reports with the same rules.

Index

Constants

View Source
const (
	// MaxScoreValue bounds a score's magnitude, and a KEEP_SUM standing
	// saturates at it, so a value read as a JSON number stays exact.
	MaxScoreValue = 1<<53 - 1
	// MaxReportScores bounds the scores one submission ranks: the players of
	// the largest match a server reports.
	MaxReportScores = 64
	// MaxKeyBytes bounds the key a mod names for a round or run.
	MaxKeyBytes = 128
	// MaxEvidenceBytes bounds what a submission names as its evidence.
	MaxEvidenceBytes = 256
	// EarnedGrace is how long before its report a score may have been
	// earned, so a late report cannot land in a window that already closed.
	EarnedGrace = time.Hour
)
View Source
const MaxTeamSize = 4

MaxTeamSize is the most players a team board's team holds.

View Source
const Service = "scores"

Service names the service mods report scores to and read boards from.

Variables

This section is empty.

Functions

func Answer

func Answer(local *Local, manifest *wasm.Manifest, seats Seats, names func(uint64) string, method string, payload []byte, now time.Time) ([]byte, string, error)

Answer answers one call to the scores service for the mod manifest describes, from local: Report and Match rank their scores, and Read returns a page. seats checks each connection the call names; nil trusts a host that checked them before passing the call on. names gives each player's name. Besides the reply it returns a line that says what a report ranked, or why the board held it back, for the session's log.

func Find

func Find(manifest *wasm.Manifest, name string) *scorespb.Board

Find returns the board named name that manifest declares, or nil.

func Partitioned

func Partitioned(board *scorespb.Board, values map[string]string) error

Partitioned checks that values names one accepted value for each of board's partitions and nothing else.

func TeamEntrant

func TeamEntrant(members []uint64) uint64

TeamEntrant is the entrant members rank under on a board that ranks teams: a hash of their sorted SteamID64s in the team range, so the same players in any order are one team.

func Teamed

func Teamed(board *scorespb.Board, player int32, teammates []int32) error

Teamed checks that a score or read on board names its teammates as the board's team takes them: the team size less one on a team board, each a different player and none the scoring player, and none on a board of single players. player is the scoring or reading player's slot, and teammates are the slots of the players the call names.

func Validate

func Validate(manifest *wasm.Manifest) error

Validate checks the boards manifest declares.

func Windows

func Windows(board *scorespb.Board) []scorespb.Window

Windows returns the windows board keeps standings for: its declared windows, or all time alone when it declares none.

Types

type Binder

type Binder struct {
	// Seat names each slot's live player.
	Seat Seat
	// contains filtered or unexported fields
}

Binder issues the proofs a host gives a mod for the connections it serves, and checks them when the mod reports. A proof stays valid after its player leaves, so a mod can report a departed player's score. It implements Seats. It is safe for concurrent use.

func (*Binder) Bind

Bind returns conn with its proof when its player holds its slot on that generation, and an error otherwise. Binding a connection again returns the same proof.

func (*Binder) Bound

func (b *Binder) Bound(conn *scorespb.ScoreConnection, slot int32) bool

Bound reports whether the Binder issued conn's proof for slot.

func (*Binder) Live

func (b *Binder) Live(conn *scorespb.ScoreConnection, slot int32) bool

Live reports whether conn names the player who holds slot now.

type Entry

type Entry struct {
	// SteamID is the scoring player.
	SteamID uint64
	// Members are the team's players, the scoring one included, on a board
	// that ranks teams, and none on a board of single players.
	Members []uint64
	// Value is the entry's score in the board's unit.
	Value int64
	// Tiebreak ranks equal values, lower first.
	Tiebreak int64
}

Entry is one entrant's score in a submission.

type Local

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

Local ranks one session's scores in memory, by the rules a published board ranks them by, for a host with no backend: a sandbox or a game on the author's computer. Its standings last as long as the Local.

It ranks scores from every server tier, where a published board holds back scores from a server below its declared tier; it keeps every other rule. It is safe for concurrent use.

func NewLocal

func NewLocal() *Local

NewLocal returns an empty Local.

func (*Local) Page

func (l *Local) Page(board *scorespb.Board, query *scorespb.BoardQuery, viewer uint64, names func(uint64) string, now time.Time) *scorespb.BoardPage

Page reads the page of board that query selects at now, with viewer's own standing when viewer, a player or TeamEntrant, holds one. names gives each player's name. An omitted window reads all time, and an omitted partition value reads the partition's first declared value. A window or partition the board does not keep reads empty.

func (*Local) Record

func (l *Local) Record(sub Submission, now time.Time) (string, error)

Record ranks the entries of sub at now. It refuses the whole submission or none of it; a resent submission changes nothing, and a different one with the same key is refused. It returns why the board holds back any entry of an accepted submission, a value outside its lowest and highest, or "" when every entry ranks.

type Seat

type Seat func(slot int32) (steamID uint64, generation uint32, ok bool)

Seat names the player who holds slot now, with the slot's generation, and ok false when no human holds it.

func (Seat) Holds

func (seat Seat) Holds(connection *scorespb.ScoreConnection, slot int32) bool

Holds reports whether connection names the player who holds slot now.

type Seats

type Seats interface {
	// Bound reports whether the host bound connection for the mod while it
	// served the player in slot. Reports and matches carry bound connections,
	// so a mod can report a player who has since left.
	Bound(connection *scorespb.ScoreConnection, slot int32) bool
	// Live reports whether connection still holds slot. A read names the
	// viewer's live connection, with no proof.
	Live(connection *scorespb.ScoreConnection, slot int32) bool
}

Seats checks the connections a scores call names. Answer refuses a call whose player, teammate or participant fails its check.

type Submission

type Submission struct {
	// Board is the declared board the entries rank on.
	Board *scorespb.Board
	// Key names the submission's receipt; the same key with the same
	// contents is the same submission. The host frames it, so a mod's own
	// key cannot name another player's implicit one.
	Key string
	// Partition names one value of each of the board's partitions.
	Partition map[string]string
	// Earned is when the scores were earned, in Unix milliseconds; zero
	// means when they are recorded.
	Earned int64
	// Evidence is what the mod names as the scores' evidence.
	Evidence string
	// Entries are the scores, one per player.
	Entries []Entry
}

Submission is one report or match: the entries it ranks together, all or none.

Jump to

Keyboard shortcuts

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