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

v0 state

Back to all declarations

callerOf

func(int, rlm .uverse.realm) .uverse.address
Open
OID
051142…d347:3
callerOf details

Inspect func

assertOwner

func(int, rlm .uverse.realm) .uverse.address
Open
OID
051142…d347:5
assertOwner details

Inspect func

assertAdmin

func(int, rlm .uverse.realm) .uverse.address
Open
OID
051142…d347:6
assertAdmin details

Inspect func

assertReferee

func(int, rlm .uverse.realm) .uverse.address
Open
OID
051142…d347:7
assertReferee details

Inspect func

TransferOwnership

func(newOwner .uverse.address)

TransferOwnership hands the realm over to newOwner. Owner only. The previous owner keeps no privilege, unless it was also added to the admin or referee lists.

Open
OID
051142…d347:8
TransferOwnership details

Inspect func

AddAdmin

func(addr .uverse.address)

AddAdmin adds addr to the admin list. Owner only.

Open
OID
051142…d347:9
AddAdmin details

Inspect func

RemoveAdmin

func(addr .uverse.address)

RemoveAdmin removes addr from the admin list. Owner only. The owner is an admin by definition and cannot be demoted this way, use TransferOwnership.

Open
OID
051142…d347:10
RemoveAdmin details

Inspect func

SetTreasury

func(addr .uverse.address)

SetTreasury sets the address the sales of skins and planes are forwarded to. Owner only.

Open
OID
051142…d347:11
SetTreasury details

Inspect func

AddReferee

func(addr .uverse.address)

AddReferee allows addr to submit kills. Admin only.

Open
OID
051142…d347:12
AddReferee details

Inspect func

RemoveReferee

func(addr .uverse.address)

RemoveReferee stops addr from submitting kills. Admin only.

Open
OID
051142…d347:13
RemoveReferee details

Inspect func

IsAdmin

func(addr .uverse.address) bool

IsAdmin reports whether addr is an admin. The owner always is.

Open
OID
051142…d347:16
IsAdmin details

Inspect func

IsReferee

func(addr .uverse.address) bool

IsReferee reports whether addr may submit kills.

Open
OID
051142…d347:17
IsReferee details

Inspect func

errInvalidAddress

*errors.errorString
Open
OID
051142…d347:31
errInvalidAddress details

Inspect pointer

errAlreadyReferee

*errors.errorString
Open
OID
051142…d347:40
errAlreadyReferee details

Inspect pointer

errNoSuchReferee

*errors.errorString
Open
OID
051142…d347:43
errNoSuchReferee details

Inspect pointer

errInvalidBounds

*errors.errorString
Open
OID
051142…d347:52
errInvalidBounds details

Inspect pointer

errValueOutOfBounds

*errors.errorString
Open
OID
051142…d347:55
errValueOutOfBounds details

Inspect pointer

errLeaderboardMin

*errors.errorString
Open
OID
051142…d347:58
errLeaderboardMin details

Inspect pointer

owner

*v0.Ownable

// the single owner, always an admin

Open
OID
051142…d347:121
owner details

Inspect pointer

admins

v0.BPTree

// extra admins, managed by the owner: address -> nil

Open
OID
051142…d347:123
admins details

Inspect ref

referees

v0.BPTree

// game servers allowed to submit kills: address -> nil

Open
OID
051142…d347:124
referees details

Inspect ref

treasury

.uverse.address

// where the sales of the skins and planes realms go

Value

<gnolang.StringValue>

version

int64

// bumps on every admin write, see Version

Value

2

pilots

v0.BPTree

// player address -> int64 kills, allocated at the first kill

Open
OID
051142…d347:167
pilots details

Inspect ref

killers

v0.ranking

// the top players by kills recorded on-chain, see rankings.gno

Open
OID
051142…d347:353
killers details

Inspect ref

webPath

string

// "/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/game/v0", used to build links in Render

Value

"/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/game/v0"

bootstrap

