Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

v0 source realm

Package profiles keeps the Gnoslinger players' records (games played, victory points) and their ranking apart from th...

Overview

Package profiles keeps the Gnoslinger players' records (games played, victory points) and their ranking apart from the game realm, so a new version of the game (new rules) keeps the scores. Only the game realms on the allowlist may write; the admin, the deployer, manages that list.

Constants 1

const MaxPage

1const MaxPage = 50
source

MaxPage bounds PlayersJSON and json/players/{offset}/{count}.

Functions 15

func AddGamePlayed

crossing Action
1func AddGamePlayed(cur realm, addr address)
source

AddGamePlayed counts a game that started for addr.

func AddVictoryPoints

crossing Action
1func AddVictoryPoints(cur realm, addr address, points int)
source

AddVictoryPoints adds an award's points (< 0 for a loss) to addr's total.

func Allow

crossing Action
1func Allow(cur realm, pkgPath string)
source

Allow lets the game realm pkgPath write the profiles (a new version of the game).

func Disallow

crossing Action
1func Disallow(cur realm, pkgPath string)
source

Disallow stops pkgPath from writing (a game version no longer scored); its calls panic from then on.

func Ensure

crossing Action
1func Ensure(cur realm, addr address)
source

Ensure creates addr's profile if it has none yet.

func IsGame

Action
1func IsGame(pkgPath string) bool
source

IsGame tells whether the realm pkgPath may write the profiles.

func Name

Action
1func Name(addr address) string
source

Name is addr's name in gno.land/r/sys/users (where namereg registers them), or "".

func PlayersJSON

Action
1func PlayersJSON(offset, count int) string
source

PlayersJSON is one page of the ranking, best first, count at most MaxPage:

Example
1{"total","offset","players":[profile...]}

func ProfileJSON

Action
1func ProfileJSON(addr string) string
source

ProfileJSON is the profile of an address, or null when it has none yet:

Example
1{"addr","name","rank","gamesPlayed","victoryPoints","createdAt"}

name is the address's name in gno.land/r/sys/users, "" if none.

func Rank

Action
1func Rank(addr address) int
source

Rank is addr's 1-based position in the ranking, 0 without a profile.

func Render

1func Render(path string) string
source

Render serves the ranking page ("") and the raw JSON views the web client reads ("json/profile/{addr}", "json/players/{offset}/{count}").

func SetAdmin

crossing Action
1func SetAdmin(cur realm, addr address)
source

SetAdmin hands the allowlist over to addr.

func Get

Action
1func Get(addr address) (Profile, bool)
source

Get is a copy of addr's profile, false when it has none.

Types 1

type Profile

struct
 1type Profile struct {
 2	Addr address
 3	// GamesPlayed counts the games the player sat in once they started (a
 4	// second player joined); a cancelled showdown does not count.
 5	GamesPlayed int
 6	// VictoryPoints adds up the points of the player's finished games (rule
 7	// 15); it may be negative.
 8	VictoryPoints int
 9	CreatedAt     time.Time
10}
source

Profile is a player's record, created the first time the address creates or joins a game.

Dependencies

Source Files 4