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

Move

type

Move is one of rock, paper, or scissors, ordered so that (winner - loser + 3) % 3 == 1 for every winning pair.

Value

v0.Move

Rock

v0.Move

Value

<zero>

Paper

v0.Move

Value

<zero>

Scissors

v0.Move

Value

<zero>

parseMove

func(s string) (v0.Move, bool)
Open
OID
0ec89d…7439:5
parseMove details

Inspect func

judge

func(p v0.Move, h v0.Move) int

judge returns 0 for a tie, 1 if p beats h, 2 if h beats p.

Open
OID
0ec89d…7439:6
judge details

Inspect func

revealWindow

int64

revealWindow is how many blocks the challenger gets to reveal after the opponent accepts before the opponent can claim a forfeit win.

Value

50

duelStatus

type

Value

v0.duelStatus

statusPending

v0.duelStatus

Value

<zero>

statusAwaitingReveal

v0.duelStatus

Value

<zero>

statusResolved

v0.duelStatus

Value

<zero>

statusForfeited

v0.duelStatus

Value

<zero>

statusCancelled

v0.duelStatus

Value

<zero>

duel

type

duel is one asynchronous round between Challenger and Opponent. The challenger's move is hidden behind Commit until Reveal; the opponent's move is stored in the clear once they Accept.

Value

v0.duel

playerState

type

playerState is the persisted record for one address.

Value

v0.playerState

duels

v0.Tree

// duel ID -> \*duel

Open
OID
0ec89d…7439:8
duels details

Inspect ref

players

v0.Tree

// address string -> \*playerState

Open
OID
0ec89d…7439:10
players details

Inspect ref

nextID

int

Value

0

totalResolved

int

Value

0

champion

.uverse.address

Value

<zero>

championWins

int

Value

0

ComputeCommit

func(moveStr string, salt string) string

ComputeCommit hashes a move and salt exactly the way Reveal checks it, so a caller can compute their commitment (e.g. via a read-only query) before calling Open, then remember the salt to pass to Reveal later.

Open
OID
0ec89d…7439:15
ComputeCommit details

Inspect func

getOrCreate

func(addr .uverse.address) *v0.playerState
Open
OID
0ec89d…7439:16
getOrCreate details

Inspect func

bumpChampion

func(addr .uverse.address, wins int)
Open
OID
0ec89d…7439:17
bumpChampion details

Inspect func

settle

func(d *v0.duel, challengerMove v0.Move, result int)

settle scores a revealed round and updates both players' records.

Open
OID
0ec89d…7439:18
settle details

Inspect func

Open

func(opponentAddr string, commitHex string) string

Open challenges opponentAddr to a duel, locking in the challenger's move as a commitment (see ComputeCommit) so the opponent can't see it before replying.

Open
OID
0ec89d…7439:19
Open details

Inspect func

Accept

func(id string, moveStr string) string

Accept replies to a pending duel with a plain move. Only the challenged opponent may call it; going second behind the challenger's hidden commitment is what keeps this fair.

Open
OID
0ec89d…7439:20
Accept details

Inspect func

Reveal

func(id string, moveStr string, salt string) string

Reveal settles an accepted duel. Only the original challenger may call it, and only with the exact move+salt that produced their commitment.

Open
OID
0ec89d…7439:21
Reveal details

Inspect func

outcomeMsg

func(d *v0.duel) string
Open
OID
0ec89d…7439:22
outcomeMsg details

Inspect func

ClaimForfeit

func(id string) string

ClaimForfeit lets the opponent collect a default win when the challenger dodges revealing (e.g. because they saw the opponent's move and knew they'd lose) past the reveal window.

Open
OID
0ec89d…7439:23
ClaimForfeit details

Inspect func

Cancel

func(id string) string

Cancel withdraws a still-pending duel. Only the challenger may cancel, and only before the opponent accepts.

Open
OID
0ec89d…7439:24
Cancel details

Inspect func

escapeInline

func(s string) string

escapeInline neutralizes markdown-active characters in untrusted text before it's embedded inline in Render output.

Open
OID
0ec89d…7439:25
escapeInline details

Inspect func

renderDuel

func(id string) string
Open
OID
0ec89d…7439:27
renderDuel details

Inspect func

renderPlayer

func(rawAddr string) string
Open
OID
0ec89d…7439:28
renderPlayer details

Inspect func

Render

func(path string) string

Render shows the duel lobby at "", a specific duel when path is a numeric ID, or one player's record when path is their bech32 address.

Open
OID
0ec89d…7439:29
Render details

Inspect func
Move : type =v0.Move
Rock : v0.Move =<zero>
Paper : v0.Move =<zero>
Scissors : v0.Move =<zero>
moveName : func(m v0.Move) string Inspect
parseMove : func(s string) (v0.Move, bool) Inspect
judge : func(p v0.Move, h v0.Move) int Inspect
revealWindow : int64 =50
duelStatus : type =v0.duelStatus
statusPending : v0.duelStatus =<zero>
statusAwaitingReveal : v0.duelStatus =<zero>
statusResolved : v0.duelStatus =<zero>
statusForfeited : v0.duelStatus =<zero>
statusCancelled : v0.duelStatus =<zero>
duel : type =v0.duel
playerState : type =v0.playerState
duels : v0.Tree Inspect
players : v0.Tree Inspect
nextID : int =0
totalResolved : int =0
champion : .uverse.address =<zero>
championWins : int =0
ComputeCommit : func(moveStr string, salt string) string Inspect
getOrCreate : func(addr .uverse.address) *v0.playerState Inspect
bumpChampion : func(addr .uverse.address, wins int) Inspect
settle : func(d *v0.duel, challengerMove v0.Move, result int) Inspect
Open : func(opponentAddr string, commitHex string) string Inspect
Accept : func(id string, moveStr string) string Inspect
Reveal : func(id string, moveStr string, salt string) string Inspect
outcomeMsg : func(d *v0.duel) string Inspect
ClaimForfeit : func(id string) string Inspect
Cancel : func(id string) string Inspect
escapeInline : func(s string) string Inspect
renderHome : func() string Inspect
renderDuel : func(id string) string Inspect
renderPlayer : func(rawAddr string) string Inspect
Render : func(path string) string Inspect