func(deployer .uverse.address, pkgPath string)

bootstrap (re)creates the initial state: roles and params.

Open
OID
051142…d347:75
bootstrap details

Inspect func

Version

func() int64

Version returns a counter that bumps on every admin write: params, treasury and roles. Referee actions (kills) do not bump it. A reader that cached StateJSON only has to read it again when Version changed.

Open
OID
051142…d347:76
Version details

Inspect func

bump

func()

bump marks the admin-tunable state as changed.

Open
OID
051142…d347:77
bump details

Inspect func

webPathOf

func(pkgPath string) string

webPathOf turns "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/game/v0" into "/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/game/v0".

Open
OID
051142…d347:78
webPathOf details

Inspect func

StateJSON

func() string

StateJSON returns everything the game needs from the chain, as one JSON object: { "version": 12, "treasury": "g1...", "params": { "plane_speed": 70, "boost_speed": 130 } } The output has no whitespace. It only changes when Version does. The skins are in their own realm, gnofly/nfts/skins.

Open
OID
051142…d347:80
StateJSON details

Inspect func

PlayerJSON

func(addr .uverse.address) string

PlayerJSON returns one player as a JSON object: { "address": "g1...", "kills": 17 } The output has no whitespace. An unknown address has zero kills. The skins and planes a player owns are read from their realms (SkinsOf, PlanesOf).

Open
OID
051142…d347:82
PlayerJSON details

Inspect func

KillLeaderboardJSON

func() string

KillLeaderboardJSON returns the top players by kills recorded on-chain as a JSON array, best first, at most leaderboard\_size entries: [ { "address": "g1...", "kills": 17 } ] The output has no whitespace. With equal kills, the player who got there first stays ahead.

Open
OID
051142…d347:83
KillLeaderboardJSON details

Inspect func

quote

func(s string) string

quote returns s as a JSON string literal, quotes included. It is for the strings the realm did not validate. Quotes and backslashes are escaped and anything outside printable ASCII is replaced by "?", so the result is valid JSON whatever s holds.

Open
OID
051142…d347:84
quote details

Inspect func

maxKillEntries

untyped bigint

// players per SubmitKills call

Value

(32 <untyped> bigint)

maxKillCount

untyped bigint

// kills per player per call

Value

(1000 <untyped> bigint)

maxKillsLen

untyped bigint

Value

(2048 <untyped> bigint)

SubmitKills

func(kills string)

SubmitKills adds kills to players' on-chain counts. Referee only. kills is 1 to 32 entries "address:count" separated by ";", for example g1abc...:3;g1def...:1 Each address must be valid and listed once, each count from 1 to 1000. Anything else aborts the transaction and nothing is recorded. The counts are added to what the players already have, and the kill leaderboard is updated. Kills are player actions: Version does not move.

Open
OID
051142…d347:88
SubmitKills details

Inspect func

parseKills

func(s string) ([].uverse.address, []int64, .uverse.error)
Open
OID
051142…d347:90
parseKills details

Inspect func

killsEntryError

func(index int, reason string) .uverse.error
Open
OID
051142…d347:91
killsEntryError details

Inspect func

param

type

param is one tunable number of the game, with the bounds an admin has to stay within.

Value

v0.param

paramLeaderboardSize

untyped string

paramLeaderboardSize is the one param the realm itself consumes. Every other param is only stored here and applied by the game server.

Value

"leaderboard_size"

defaultParams

func() []*v0.param

defaultParams returns the registry with its default values. The order is the display order, in StateJSON as well as in Render.

Open
OID
051142…d347:92
defaultParams details

Inspect func

findParam

func(key string) *v0.param

findParam returns the param registered under key, or nil. The registry is a dozen entries, a linear scan is cheaper than any index.

Open
OID
051142…d347:94
findParam details

Inspect func

SetParam

func(key string, value int64)

SetParam changes a game parameter. Admin only. The key must exist and the value must be within the bounds of that key, see Render("params"). Lowering leaderboard\_size truncates the kill leaderboard right away. Raising it does not bring back the lines that were dropped: the list fills up again as kills come in.

