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

playerStats

type

playerStats is the persisted record for one address.

Value

v0.playerStats

players

v0.Tree

// address string -> \*playerStats

Open
OID
025e52…82c1:4
players details

Inspect ref

king

.uverse.address

Value

<zero>

kingRoll

int

Value

0

reignSince

int64

// chain height at which the current king took the throne

Value

0

nonce

int

Value

0

totalRolls

int

Value

0

get

func(addr .uverse.address) *v0.playerStats

get returns the stored \*playerStats for addr, creating one if absent.

Open
OID
025e52…82c1:10
get details

Inspect func

pseudoRoll

func(addr .uverse.address, nonce int, height int64) int

pseudoRoll derives a deterministic 1-100 value from the caller's address, a per-call nonce, and the current chain height, so no two calls in the same block from the same address collide, yet the result can't be pre-computed off-chain before the triggering transaction lands.

Open
OID
025e52…82c1:12
pseudoRoll details

Inspect func

Roll

func() string

Roll throws the die for the caller. Rolling higher than the current king's roll dethrones them (crediting their finished reign in blocks) and crowns the caller as the new king.

Open
OID
025e52…82c1:13
Roll details

Inspect func

effectiveReignBlocks

func(ps *v0.playerStats, height int64) int64

effectiveReignBlocks returns a player's accumulated reign length, including the currently-in-progress reign if they are the sitting king. It does not mutate state — it's a display-time projection.

Open
OID
025e52…82c1:14
effectiveReignBlocks details

Inspect func

byReign

type

byReign implements sort.Interface, ranking players by effective reign length descending, ties broken by best roll then address so the order is fully deterministic.

Value

v0.byReign

snapshot

func(height int64) ([]*v0.playerStats, []int64)

snapshot collects all players ranked by effective reign length descending.

Open
OID
025e52…82c1:15
snapshot details

Inspect func

medal

func(rank int) string

medal returns the emoji for a given zero-based rank, or "" past the podium.

Open
OID
025e52…82c1:16
medal details

Inspect func

display

func(addr .uverse.address) string

display returns a shortened address for table display.

Open
OID
025e52…82c1:17
display details

Inspect func

Render

func(path string) string

Render shows the current king and a reign-length leaderboard.

Open
OID
025e52…82c1:18
Render details

Inspect func
playerStats : type =v0.playerStats
players : v0.Tree Inspect
king : .uverse.address =<zero>
kingRoll : int =0
reignSince : int64 =0
nonce : int =0
totalRolls : int =0
get : func(addr .uverse.address) *v0.playerStats Inspect
pseudoRoll : func(addr .uverse.address, nonce int, height int64) int Inspect
Roll : func() string Inspect
effectiveReignBlocks : func(ps *v0.playerStats, height int64) int64 Inspect
byReign : type =v0.byReign
snapshot : func(height int64) ([]*v0.playerStats, []int64) Inspect
medal : func(rank int) string Inspect
display : func(addr .uverse.address) string Inspect
Render : func(path string) string Inspect