moveWindow
untyped bigint// seconds a player has for each move
Value
(86400 <untyped> bigint)
openWindow
untyped bigint// seconds an open challenge stays on the board
Value
(604800 <untyped> bigint)
maxBox
untyped bigint// bytes
Value
(104 <untyped> bigint)
maxPage
untyped bigintValue
(50 <untyped> bigint)
maxCleared
untyped bigint// expired challenges one Challenge deletes at most
Value
(8 <untyped> bigint)
idDigits
untyped bigintValue
(10 <untyped> bigint)
phaseOpen
untyped stringValue
"open"
phaseReveal
untyped stringValue
"reveal"
phasePlay
untyped stringValue
"play"
phaseEnded
untyped stringValue
"ended"
phaseExpired
untyped string// reported for an open match past its expiry, never stored
Value
"expired"
lastID
intValue
5
OpenChallenge
typeOpenChallenge is an open challenge as the board lists it.
Value
arena.OpenChallenge
Challenge
func(clan string, deckSeal string, planSeal string, box string, opponent .uverse.address) stringChallenge 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.
- OID
- 0a8c52…099f:4
Challenge details
Open
func(offset int, limit int) []arena.OpenChallengeOpen lists open, unexpired challenges, newest first: limit of them after skipping offset. limit is 1 to 50.
- OID
- 0a8c52…099f:6
Open details
forget
func(id int, challenger .uverse.address)forget deletes open challenge id and its place among its challenger's matches. Its entry on the open list is the caller's to remove.
- OID
- 0a8c52…099f:7
forget details
checkPage
func(offset int, limit int)- OID
- 0a8c52…099f:8
checkPage details
boxBytes
func(text string) stringboxBytes decodes a box argument: the standard base64 of 1 to maxBox bytes, in the one form that encodes them, so Match returns every box exactly as it was sent.
- OID
- 0a8c52…099f:9
boxBytes details
canonical
func(a .uverse.address) boolcanonical accepts a valid address in the lowercase form callers carry. bech32 also allows uppercase, which would never equal a caller's address.
- OID
- 0a8c52…099f:10
canonical details
validSeal
func(s string) boolvalidSeal accepts a sha256 sum in lowercase hex.
- OID
- 0a8c52…099f:11
validSeal details
chunkSize
untyped bigint// match ids per chunk
Value
(64 <untyped> bigint)
addressSize
untyped bigint// bytes in an address's text
Value
(40 <untyped> bigint)
sealSize
untyped bigint// bytes in a raw sha256 seal
Value
(32 <untyped> bigint)
lockSize
untyped bigintValue
(48 <untyped> bigint)
openSize
untyped bigintValue
(8 <untyped> bigint)
standingFix
untyped bigint// a standing's bytes before its per-clan counts
Value
(9 <untyped> bigint)
clanSize
untyped bigintValue
(14 <untyped> bigint)
planBits
untyped bigint// bits per round in a side's plans: 2 for the length, 6 per card
Value
(20 <untyped> bigint)
cardBits
untyped bigintValue
(6 <untyped> bigint)
maxPlanLen
untyped bigintValue
(3 <untyped> bigint)
maxRound
untyped bigintValue
(3 <untyped> bigint)
maxPool
untyped bigint// cards in a clan's pool; a deck is one bit per pool card
Value
(16 <untyped> bigint)
bitsAt
func(v uint64, at uint, width uint) uint64bitsAt returns the width bits of v starting at bit at.
- OID
- 0a8c52…099f:12
bitsAt details
withBits
func(v uint64, at uint, width uint, x uint64) uint64withBits returns v with the width bits at bit at replaced by x.
- OID
- 0a8c52…099f:14
withBits details
mask
func(width uint) uint64- OID
- 0a8c52…099f:15
mask details
planAt
func(plans uint64, round int) engine.PlanplanAt returns the plan made for round, or nil when it is not yet made.
- OID
- 0a8c52…099f:16
planAt details
withPlan
func(plans uint64, round int, p engine.Plan) uint64withPlan returns plans with round's plan set to p.
- OID
- 0a8c52…099f:17
withPlan details
plansMade
func(plans uint64) intplansMade counts the rounds from the first that have a plan.
- OID
- 0a8c52…099f:18
plansMade details
planOffset
func(round int) uint- OID
- 0a8c52…099f:19
planOffset details
deckOnPool
func(pool uint64, deck uint64) uint16deckOnPool returns deck, a set of card ids, as one bit per card of pool in id order.
- OID
- 0a8c52…099f:20
deckOnPool details
deckFromPool
func(pool uint64, bits uint16) uint64deckFromPool is the inverse of deckOnPool.
- OID
- 0a8c52…099f:21
deckFromPool details
cardsIn
func(pool uint64) uint- OID
- 0a8c52…099f:22
cardsIn details
writer
typeValue
arena.writer
reader
typeValue
arena.reader
record
typerecord is a match as the arena works on it, decoded from its stored bytes. clans holds each side's index in the ruleset plus one, 0 for none; decks and plans are the engine's card sets and the packed plans of withPlan; hp is the HP after each round, per side; carried holds only the Vulnerable and Strength left after the last resolved round. deckSeal and seal are 64 hex characters; box is the raw bytes, up to maxBox, stored with a 2-byte length.
Value
arena.record
flagOpponent
untyped bigintValue
(1 <untyped> bigint)
flagDeckSeal
untyped bigintValue
(2 <untyped> bigint)
flagSealBox
untyped bigintValue
(4 <untyped> bigint)
phaseNames
[]stringThe value of each name is its index; 0 of result and reason is none.
- OID
- 0a8c52…099f:24
phaseNames details
resultNames
[]stringThe value of each name is its index; 0 of result and reason is none.
- OID
- 0a8c52…099f:26
resultNames details
reasonNames
[]stringThe value of each name is its index; 0 of result and reason is none.
- OID
- 0a8c52…099f:28
reasonNames details
nameIndex
func(names []string, s string, what string) uint64- OID
- 0a8c52…099f:29
nameIndex details
nameAt
func(names []string, i uint64, what string) string- OID
- 0a8c52…099f:30
nameAt details
encodeMatch
func(rules *engine.Ruleset, m arena.record) string- OID
- 0a8c52…099f:31
encodeMatch details
decodeMatch
func(rules *engine.Ruleset, b string) arena.record- OID
- 0a8c52…099f:32
decodeMatch details
clanNibble
func(rules *engine.Ruleset, clan int) uint64clanNibble is a clan's stored form, its ruleset index plus one, checked against rules.
- OID
- 0a8c52…099f:33
clanNibble details
poolOf
func(rules *engine.Ruleset, clan int) uint64poolOf returns the card pool of clan, 0 for no clan.
- OID
- 0a8c52…099f:34
poolOf details
chunkRecord
func(chunk string, slot int) stringchunkRecord returns the record in slot, or "" when it is removed or beyond the chunk.
- OID
- 0a8c52…099f:35
chunkRecord details
withChunkRecord
func(chunk string, slot int, rec string) stringwithChunkRecord returns chunk with slot's record set to rec, adding empty slots up to it.
- OID
- 0a8c52…099f:36
withChunkRecord details
playerRecord
typeplayerRecord is what the arena keeps per player: the ids of their matches, oldest first, their standing, nil until their first rated match, and the session locks that bind a session key to one match.
Value
arena.playerRecord
standing
typestanding is a player's rated record. lastClan is the clan number, index plus one, of their last rated match; perClan\[i] counts their rated matches with clan number i + 1.
Value
arena.standing
sessionLock
typeValue
arena.sessionLock
decodePlayer
func(s string) arena.playerRecordA player's bytes are a 2-byte id count, the ids at 4 bytes each, a 1-byte standing length, 0 for none, the standing, then the locks. A standing is the rating, wins, losses and draws at 2 bytes each, the last clan at 1, then a 2-byte count per clan. ceiling: joining a match or changing a lock rewrites all of a player's ids, up to 65,535, so gas grows with their matches; an avl index of ids per player if some play thousands.
- OID
- 0a8c52…099f:37
decodePlayer details
decodeStanding
func(s string) *arena.standingdecodeStanding reads only the standing of a player's bytes, skipping their ids, so its cost does not grow with the player's matches; nil when they have none.
- OID
- 0a8c52…099f:38
decodeStanding details
withStanding
func(s string, st *arena.standing) stringwithStanding returns a player's bytes s with their standing replaced by st. It copies the ids and locks without reading them, so its cost does not grow with the player's matches.
- OID
- 0a8c52…099f:39
withStanding details
readStanding
func(r *arena.reader) *arena.standing- OID
- 0a8c52…099f:40
readStanding details
encodePlayer
func(p arena.playerRecord) string- OID
- 0a8c52…099f:41
encodePlayer details
writeStanding
func(w *arena.writer, st *arena.standing)- OID
- 0a8c52…099f:42
writeStanding details
ladderKey
func(rating int, player .uverse.address) stringladderKey orders the ladder: highest rating first, then address order.
- OID
- 0a8c52…099f:43
ladderKey details
clanRecord
typeclanRecord is a clan's rating and its record in rated matches against other clans.
Value
arena.clanRecord
decodeClans
func(s string, n int) []arena.clanRecordThe clan records are one string holding, per clan in ruleset order, the rating at 2 bytes and the wins, losses and draws at 4 each. decodeClans returns n clans; a clan past the end of s has no rated match yet.
- OID
- 0a8c52…099f:44
decodeClans details
encodeClans
func(c []arena.clanRecord) string- OID
- 0a8c52…099f:45
encodeClans details
openEntry
typeopenEntry is a challenge on the board: its match id and expiry in Unix seconds.
Value
arena.openEntry
openEntries
func(s string) []arena.openEntry- OID
- 0a8c52…099f:46
openEntries details
encodeOpen
func(entries []arena.openEntry) string- OID
- 0a8c52…099f:47
encodeOpen details
guard
func(fromUser bool, caller .uverse.address, m arena.record, id int)guard binds the session that signed the transaction to match id, held in m, saving the caller's record only when its locks change.
- OID
- 0a8c52…099f:48
guard details
join
func(fromUser bool, caller .uverse.address, id int)join adds match id to the caller's record and binds the session that signed the transaction to it, refused when that session is bound to a match already.
- OID
- 0a8c52…099f:50
join details
signingSession
func(fromUser bool) (.uverse.address, int64, bool)- OID
- 0a8c52…099f:51
signingSession details
lockSession
func(locks []arena.sessionLock, session .uverse.address, expires int64, id int, opening bool, now int64) (kept []arena.sessionLock, changed bool, refusal string)lockSession binds session to match id, refused when bound to another, or any when opening. It drops expired locks and any lock its key holds under another expiry (Unix seconds, 0 never).
- OID
- 0a8c52…099f:52
lockSession details
self
stringself is the arena's package path; a deploy under another path changes it.
Value
"gno.land/r/g188vafzutzvlfw6wt7u3s62xtuvm0epmu8ufmfz/gnomepit/arena"
pagePath
untyped stringpagePath is where the page lives on its origin, the start of every trigger's link; the registry accepts only a link that starts with "/".
Value
"/gnomepit/"
init.81
func()- OID
- 0a8c52…099f:54
init.81 details
tell
func(kind string, player .uverse.address, caller .uverse.address, id int, text string)tell emits kind to player about match id. It emits nothing when player made the call, so an event never names its caller.
- OID
- 0a8c52…099f:56
tell details
tellBoard
func(id int, text string)tellBoard emits Board about match id, whose change altered the open-challenge list. It names no address, so a caller cannot aim it at one player's browser.
- OID
- 0a8c52…099f:57
tellBoard details
tellEnded
func(m arena.record, id int, caller .uverse.address)tellEnded sends Ended to each player of the finished match m, numbered id, but caller, one event each, since gnotif reads only the first value of a repeated attribute.
- OID
- 0a8c52…099f:58
tellEnded details
endText
func(m arena.record, side int) stringendText says how m ended to the player on side.
- OID
- 0a8c52…099f:59
endText details
Accept
func(id string, clan string, deck string, plan string)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.
- OID
- 0a8c52…099f:60
Accept details
Reveal
func(id string, deck string, deckSalt string, plan string, planSalt string, nextSeal string, nextBox string)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.
- OID
- 0a8c52…099f:62
Reveal details
Play
func(id string, plan string)Play records the acceptor's plan for the round being played.
- OID
- 0a8c52…099f:63
Play details
Resign
func(id string)Resign withdraws the caller's open challenge, expired or not, deleting it, or concedes a running match.
- OID
- 0a8c52…099f:64
Resign details
ClaimForfeit
func(id string)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.
- OID
- 0a8c52…099f:65
ClaimForfeit details
find
func(rules *engine.Ruleset, id string) (int, arena.record)- OID
- 0a8c52…099f:66
find details
lookup
func(rules *engine.Ruleset, id string) (int, arena.record, bool)lookup returns the match id names, false when there is none. Only an id's own decimal text names it, never "01" or "+1".
- OID
- 0a8c52…099f:67
lookup details
stateOf
func(rules *engine.Ruleset, m arena.record) engine.StatestateOf rebuilds the engine state the next round of m starts from. A round is resolved once the challenger's plan for it is stored; the specials of resolved rounds are spent.
- OID
- 0a8c52…099f:68
stateOf details
checkSeal
func(seal string, salt string, text string)checkSeal panics unless seal is the sha256 of salt's bytes followed by text.
- OID
- 0a8c52…099f:69
checkSeal details
clanNumber
func(rules *engine.Ruleset, clan string) intclanNumber is clan's index in rules plus one, as a record stores it, or 0 when no clan has that name.
- OID
- 0a8c52…099f:70
clanNumber details
clanName
func(rules *engine.Ruleset, n int) stringclanName is the name of the clan a record stores as n, "" for none.
- OID
- 0a8c52…099f:71
clanName details
planOf
func(rules *engine.Ruleset, text string) engine.PlanplanOf maps comma-separated card names to the engine's ids.
- OID
- 0a8c52…099f:72
planOf details
deckBits
func(rules *engine.Ruleset, c engine.Clan, deck string) uint64deckBits returns deck as the engine's bit set, panicking unless it is legal for c. A card named twice is illegal, so a legal deck text holds exactly the deck's names.
- OID
- 0a8c52…099f:73
deckBits details
legal
func(rules *engine.Ruleset, s engine.State, side engine.Side, deck uint64, p engine.Plan) bool- OID
- 0a8c52…099f:74
legal details
samePlan
func(p engine.Plan, q engine.Plan) bool- OID
- 0a8c52…099f:75
samePlan details
resultName
func(r engine.Result) string- OID
- 0a8c52…099f:76
resultName details
reasonOf
func(s engine.State) stringreasonOf says why a finished match ended: a gnome at 0 HP or less is a knockout.
- OID
- 0a8c52…099f:77
reasonOf details
MatchSummary
typeMatchSummary 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.
Value
arena.MatchSummary
MatchView
typeMatchView 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.
Value
arena.MatchView
SessionLock
typeSessionLock 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.
Value
arena.SessionLock
Standing
typeStanding 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.
Value
arena.Standing
ClanStanding
typeClanStanding is one clan's record across rated cross-clan matches.
Value
arena.ClanStanding
Leaderboard
func(offset int, limit int) []arena.StandingLeaderboard lists rated players, highest rating first: limit of them after skipping offset.
- OID
- 0a8c52…099f:78
Leaderboard details
StandingOf
func(player .uverse.address) arena.StandingStandingOf returns player's standing, rated or not.
- OID
- 0a8c52…099f:80
StandingOf details
RatedPlayers
func() intRatedPlayers counts the players on the ladder.
- OID
- 0a8c52…099f:81
RatedPlayers details
ClanStandings
func() []arena.ClanStandingClanStandings lists every clan of the ruleset, highest rating first; equal ratings keep ruleset order and share a rank.
- OID
- 0a8c52…099f:82
ClanStandings details
standingOf
func(rules *engine.Ruleset, player .uverse.address) arena.StandingstandingOf is player's standing without its rank.
- OID
- 0a8c52…099f:83
standingOf details
nameOf
func(player .uverse.address) stringnameOf is player's gno.land name, "" when they have none.
- OID
- 0a8c52…099f:84
nameOf details
Locks
func(player .uverse.address) []arena.SessionLockLocks lists player's session locks. It can include locks whose session has expired.
- OID
- 0a8c52…099f:85
Locks details
Matches
func(player .uverse.address, offset int, limit int) []arena.MatchSummaryMatches lists player's matches, newest first: limit of them after skipping offset.
- OID
- 0a8c52…099f:86
Matches details
Match
func(id string) arena.MatchViewMatch returns the view of match id.
- OID
- 0a8c52…099f:87
Match details
deckText
func(rules *engine.Ruleset, deck uint64) stringdeckText names the cards of deck in card id order.
- OID
- 0a8c52…099f:88
deckText details
planText
func(rules *engine.Ruleset, p engine.Plan) stringplanText names the cards of p in play order.
- OID
- 0a8c52…099f:89
planText details
startRating
untyped bigintValue
(1000 <untyped> bigint)
maxRating
untyped bigint// a ladder key holds the rating in 2 bytes
Value
(65535 <untyped> bigint)
playerK
untyped bigintValue
(32 <untyped> bigint)
clanK
untyped bigintValue
(16 <untyped> bigint)
expectedTable
[17]intexpectedTable is the expected score, in thousandths, of a side whose opponent is rated 0, 25, …, 400 points above it: 1 / (1 + 10^(d / 400)), rounded.
- OID
- 0a8c52…099f:91
expectedTable details
expected
func(a int, b int) intexpected is the expected score, in thousandths, of a side rated a against one rated b. The gap is capped at 400 points and rounded to the nearest 25.
- OID
- 0a8c52…099f:92
expected details
eloChange
func(a int, b int, score int, k int) inteloChange is the change, rounded to the nearest point, of a side rated a that scored score thousandths (1000 a win, 500 a draw, 0 a loss) against one rated b.
- OID
- 0a8c52…099f:94
eloChange details
applyChange
func(a int, b int, delta int) (int, int)applyChange gives a the change delta and b its negative, each kept within 0 to maxRating.
- OID
- 0a8c52…099f:95
applyChange details
clampRating
func(r int) int- OID
- 0a8c52…099f:96
clampRating details
rate
func(rules *engine.Ruleset, m arena.record)rate counts match m, which has just ended, in both players' standings and on the ladder, and in the clan records when two different clans met. A match its challenger accepted is not rated.
- OID
- 0a8c52…099f:97
rate details
ratedStanding
func(rules *engine.Ruleset, a .uverse.address) *arena.standingratedStanding returns a's standing, created at startRating for a first rated match, with a count for every clan of rules, and takes its key off the ladder until it is counted.
- OID
- 0a8c52…099f:98
ratedStanding details
scoreOf
func(result string) intscoreOf is the challenger's score, in thousandths, in a match that ended with result.
- OID
- 0a8c52…099f:99
scoreOf details
tally
func(score int, wins *int, losses *int, draws *int)- OID
- 0a8c52…099f:100
tally details
rankOf
func(rating int) intrankOf is the rank a rating holds: 1 plus the number of players rated above it.
- OID
- 0a8c52…099f:101
rankOf details
notFound
untyped stringValue
"# Not found\n\nThe arena has no page at this path.\n"
Render
func(path string) stringRender serves the board of open challenges at "", one player's matches at "player/\<address>", and one match at "match/\<id>".
- OID
- 0a8c52…099f:102
Render details
renderBoard
func() string- OID
- 0a8c52…099f:104
renderBoard details
renderPlayer
func(player .uverse.address) string- OID
- 0a8c52…099f:105
renderPlayer details
renderMatch
func(v arena.MatchView) string- OID
- 0a8c52…099f:106
renderMatch details
outcome
func(result string, reason string) string- OID
- 0a8c52…099f:107
outcome details
matchLink
func(id string) string- OID
- 0a8c52…099f:108
matchLink details
date
func(unix int64) string- OID
- 0a8c52…099f:109
date details
orNone
func(s string) string- OID
- 0a8c52…099f:110
orNone details
chunks
v0.Tree// 4-byte chunk number → chunk string
- OID
- 0a8c52…099f:112
chunks details
players
v0.Tree// address → player string
- OID
- 0a8c52…099f:114
players details
ladder
*v0.Node// ladderKey of every rated player → nil
- OID
- 0a8c52…099f:251
ladder details
clanRecords
stringValue
"\x03�\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03�\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x03�\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00"
openList
stringValue
""
chunkKey
func(id int) string- OID
- 0a8c52…099f:118
chunkKey details
loadMatch
func(rules *engine.Ruleset, id int) (arena.record, bool)loadMatch returns match id, or false when it does not exist or was removed.
- OID
- 0a8c52…099f:120
loadMatch details
saveMatch
func(rules *engine.Ruleset, id int, m arena.record)- OID
- 0a8c52…099f:121
saveMatch details
dropMatch
func(id int)dropMatch removes match id; an absent id is left alone.
- OID
- 0a8c52…099f:122
dropMatch details
putRecord
func(id int, rec string)- OID
- 0a8c52…099f:123
putRecord details
stringAt
func(t *v0.Tree, key string) stringstringAt returns the string under key, "" when there is none.
- OID
- 0a8c52…099f:124
stringAt details
loadPlayer
func(a .uverse.address) arena.playerRecord- OID
- 0a8c52…099f:125
loadPlayer details
savePlayer
func(a .uverse.address, p arena.playerRecord)- OID
- 0a8c52…099f:126
savePlayer details
loadStanding
func(a .uverse.address) *arena.standingloadStanding returns a's standing, nil before their first rated match.
- OID
- 0a8c52…099f:127
loadStanding details
saveStanding
func(a .uverse.address, st *arena.standing)- OID
- 0a8c52…099f:128
saveStanding details
openAdd
func(id int, expires int64)ceiling: each change rewrites the whole open list, 8 bytes per open challenge, so its gas grows with the board; an avl index keyed by expiry and id if the board holds thousands.
- OID
- 0a8c52…099f:129
openAdd details
openRemove
func(id int)- OID
- 0a8c52…099f:130
openRemove details
openNewest
func(now int64, offset int, limit int) []intopenNewest returns up to limit unexpired ids, newest first, after skipping offset of them.
- OID
- 0a8c52…099f:131
openNewest details
openClear
func(now int64, max int) []intopenClear removes up to max expired entries from the front and returns their ids.
- OID
- 0a8c52…099f:132