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

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

connect4_v3 state

Back to all declarations

cols

untyped bigint

Value

(7 <untyped> bigint)

rows

untyped bigint

Value

(6 <untyped> bigint)

board

type

board is indexed \[column]\[row]; row 0 is the bottom. 0 = empty, 1/2 = player.

Value

connect4_v3.board

moveTimeout

time.Duration

Value

<zero>

maxOfferTTL

untyped bigint

// minutes

Value

(60 <untyped> bigint)

minStake

untyped bigint

// ugnot

Value

(1000000 <untyped> bigint)

denom

untyped string

Value

"ugnot"

Status

type

Value

connect4_v3.Status

Open

connect4_v3.Status

Value

<zero>

Playing

connect4_v3.Status

Value

<zero>

Won

connect4_v3.Status

Value

<zero>

Draw

connect4_v3.Status

Value

<zero>

Void

connect4_v3.Status

Value

<zero>

Cancelled

connect4_v3.Status

Value

<zero>

Game

type

Value

connect4_v3.Game

Stats

type

Value

connect4_v3.Stats

games

v0.Tree

// key(id) -> \*Game

Open
OID
015e41…700e:4
games details

Inspect ref

active

v0.Tree

// key(id) -> \*Game, only Open and Playing

Open
OID
015e41…700e:6
active details

Inspect ref

stats

v0.Tree

// address -> \*Stats

Open
OID
015e41…700e:8
stats details

Inspect ref

nextID

int

Value

2

fee

int64

// ugnot per decisive game

Value

100000

feesCollected

int64

Value

100000

owner

*v0.Ownable

// the deployer; nil (no owner) if deployed some other way

Open
OID
015e41…700e:73
owner details

Inspect pointer

testSession

bool

Value

false

Offer

func(opponent .uverse.address, validFor int, commitment string) int

Offer posts a game open for validFor minutes. The stake is the ugnot sent with the call. A non-empty opponent makes the offer private. commitment is the lowercase hex sha256 of a secret passphrase, revealed after Accept.

Open
OID
015e41…700e:16
Offer details

Inspect func

validateOffer

func(stake int64, validFor int, opponent .uverse.address, commitment string) []string

validateOffer returns every rule an offer breaks. Offer panics with the first; the "new" page lists them all before anyone signs.

Open
OID
015e41…700e:17
validateOffer details

Inspect func

Accept

func(id int)

Accept joins an open offer by sending exactly its stake. The creator then has 90s to Reveal, which picks the first mover.

Open
OID
015e41…700e:18
Accept details

Inspect func

Reveal

func(id int, passphrase string)

Reveal discloses the creator's passphrase, which picks the first mover. It must come within 90s of Accept.

Open
OID
015e41…700e:19
Reveal details

Inspect func

Play

func(id int, column int, move int)

Play drops a piece in column (1-7). move is the game's move count the player saw (Moves before this piece): a resent or delayed move that the game has moved past is refused instead of being played on a later turn.

Open
OID
015e41…700e:20
Play details

Inspect func

ClaimTimeout

func(id int)

ClaimTimeout settles a game whose move clock ran out. Anyone may call it.

Open
OID
015e41…700e:21
ClaimTimeout details

Inspect func

Resign

func(id int)

Resign concedes a game in progress.

Open
OID
015e41…700e:22
Resign details

Inspect func

Cancel

func(id int)

Cancel withdraws an open offer and refunds the creator. The creator may cancel at any time; anyone may once the offer has expired.

Open
OID
015e41…700e:23
Cancel details

Inspect func

SetFee

func(amount int64)

SetFee changes the flat house fee, in ugnot, for new offers. Games already offered keep the fee they were created with.

Open
OID
015e41…700e:24
SetFee details

Inspect func

WithdrawFees

func(to .uverse.address)

WithdrawFees sends all collected fees to to.

Open
OID
015e41…700e:25
WithdrawFees details

Inspect func

TransferOwnership

