Skip to content Search Apps Documentation Source Content Run Reset Eval Playground 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.

v1 source pure

Package pafta is a Sinopia engine: a collection of 256 map sheets that together form one large survey map (16 x 16 sh...

Overview

Package pafta is a Sinopia engine: a collection of 256 map sheets that together form one large survey map (16 x 16 sheets). The terrain is one global field, so the edges of neighbouring sheets join exactly; every token is one sheet, with its own settlement, landmark and place name.

Fairness. The map and every token's sheet are fixed by the collection's final salt (core commit-reveal), which exists only after the sale closed and both secrets were revealed:

Example
1mapSeed   = sha256hex("art|pafta|map|v1|" + cid + "|" + salt)
2permKey   = sha256hex("art|pafta|perm|v1|" + cid + "|" + salt)
3tile(tid) = media.Permute(permKey, 256, tid-1)

The token's own seed (core's safe.Seed(cid, tid, salt)) only chooses what is drawn on its sheet. Before Final nobody, the creator included, can tell which sheet a token will be or what the map looks like. Without a collection (core.RenderWith, Studio, the registration sample) a seed renders a "standalone" sheet of its own map (Standalone).

The adapter (r/…/engines/pafta) decides which of the two a call gets: only core's real TokenURI/TokenTraits call for a Final commit-reveal collection of this engine is placed.

frontend/src/engines/pafta.ts is a byte-identical TypeScript twin; pafta_test.gno and pafta.test.ts pin the same golden vectors. Pure integer maths: no floats, no time, no block data.

Constants 6

const Side, Sheets

1const (
2	Side   = 16
3	Sheets = 256
4)
source

Side is the number of sheets per map side; a collection is exactly Sheets tokens (CheckLaunch in the adapter).

const Width, Height, MapX, MapY, MapSize

1const (
2	Width   = 560
3	Height  = 660
4	MapX    = 40
5	MapY    = 96
6	MapSize = 480
7)
source

The map face of every sheet: a composite view crops each token's SVG to the box (MapX, MapY, MapSize) of the Width x Height sheet and lays the boxes edge to edge on the 16 x 16 grid.

const MapDomain, PermDomain

1const (
2	MapDomain  = "art|pafta|map|v1|"
3	PermDomain = "art|pafta|perm|v1|"
4)
source

Hash domains of the post-reveal map seed and sheet permutation.

const DefaultParams

1const DefaultParams = `{"palette":"Seeded","landform":"Seeded"}`
source

DefaultParams is the canonical form of the defaults; it renders exactly like "".

const MaxSVGBytes

1const MaxSVGBytes = 28672
source

MaxSVGBytes: see the size table in docs/engines/pafta.md.

const ParamsSchema

1const ParamsSchema = `{"type":"object","properties":{` +
2	`"palette":{"type":"string","title":"Palette","enum":["Seeded","Survey","Atlas","Admiralty","Antique"],"default":"Seeded"},` +
3	`"landform":{"type":"string","title":"Landform","enum":["Seeded","Island","Archipelago","Mainland Coast","Inland Sea"],` +
4	`"default":"Seeded"}}}`
source

ParamsSchema is the Studio form. Studio sends JSON.stringify of the values in this property order; ValidateParams accepts exactly that or "".

Functions 13

func Manifest

1func Manifest() engine.Manifest
source

Manifest describes the engine. Author and FeeBps are set by the adapter.

func MapSeed

1func MapSeed(cid, salt string) string
source

MapSeed is collection cid's map seed for its final salt.

func PermKey

1func PermKey(cid, salt string) string
source

PermKey is collection cid's sheet permutation key for its final salt.

func Render

1func Render(in engine.Input) string
source

Render returns the SVG of a standalone sheet of in.Seed.

func SheetCode

1func SheetCode(tile int) string
source

SheetCode is "A1" … "P16": row letter + column number.

func SheetSVG

1func SheetSVG(seed string, cfg Config, p Place) string
source

SheetSVG is the full sheet of token seed at place p.

func SheetTraits

1func SheetTraits(seed string, cfg Config, p Place) []engine.Trait
source

SheetTraits are the traits of token seed at place p, in TraitTypes order. It never renders.

func Traits

1func Traits(in engine.Input) []engine.Trait
source

Traits returns the eight traits of a standalone sheet of in.Seed.

func ValidateParams

1func ValidateParams(params string) error
source

ValidateParams accepts "" (the showcase defaults) and the canonical JSON.

func Defaults

1func Defaults() Config
source

Defaults is the showcase look (params "").

func ParseParams

1func ParseParams(params string) (Config, error)
source

ParseParams accepts "" or the canonical JSON Studio produces, nothing else.

func Placement

1func Placement(cid string, tid int64, salt string) Place
source

Placement is token tid (1..256) of a Final collection with salt salt.

func Standalone

1func Standalone(seed string, cfg Config) Place
source

Standalone is the placement of a seed without a collection: a sheet of the seed's own map, drawn among the sheets with land at their centre (any sheet when the map has none).

Types 2

type Config

struct
1type Config struct {
2	Palette  int // -1: from the map seed
3	Landform int // -1: from the map seed
4}
source

Config is a parsed params string.

type Place

struct
1type Place struct {
2	MapSeed string
3	Tile    int
4}
source

Place is where a token lies: the map it belongs to and its sheet (0..255, row-major).

Dependencies

Source Files 2