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

connect4 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.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.Status

Open

connect4.Status

Value

<zero>

Playing

connect4.Status

Value

<zero>

Won

connect4.Status

Value

<zero>

Draw

connect4.Status

Value

<zero>

Void

connect4.Status

Value

<zero>

Cancelled

connect4.Status

Value

<zero>

Game

type

Value

connect4.Game

Stats

type

Value

connect4.Stats

games

v0.Tree

// key(id) -> \*Game

Open
OID
098db0…62ae:4
games details

Inspect ref

active

v0.Tree

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

Open
OID
098db0…62ae:6
active details

Inspect ref

stats

v0.Tree

// address -> \*Stats

Open
OID
098db0…62ae:8
stats details

Inspect ref

nextID

int

Value

2

fee

int64

// ugnot per decisive game

Value

100000

feesCollected

int64

Value

100000

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
098db0…62ae:15
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
098db0…62ae: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
098db0…62ae: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
098db0…62ae:19
Reveal details

Inspect func

Play

func(id int, column int)

Play drops a piece in column (1-7).

Open
OID
098db0…62ae:20
Play details

Inspect func

ClaimTimeout

func(id int)

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

Open
OID
098db0…62ae:21
ClaimTimeout details

Inspect func

Resign

func(id int)

Resign concedes a game in progress.

Open
OID
098db0…62ae: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
098db0…62ae: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
098db0…62ae:24
SetFee details

Inspect func

WithdrawFees

func(to .uverse.address)

WithdrawFees sends all collected fees to to.

Open
OID
098db0…62ae:25
WithdrawFees details

Inspect func

TransferOwnership

func(newOwner .uverse.address)
Open
OID
098db0…62ae: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
098db0…62ae: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
098db0…62ae:28
noCoins details

Inspect func

sha256Hex

func(s string) string
Open
OID
098db0…62ae:29
sha256Hex details

Inspect func

isHexSHA256

func(s string) bool
Open
OID
098db0…62ae:30
isHexSHA256 details

Inspect func

settleWin

func(g *connect4.Game, winner .uverse.address)
Open
OID
098db0…62ae:31
settleWin details

Inspect func

settleDraw

func(g *connect4.Game)
Open
OID
098db0…62ae:32
settleDraw details

Inspect func

settleVoid

func(g *connect4.Game)
Open
OID
098db0…62ae:33
settleVoid details

Inspect func

finish

func(g *connect4.Game, s connect4.Status)
Open
OID
098db0…62ae:34
finish details

Inspect func

send

func(to .uverse.address, amount int64)
Open
OID
098db0…62ae:35
send details

Inspect func

statsOf

func(addr .uverse.address) *connect4.Stats
Open
OID
098db0…62ae:36
statsOf details

Inspect func

key

func(id int) string

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

Open
OID
098db0…62ae:37
key details

Inspect func

mustGet

func(id int) *connect4.Game
Open
OID
098db0…62ae:39
mustGet details

Inspect func

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
098db0…62ae:44
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
098db0…62ae:46
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
098db0…62ae:49
renderNew details

Inspect func

renderGame

func(g *connect4.Game) string
Open
OID
098db0…62ae:50
renderGame details

Inspect func

boardView

func(g *connect4.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
098db0…62ae:51
boardView details

Inspect func

drawColumn

func(canvas *v0.Canvas, g *connect4.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
098db0…62ae:52
drawColumn details

Inspect func

acceptURL

func(g *connect4.Game) string
Open
OID
098db0…62ae:53
acceptURL details

Inspect func

openTo

func(g *connect4.Game) string
Open
OID
098db0…62ae:55
openTo details

Inspect func

parseGNOT

func(s string) (int64, bool)

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

Open
OID
098db0…62ae:56
parseGNOT details

Inspect func

leaderboard

func(score func(...), format func(...)) string

leaderboard renders the top 10 players by score, skipping zero scores.

Open
OID
098db0…62ae:57
leaderboard details

Inspect func

gnot

func(ugnot int64) string

gnot formats ugnot as GNOT with up to 6 decimals.

Open
OID
098db0…62ae:58
gnot details

Inspect func

remaining

func(d time.Duration) string
Open
OID
098db0…62ae:59
remaining details

Inspect func

orNone

func(a .uverse.address) string
Open
OID
098db0…62ae:60
orNone details

Inspect func
cols : untyped bigint =(7 <untyped> bigint)
rows : untyped bigint =(6 <untyped> bigint)
board : type =connect4.board
moveTimeout : time.Duration =<zero>
maxOfferTTL : untyped bigint =(60 <untyped> bigint)
minStake : untyped bigint =(1000000 <untyped> bigint)
denom : untyped string ="ugnot"
Status : type =connect4.Status
Open : connect4.Status =<zero>
Playing : connect4.Status =<zero>
Won : connect4.Status =<zero>
Draw : connect4.Status =<zero>
Void : connect4.Status =<zero>
Cancelled : connect4.Status =<zero>
Game : type =connect4.Game
Stats : type =connect4.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
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) 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
sha256Hex : func(s string) string Inspect
isHexSHA256 : func(s string) bool Inspect
settleWin : func(g *connect4.Game, winner .uverse.address) Inspect
settleDraw : func(g *connect4.Game) Inspect
settleVoid : func(g *connect4.Game) Inspect
finish : func(g *connect4.Game, s connect4.Status) Inspect
send : func(to .uverse.address, amount int64) Inspect
statsOf : func(addr .uverse.address) *connect4.Stats Inspect
key : func(id int) string Inspect
get : func(id int) *connect4.Game Inspect
mustGet : func(id int) *connect4.Game Inspect
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.Game) string Inspect
boardView : func(g *connect4.Game, now time.Time) string Inspect
drawColumn : func(canvas *v0.Canvas, g *connect4.Game, win *[7][6]bool, c int, x int) string Inspect
acceptURL : func(g *connect4.Game) string Inspect
digits : func(s string) bool Inspect
openTo : func(g *connect4.Game) string Inspect
parseGNOT : func(s string) (int64, bool) Inspect
leaderboard : func(score func(...), format func(...)) string Inspect
gnot : func(ugnot int64) string Inspect
remaining : func(d time.Duration) string Inspect
orNone : func(a .uverse.address) string Inspect