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.

cagematch source realm

Package cagematch is the Cage Match arena: it runs deterministic fights between roster fighters, stores the full reca...

Overview

Package cagematch is the Cage Match arena: it runs deterministic fights between roster fighters, stores the full recap of every fight on-chain, and keeps the ladder. Fights are resolved synchronously inside one transaction with bounded compute (9x9 grid, 60 rounds).

Functions 7

func Challenge

crossing Action
1func Challenge(cur realm, a, b string) int
source

Challenge runs a fight between two roster fighters and records it. Anyone may call it; the fight is deterministic and its recap public. Returns the fight id.

func FightRecapJSON

Action
1func FightRecapJSON(id int) string
source

FightRecapJSON renders a fight recap as compact JSON. Frames are flat arrays: [round, ax, ay, bx, by, ahp, bhp, aact, adir, bact, bdir, admg, bdmg].

func Render

1func Render(path string) string
source

Render is the gnoweb entry point. Routes: "" home, "f/<id>" a fight.

func GetFight

Action
1func GetFight(id int) Fight
source

GetFight returns a copy of a recorded fight. Panics if unknown.

Types 2

type Entry

struct
1type Entry struct {
2	Name   string
3	Points int
4	Wins   int
5	Draws  int
6	Losses int
7}
source

Entry is one fighter's ladder record. Points: win 3, draw 1, loss 0.

type Fight

struct
1type Fight struct {
2	ID         int
3	A, B       string
4	Winner     int // 0 = A, 1 = B, -1 = draw
5	Rounds     int
6	Recap      engine.Recap
7	Challenger address
8}
source

Fight is one recorded battle.

Dependencies

Source Files 3