func(newOwner .uverse.address)
Open
OID
015e41…700e:26
TransferOwnership details

Inspect func

received

func() int64

received returns the ugnot sent with a direct user call. OriginSend only describes a real payment to this realm when the caller is an EOA using maketx call; see docs/resources/effective-gno.md.

Open
OID
015e41…700e:27
received details

Inspect func

noCoins

func()

noCoins guards calls that take no payment: coins sent with them would be stuck in the realm.

Open
OID
015e41…700e:28
noCoins details

Inspect func

noSession

func(action string)

noSession refuses calls signed by an account session key.

Open
OID
015e41…700e:29
noSession details

Inspect func

sha256Hex

func(s string) string
Open
OID
015e41…700e:30
sha256Hex details

Inspect func

isHexSHA256

func(s string) bool
Open
OID
015e41…700e:31
isHexSHA256 details

Inspect func

settleWin

func(g *connect4_v3.Game, winner .uverse.address)
Open
OID
015e41…700e:32
settleWin details

Inspect func

settleDraw

func(g *connect4_v3.Game)
Open
OID
015e41…700e:33
settleDraw details

Inspect func

settleVoid

func(g *connect4_v3.Game)
Open
OID
015e41…700e:34
settleVoid details

Inspect func

leader

type

leader is one leaderboard row. The boards are kept at settlement so Render never walks every player's stats.

Value

connect4_v3.leader

topWins

[]connect4_v3.leader (len=1)

// highest first, at most topN

Open
OID
015e41…700e:99
topWins details (len=1)

+1 more Inspect slice

topGnot

[]connect4_v3.leader (len=1)

// highest first, at most topN

Open
OID
015e41…700e:101
topGnot details (len=1)

+1 more Inspect slice

topN

untyped bigint

Value

(10 <untyped> bigint)

bump

func(board []connect4_v3.leader, addr .uverse.address, score int64) []connect4_v3.leader

bump moves addr to its new score in board. Scores only grow, so a player already listed can only move up; ties keep the earlier holder first.

Open
OID
015e41…700e:37
bump details

Inspect func

finish

func(g *connect4_v3.Game, s connect4_v3.Status)
Open
OID
015e41…700e:38
finish details

Inspect func

send

func(to .uverse.address, amount int64)
Open
OID
015e41…700e:39
send details

Inspect func

statsOf

func(addr .uverse.address) *connect4_v3.Stats
Open
OID
015e41…700e:40
statsOf details

Inspect func

key

func(id int) string

key zero-pads ids so avl iteration order matches creation order.

Open
OID
015e41…700e:41
key details

Inspect func

mustGet

func(id int) *connect4_v3.Game
Open
OID
015e41…700e:43
mustGet details

Inspect func

GameJSON

func(id int) string

GameJSON returns {"now":\<unix>,"game":\<game>|null}. It is a read-only accessor for clients querying over vm/qeval; now is the block time.

Open
OID
015e41…700e:44
GameJSON details

Inspect func

ActiveJSON

func(offset int, limit int) string

ActiveJSON returns {"now":\<unix>,"games":\[...]}: Open and Playing games in id order, skipping offset and returning at most limit (clamped to 1-100).

Open
OID
015e41…700e:46
ActiveJSON details

Inspect func

writeNow

func(b *strings.Builder)
Open
OID
015e41…700e:47
writeNow details

Inspect func

writeGame

func(b *strings.Builder, g *connect4_v3.Game)

writeGame emits one game. Every stored string is validated on write (addresses by IsValid, the commitment as hex), so Quote is defence in depth.

Open
OID
015e41…700e:48
writeGame details

Inspect func

writeStr

func(b *strings.Builder, k string, v string)