Open
OID
051142…d347:95
SetParam details

Inspect func

SetParamBounds

func(key string, min int64, max int64)

SetParamBounds changes the range SetParam accepts for a key. Owner only. The bounds are the guard rail between the owner and the admins: admins tune values within them, the owner decides how far tuning may go. The current value has to fit the new bounds, so that the registry never holds a value SetParam would refuse.

Open
OID
051142…d347:96
SetParamBounds details

Inspect func

Param

func(key string) int64

Param returns the value of a game parameter. It panics on an unknown key.

Open
OID
051142…d347:97
Param details

Inspect func

indexFrom

func(s string, i int, c uint8) int

indexFrom returns the index of the first c in s at or after i, or len(s) when there is none.

Open
OID
051142…d347:98
indexFrom details

Inspect func

digits

func(s string) (int64, bool)

digits parses a non-empty string of decimal digits. Kill counts are never negative, so there is no sign to read.

Open
OID
051142…d347:100
digits details

Inspect func

recordedKills

func(addr .uverse.address) int64

killsOf returns the kills recorded for addr.

Open
OID
051142…d347:101
recordedKills details

Inspect func

ranking

type

ranking is a leaderboard on a single number that only goes up, the count of kills: the top players, best first, at most leaderboard\_size lines and one line per player. With equal scores, the player who got there first stays ahead. It is kept sorted at write time, so reading it never has to look at every player. Scores only going up is what makes that exact: a player outside the list can only enter it through raise. The two slices are parallel: slices of plain values are one stored object each, where a slice of structs would be one object per line. Measured on gnodev, a line costs about 190 bytes this way.

Value

v0.ranking

leaderboardSize

func() int

leaderboardSize returns how many lines a leaderboard may hold.

Open
OID
051142…d347:103
leaderboardSize details

Inspect func

spliceAddrs

func(list [].uverse.address, from int, to int, v .uverse.address, size int) [].uverse.address
Open
OID
051142…d347:105
spliceAddrs details

Inspect func

spliceInts

func(list []int64, from int, to int, v int64, size int) []int64

spliceInts is spliceAddrs for a column of numbers.

Open
OID
051142…d347:106
spliceInts details

Inspect func

trimRankings

func()

trimRankings cuts the kill leaderboard down to leaderboard\_size.

Open
OID
051142…d347:107
trimRankings details

Inspect func

writeRanking

func(b *strings.Builder, r v0.ranking, key string)

writeRanking writes a ranking as a JSON array of {"address":"g1...","\<key>":\<score>} objects, best first.

Open
OID
051142…d347:108
writeRanking details

Inspect func

Render

func(path string) string

Render returns the state of the game as markdown, for gnoweb: "" overview "leaderboard" the top players by kills "params" the game parameters and their bounds "player/<addr>" one player Everything printed here was validated against a narrow charset when it was written (see validate.gno), and the only caller-supplied value, the address of a player page, is printed only if it is a valid address. Nothing needs markdown escaping.

Open
OID
051142…d347:109
Render details

Inspect func

renderLeaderboard

func() string
Open
OID
051142…d347:113
renderLeaderboard details

Inspect func

renderPlayer

func(addr .uverse.address) string
Open
OID
051142…d347:116
renderPlayer details

Inspect func

validAddress

func(addr .uverse.address) bool

validAddress reports whether addr is a valid address in its canonical, lowercase form. Bech32 can also be written in all capitals, and address.IsValid accepts that. To this realm the capitals would be a second key for the same account: a second player record, a second line on a leaderboard, an admin who can never be matched to a caller. Bech32 does not allow mixing cases, so looking at the first character is enough.

Open
OID
051142…d347:117
validAddress details

