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.

arena source realm

Package arena holds Gnomepit's online matches. A challenger posts a sealed deck and round-1 plan; an acceptor answers...

Overview

Package arena holds Gnomepit's online matches. A challenger posts a sealed deck and round-1 plan; an acceptor answers face up; the challenger reveals each round with the seal of the next, and the shared duel engine checks and resolves every move. A session key is bound to the match of the first call it signs: it then acts in no other match and posts or accepts nothing more. Calls the wallet signs are never bound.

Functions 15

func Accept

crossing Action
1func Accept(cur realm, id, clan, deck, plan string)
source

Accept answers open challenge id as clan, with deck and the round-1 plan in plain text. When the challenge names an opponent, only that address may accept.

func Challenge

crossing Action
1func Challenge(cur realm, clan, deckSeal, planSeal, box string, opponent address) string
source

Challenge posts a challenge for clan with the seals of the challenger's deck and round-1 plan, the box holding both, and an opponent who alone may accept, or none. It returns the new match's id. It first deletes up to 8 expired challenges, whoever posted them.

func ClaimForfeit

crossing Action
1func ClaimForfeit(cur realm, id string)
source

ClaimForfeit ends a running match whose deadline has passed: the player who had to move loses. Any wallet may claim it; a session may claim only a match its wallet plays.

func Play

crossing Action
1func Play(cur realm, id, plan string)
source

Play records the acceptor's plan for the round being played.

func Render

1func Render(path string) string
source

Render serves the board of open challenges at "", one player's matches at "player/<address>", and one match at "match/<id>".

func Resign

crossing Action
1func Resign(cur realm, id string)
source

Resign withdraws the caller's open challenge, expired or not, deleting it, or concedes a running match.

func Reveal

crossing Action
1func Reveal(cur realm, id, deck, deckSalt, plan, planSalt, nextSeal, nextBox string)
source

Reveal opens the challenger's sealed plan for the round being played, and on the first reveal the sealed deck, then resolves the round. A match that goes on needs nextSeal and nextBox for the challenger's next plan; one that ends takes neither.

func ClanStandings

Action
1func ClanStandings() []ClanStanding
source

ClanStandings lists every clan of the ruleset, highest rating first; equal ratings keep ruleset order and share a rank.

func Matches

Action
1func Matches(player address, offset, limit int) []MatchSummary
source

Matches lists player's matches, newest first: limit of them after skipping offset.

func Match

Action
1func Match(id string) MatchView
source

Match returns the view of match id.

func Open

Action
1func Open(offset, limit int) []OpenChallenge
source

Open lists open, unexpired challenges, newest first: limit of them after skipping offset. limit is 1 to 50.

func Locks

Action
1func Locks(player address) []SessionLock
source

Locks lists player's session locks. It can include locks whose session has expired.

func Leaderboard

Action
1func Leaderboard(offset, limit int) []Standing
source

Leaderboard lists rated players, highest rating first: limit of them after skipping offset.

func StandingOf

Action
1func StandingOf(player address) Standing
source

StandingOf returns player's standing, rated or not.

Types 6

type ClanStanding

struct
1type ClanStanding struct {
2	Rank                int
3	Clan                string
4	Rating              int
5	Wins, Losses, Draws int
6}
source

ClanStanding is one clan's record across rated cross-clan matches.

type MatchSummary

struct
 1type MatchSummary struct {
 2	ID, Phase                    string
 3	Round                        int
 4	Challenger, Acceptor         string
 5	ChallengerClan, AcceptorClan string
 6	ToMove                       string
 7	Deadline                     int64
 8	Result, Reason               string
 9	Opponent                     string
10}
source

MatchSummary is one match as a player's list shows it. Round is the round being played, or the last one resolved once the match is over. ToMove is the address that must move next, empty when none. Deadline is the end of the current move's 24 hours, or the expiry of an open challenge, in Unix seconds. Opponent is the address an open challenge is reserved for, "" when anyone can accept it and once accepted.

type MatchView

struct
1type MatchView struct {
2	MatchSummary
3	ChallengerDeck, AcceptorDeck string
4	Plans                        [][]string
5	Box                          string
6	HP                           [][]int
7	DeadlinePassed               bool
8}
source

MatchView is everything one match screen needs. Plans holds [challenger, acceptor] for each resolved round, and for the round being played while the match runs, "" while a plan is sealed or not yet made; HP holds both sides' HP after each resolved round; Box is the challenger's encrypted pending plan, in base64.

type OpenChallenge

struct
1type OpenChallenge struct {
2	ID, Challenger, Clan, Opponent string
3	Posted, Expires                int64
4}
source

OpenChallenge is an open challenge as the board lists it.

type SessionLock

struct
1type SessionLock struct {
2	Session, Match string
3	Expires        int64
4}
source

SessionLock binds the session key at address Session to the match whose id is Match. Expires is the session's expiry in Unix seconds, 0 for none.

type Standing

struct
1type Standing struct {
2	Rank                   int
3	Player, Name, MainClan string
4	Rating                 int
5	Wins, Losses, Draws    int
6}
source

Standing is one player's place on the ladder. Rank is 1 for the highest rating and equal ratings share it; Rank is 0 and Rating 1000 for a player with no rated match. Name is the player's gno.land name, "" without one. MainClan is "" until their first rated match.

Dependencies

Source Files 10