func AddAdmin
crossing ActionAddAdmin adds addr to the admin list. Owner only.
v0 - Unaudited: This is an initial version that has not yet been formally audited. Use in production at your own risk.
v0 - Unaudited: This is an initial version that has not yet been formally audited. Use in production at your own risk.
Package game is the on-chain part of gnofly, a multiplayer plane game. It is the source of truth for everything an admin can tune: the game parameters, the roles and the treasury. It also keeps what the referee attests and what has lasting value: the kills, on the kill leaderboard. Skins and planes are tokens of their own realms, gnofly/nfts/skins and gnofly/nfts/planes, which ask this one who the admins are and where the treasury is.
Three kinds of callers write to it:
Challenge runs never reach the chain: the game server defines the challenges, scores the runs and keeps the session boards.
Reads are plain functions meant for vm/qeval. The ones ending in JSON return a single string holding a JSON document. Render exposes the same data as markdown for gnoweb.
AddAdmin adds addr to the admin list. Owner only.
AddReferee allows addr to submit kills. Admin only.
IsAdmin reports whether addr is an admin. The owner always is.
IsReferee reports whether addr may submit kills.
KillLeaderboardJSON returns the top players by kills recorded on-chain as a JSON array, best first, at most leaderboard_size entries:
1[ { "address": "g1...", "kills": 17 } ]
The output has no whitespace. With equal kills, the player who got there first stays ahead.
Param returns the value of a game parameter. It panics on an unknown key.
PlayerJSON returns one player as a JSON object:
1{ "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).
RemoveAdmin removes addr from the admin list. Owner only.
The owner is an admin by definition and cannot be demoted this way, use TransferOwnership.
RemoveReferee stops addr from submitting kills. Admin only.
Render returns the state of the game as markdown, for gnoweb:
1"" overview
2"leaderboard" the top players by kills
3"params" the game parameters and their bounds
4"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.
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.
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.
SetTreasury sets the address the sales of skins and planes are forwarded to. Owner only.
StateJSON returns everything the game needs from the chain, as one JSON object:
1{
2 "version": 12,
3 "treasury": "g1...",
4 "params": { "plane_speed": 70, "boost_speed": 130 }
5}
The output has no whitespace. It only changes when Version does. The skins are in their own realm, gnofly/nfts/skins.
SubmitKills adds kills to players' on-chain counts. Referee only.
kills is 1 to 32 entries "address:count" separated by ";", for example
1g1abc...: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.
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.
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.