writeStr and writeNum append \`,"k":v\`; the caller writes the first field.

Open
OID
015e41…700e:49
writeStr details

Inspect func

writeNum

func(b *strings.Builder, k string, v int64)
Open
OID
015e41…700e:50
writeNum details

Inspect func

lobbyRows

untyped bigint

lobbyRows caps the games the lobby lists, so Render stays within query gas however many games are open; clients page through ActiveJSON instead.

Value

(50 <untyped> bigint)

red

untyped string

Board colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.

Value

"#e53935"

yellow

untyped string

Board colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.

Value

"#fdd835"

hole

untyped string

Board colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.

Value

"#ffffff"

boardBlue

untyped string

Board colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.

Value

"#1565c0"

lastMoveStroke

untyped string

Board colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.

Value

"#212121"

winStroke

untyped string

Board colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.

Value

"#00e676"

cellPx

untyped bigint

Board colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.

Value

(48 <untyped> bigint)

headerPx

untyped bigint

Board colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.

Value

(20 <untyped> bigint)

Render

func(path string) string

Render serves "" (lobby and leaderboards), "new" (offer form) and "game/\<id>" (one game with every action its state allows). Everything written comes from realm state or from query values that have been validated and re-formatted; raw path input is never echoed.

Open
OID
015e41…700e:55
Render details

Inspect func

pageURL

func(page string) string

pageURL links to one of this realm's Render pages. The realm path is read at runtime, like txlink does, so links work wherever the realm is deployed.

Open
OID
015e41…700e:57
pageURL details

Inspect func

renderNew

func(query string) string

renderNew shows the offer form and, once submitted, a single Offer link with the stake and every argument prefilled (gnoweb cannot edit .send).

Open
OID
015e41…700e:60
renderNew details

Inspect func

renderGame

func(g *connect4_v3.Game) string
Open
OID
015e41…700e:61
renderGame details

Inspect func

boardView

func(g *connect4_v3.Game, now time.Time) string

boardView draws the board. While a move can be played it is 7 column images, each wrapped in its Play link (gnoweb lays linked images out side by side). Otherwise it is one image of all 7 columns, since gnoweb stacks bare images vertically. The last move gets a dark ring, a winning line a green one.

Open
OID
015e41…700e:62
boardView details

Inspect func

drawColumn

func(canvas *v0.Canvas, g *connect4_v3.Game, win *[7][6]bool, c int, x int) string

drawColumn draws column c at horizontal offset x and returns its alt text.

Open
OID
015e41…700e:63
drawColumn details

Inspect func

acceptURL

func(g *connect4_v3.Game) string
Open
OID
015e41…700e:64
acceptURL details

Inspect func

openTo

func(g *connect4_v3.Game) string
Open
OID
015e41…700e:66
openTo details

Inspect func

parseGNOT

func(s string) (int64, bool)

parseGNOT parses a decimal GNOT amount ("10", "2.5") into ugnot.

Open
OID
015e41…700e:67
parseGNOT details

Inspect func

leaderboard

func(board []connect4_v3.leader, format func(...)) string

leaderboard renders a board kept at settlement (topWins, topGnot).

Open
OID
015e41…700e:68
leaderboard details

Inspect func

gnot

func(ugnot int64) string

gnot formats ugnot as GNOT with up to 6 decimals.

Open
OID
015e41…700e:69
gnot details

Inspect func

remaining

func(d time.Duration) string
Open
OID
015e41…700e:70
remaining details

Inspect func

orNone

func(a .uverse.address) string
Open
OID
015e41…700e:71
orNone details

Inspect func
cols : untyped bigint =(7 <untyped> bigint)
rows : untyped bigint =(6 <untyped> bigint)
board : type =connect4_v3.board
moveTimeout : time.Duration =<zero>
maxOfferTTL : untyped bigint =(60 <untyped> bigint)
minStake : untyped bigint =(1000000 <untyped> bigint)
denom : untyped string ="ugnot"
Status : type =connect4_v3.Status
Open : connect4_v3.Status =<zero>
Playing : connect4_v3.Status =<zero>
Won : connect4_v3.Status =<zero>
Draw : connect4_v3.Status =<zero>
Void : connect4_v3.Status =<zero>
Cancelled : connect4_v3.Status =<zero>
Game : type =connect4_v3.Game
Stats : type =connect4_v3.Stats
games : v0.Tree Inspect
active : v0.Tree Inspect
stats : v0.Tree Inspect
nextID : int =2
fee : int64 =100000
feesCollected : int64 =100000
owner : *v0.Ownable Inspect
testSession : bool =false
init.24 : func() Inspect
Offer : func(opponent .uverse.address, validFor int, commitment string) int Inspect
validateOffer : func(stake int64, validFor int, opponent .uverse.address, commitment string) []string Inspect
Accept : func(id int) Inspect
Reveal : func(id int, passphrase string) Inspect
Play : func(id int, column int, move int) Inspect
ClaimTimeout : func(id int) Inspect
Resign : func(id int) Inspect
Cancel : func(id int) Inspect
SetFee : func(amount int64) Inspect
WithdrawFees : func(to .uverse.address) Inspect
TransferOwnership : func(newOwner .uverse.address) Inspect
received : func() int64 Inspect
noCoins : func() Inspect
noSession : func(action string) Inspect
sha256Hex : func(s string) string Inspect
isHexSHA256 : func(s string) bool Inspect
settleWin : func(g *connect4_v3.Game, winner .uverse.address) Inspect
settleDraw : func(g *connect4_v3.Game) Inspect
settleVoid : func(g *connect4_v3.Game) Inspect
leader : type =connect4_v3.leader
topWins : []connect4_v3.leader (len=1) Inspect
topGnot : []connect4_v3.leader (len=1) Inspect
topN : untyped bigint =(10 <untyped> bigint)
bump : func(board []connect4_v3.leader, addr .uverse.address, score int64) []connect4_v3.leader Inspect
finish : func(g *connect4_v3.Game, s connect4_v3.Status) Inspect
send : func(to .uverse.address, amount int64) Inspect
statsOf : func(addr .uverse.address) *connect4_v3.Stats Inspect
key : func(id int) string Inspect
get : func(id int) *connect4_v3.Game Inspect
mustGet : func(id int) *connect4_v3.Game Inspect
GameJSON : func(id int) string Inspect
ActiveJSON : func(offset int, limit int) string Inspect
writeNow : func(b *strings.Builder) Inspect
writeGame : func(b *strings.Builder, g *connect4_v3.Game) Inspect
writeStr : func(b *strings.Builder, k string, v string) Inspect
writeNum : func(b *strings.Builder, k string, v int64) Inspect
lobbyRows : untyped bigint =(50 <untyped> bigint)
red : untyped string ="#e53935"
yellow : untyped string ="#fdd835"
hole : untyped string ="#ffffff"
boardBlue : untyped string ="#1565c0"
lastMoveStroke : untyped string ="#212121"
winStroke : untyped string ="#00e676"
cellPx : untyped bigint =(48 <untyped> bigint)
headerPx : untyped bigint =(20 <untyped> bigint)
pieceColor : [3]string Inspect
pieceName : [3]string Inspect
Render : func(path string) string Inspect
pageURL : func(page string) string Inspect
renderLobby : func() string Inspect
renderNew : func(query string) string Inspect
renderGame : func(g *connect4_v3.Game) string Inspect
boardView : func(g *connect4_v3.Game, now time.Time) string Inspect
drawColumn : func(canvas *v0.Canvas, g *connect4_v3.Game, win *[7][6]bool, c int, x int) string Inspect
acceptURL : func(g *connect4_v3.Game) string Inspect
digits : func(s string) bool Inspect
openTo : func(g *connect4_v3.Game) string Inspect
parseGNOT : func(s string) (int64, bool) Inspect
leaderboard : func(board []connect4_v3.leader, format func(...)) string Inspect
gnot : func(ugnot int64) string Inspect
remaining : func(d time.Duration) string Inspect
orNone : func(a .uverse.address) string Inspect