Inspect func
callerOf : func(int, rlm .uverse.realm) .uverse.address Inspect
assertOwner : func(int, rlm .uverse.realm) .uverse.address Inspect
assertAdmin : func(int, rlm .uverse.realm) .uverse.address Inspect
assertReferee : func(int, rlm .uverse.realm) .uverse.address Inspect
TransferOwnership : func(newOwner .uverse.address) Inspect
AddAdmin : func(addr .uverse.address) Inspect
RemoveAdmin : func(addr .uverse.address) Inspect
SetTreasury : func(addr .uverse.address) Inspect
AddReferee : func(addr .uverse.address) Inspect
RemoveReferee : func(addr .uverse.address) Inspect
Owner : func() .uverse.address Inspect
Treasury : func() .uverse.address Inspect
IsAdmin : func(addr .uverse.address) bool Inspect
IsReferee : func(addr .uverse.address) bool Inspect
errSpoofedRealm : *errors.errorString Inspect
errNotOwner : *errors.errorString Inspect
errNotAdmin : *errors.errorString Inspect
errNotReferee : *errors.errorString Inspect
errInvalidAddress : *errors.errorString Inspect
errAlreadyAdmin : *errors.errorString Inspect
errNoSuchAdmin : *errors.errorString Inspect
errAlreadyReferee : *errors.errorString Inspect
errNoSuchReferee : *errors.errorString Inspect
errTreasurySelf : *errors.errorString Inspect
errUnknownParam : *errors.errorString Inspect
errInvalidBounds : *errors.errorString Inspect
errValueOutOfBounds : *errors.errorString Inspect
errLeaderboardMin : *errors.errorString Inspect
owner : *v0.Ownable Inspect
admins : v0.BPTree Inspect
referees : v0.BPTree Inspect
treasury : .uverse.address =<gnolang.StringValue>
version : int64 =2
params : []*v0.param (len=18) Inspect
pilots : v0.BPTree Inspect
killers : v0.ranking Inspect
webPath : string ="/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/game/v0"
init.37 : func() Inspect
bootstrap : func(deployer .uverse.address, pkgPath string) Inspect
Version : func() int64 Inspect
bump : func() Inspect
webPathOf : func(pkgPath string) string Inspect
itoa : func(n int64) string Inspect
StateJSON : func() string Inspect
PlayerJSON : func(addr .uverse.address) string Inspect
KillLeaderboardJSON : func() string Inspect
quote : func(s string) string Inspect
maxKillEntries : untyped bigint =(32 <untyped> bigint)
maxKillCount : untyped bigint =(1000 <untyped> bigint)
maxKillsLen : untyped bigint =(2048 <untyped> bigint)
errKillsFormat : *errors.errorString Inspect
SubmitKills : func(kills string) Inspect
parseKills : func(s string) ([].uverse.address, []int64, .uverse.error) Inspect
killsEntryError : func(index int, reason string) .uverse.error Inspect
param : type =v0.param
paramLeaderboardSize : untyped string ="leaderboard_size"
defaultParams : func() []*v0.param Inspect
findParam : func(key string) *v0.param Inspect
SetParam : func(key string, value int64) Inspect
SetParamBounds : func(key string, min int64, max int64) Inspect
Param : func(key string) int64 Inspect
indexFrom : func(s string, i int, c uint8) int Inspect
digits : func(s string) (int64, bool) Inspect
recordedKills : func(addr .uverse.address) int64 Inspect
ranking : type =v0.ranking
leaderboardSize : func() int Inspect
spliceAddrs : func(list [].uverse.address, from int, to int, v .uverse.address, size int) [].uverse.address Inspect
spliceInts : func(list []int64, from int, to int, v int64, size int) []int64 Inspect
trimRankings : func() Inspect
writeRanking : func(b *strings.Builder, r v0.ranking, key string) Inspect
Render : func(path string) string Inspect
renderHome : func() string Inspect
renderLeaderboard : func() string Inspect
renderParams : func() string Inspect
renderPlayer : func(addr .uverse.address) string Inspect
validAddress : func(addr .uverse.address) bool Inspect