const EasyPoints, MediumPoints, HardPoints
Points a challenge starts at, by difficulty.
Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.
Package flag is the shared vocabulary of Cellar, a capture-the-flag wargame played on gno.land.
Package flag is the shared vocabulary of Cellar, a capture-the-flag wargame played on gno.land.
A challenge is a realm that holds a deliberate weakness. When a player exploits it, the realm records a capture in a Ledger. A hall (a scoreboard realm) learns about the challenge through the Challenge interface and asks it, on claim, whether a given player captured it.
Anyone can author a challenge by importing this package:
1package riddle
2
3import (
4 "gno.land/p/<ns>/cellar/flag"
5 "gno.land/r/<ns>/cellar/hall"
6)
7
8var captures = flag.NewLedger()
9
10type challenge struct{}
11
12func (challenge) Info() flag.Info { return info }
13func (challenge) Captured(p address) bool { return captures.Captured(p) }
14
15func init(cur realm) { hall.Enlist(cross(cur), challenge{}) }
The package also carries the scoring curve (Value) and the rule that maps a caller to the player who gets the credit (Player).
Points a challenge starts at, by difficulty.
DecaySolves is the number of solves after which a challenge settles at its floor value.
Difficulty levels, from a first evening in the cellar to a long night.
Errors returned by Validate.
1var ErrNoPlayer = errors.New("flag: deploy your solution under gno.land/r/<your-g1-address>/ so the hall knows who you are")ErrNoPlayer is returned when a caller cannot be tied to a player.
Captures renders the n most recent captures of l as a markdown list.
Card renders the standard header of a challenge page: title, grade, category, number of captures and the brief. Authors use it at the top of their Render so every challenge in the cellar reads the same way.
Value returns what a challenge of difficulty d is worth to every one of its solvers once it has solves solvers. It follows the CTFd dynamic curve: the value falls with the square of the solve count and settles at the floor after DecaySolves solves. A lone solver keeps the full value, and the value applies retroactively to all solvers.
NewLedger returns an empty Ledger.
Caller is the part of a realm value Player needs. Pass cur.Previous().
Capture is the proof that a player broke a challenge.
Challenge is what a challenge realm hands to a hall.
Implementations live in the challenge realm, so their methods run with that realm's storage. Captured must be a pure read.
Difficulty grades a challenge. It sets the starting value of the challenge on the scoring curve.
FirstBloodBonus returns the one-time bonus for the first solver.
Floor returns the lowest value a challenge of difficulty d decays to: two fifths of its initial value.
Initial returns the value of a challenge nobody has solved yet.
String returns the human name of d.
Valid reports whether d is one of the declared levels.
1type Info struct {
2 Slug string // unique, lowercase, 3 to 24 chars of [a-z0-9-]
3 Title string // display name
4 Difficulty Difficulty // starting value on the scoring curve
5 Category string // the Gno semantic it teaches, e.g. "render"
6 Brief string // the story a player reads first (markdown)
7}Info describes a challenge to players and to the hall.
Ledger records captures for one challenge.
Keep a Ledger in an unexported variable of your realm and never return a pointer to it: its methods mutate, and a method call on a leaked pointer commits under your realm's authority. (Challenge "rack" is about exactly that.)
Captured reports whether player has captured.
Count returns the number of distinct players who captured.
Get returns the capture of player, if any.
Recent returns up to n captures, newest first.
Record stores a capture for player at the current height. It returns the stored capture and true, or the earlier capture and false if the player had already captured.