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.

Playground

gnomod.toml

module = "gno.land/r/g1lnkytfqcjwllws63gvf0mv9yt04aswy4y9amhm/shots"
gno = "0.9"

[addpkg]
  creator = "g1lnkytfqcjwllws63gvf0mv9yt04aswy4y9amhm"
  height = 163392
  max_deposit = "100000000ugnot"

shots.gno

// Package shots is a pay-to-play penalty shootout against the chain.
//
// A creator opens a game by choosing its keeper and ball constants and
// seeding the pot. A challenger joins an open game by paying its entry fee
// into the pot, then plays a shootout: in every round they take a kick
// (TakeShot) and then keep against the chain's kick (SubmitKeeperPlan). Five
// kicks each, finishing early when one side cannot be caught, then sudden
// death. Win, and the whole pot is paid out; lose, and the entry fee stays in
// the pot for the next challenger.
//
// Every kick is played out in the transaction that makes it: the player's
// choices are completed by 32 bytes derived from the block's timestamp (the
// chain's move and the mishit), and the outcome is penalty.SimulateShot of the
// ten inputs, recorded so anyone can re-run it. See impl/v1 for what that
// entropy does and does not guarantee.
//
// This realm's path and entry points are permanent. The rules engine is an
// implementation realm behind an upgradeable proxy
// (gno.land/p/g1lnkytfqcjwllws63gvf0mv9yt04aswy4y9amhm/upgradeable/v0); the games and their pots live here
// and survive every upgrade.
package shots

import (
	"chain/runtime/unsafe"
	"strconv"
	"strings"

	"gno.land/p/g1lnkytfqcjwllws63gvf0mv9yt04aswy4y9amhm/penalty/v0"
	"gno.land/p/g1lnkytfqcjwllws63gvf0mv9yt04aswy4y9amhm/shootout/v0"
	"gno.land/p/g1lnkytfqcjwllws63gvf0mv9yt04aswy4y9amhm/upgradeable/v0"
)

// Impl is the rules engine. Declared here so every version agrees on one
// type identity. The methods are non-crossing: this realm threads its own cur
// in, so an implementation reaching Store is seen as this realm.
//
// The caller's address and the coins received are established by the entry
// points below and passed in; an implementation cannot be invoked with forged
// ones from elsewhere, because without this realm's live cur it cannot reach
// the state at all.
type Impl interface {
	CreateGame(_ int, rlm realm, creator address, deposit, entryFee, timeoutBlocks int64, config string) uint64
	JoinGame(_ int, rlm realm, player address, gameID uint64, paid int64)
	TopUp(_ int, rlm realm, from address, gameID uint64, paid int64)
	TakeShot(_ int, rlm realm, player address, gameID uint64, shot penalty.ShotInput) shootout.Kick
	SubmitKeeperPlan(_ int, rlm realm, player address, gameID uint64, plan penalty.KeeperPlan) shootout.Kick
	Forfeit(_ int, rlm realm, caller address, gameID uint64)
	CancelGame(_ int, rlm realm, caller address, gameID uint64)

	// SimulateShot is the pure outcome function: six taker inputs (in shot,
	// mishit seed included) and four keeper inputs, under cfg.
	SimulateShot(shot penalty.ShotParams, plan penalty.KeeperPlan, cfg penalty.Config) penalty.Result

	// Describe names the implementation for Render.
	Describe() string
}

// Denom is the coin pots are held in.
const Denom = "ugnot"

// Admin may accept, roll back or freeze an implementation. The value is the
// standard test1 account so the tests run unedited; set your own address
// before deploying (TransferAuthority moves it afterwards).
const Admin = address("g1lnkytfqcjwllws63gvf0mv9yt04aswy4y9amhm")

var (
	proxy    *upgradeable.Proxy
	selfPath string
)

func init(cur realm) {
	selfPath = cur.PkgPath()
	proxy = upgradeable.New(upgradeable.NewAddrAuthority(Admin))
}

// ---------------------------------------------------------------- playing

// CreateGame opens a game. Send the initial pot with the call (ugnot).
// config overrides the default constants as "key=value,..." ("" for the
// defaults; see penalty.ParseConfig). timeoutBlocks 0 picks the default.
// Returns the game id.
func CreateGame(cur realm, entryFee, timeoutBlocks int64, config string) uint64 {
	paid := receivePayment(0, cur)
	return live().CreateGame(0, cur, cur.Previous().Address(), paid, entryFee, timeoutBlocks, config)
}

// JoinGame starts a shootout in an open game. Send exactly its entry fee.
func JoinGame(cur realm, gameID uint64) {
	paid := receivePayment(0, cur)
	live().JoinGame(0, cur, cur.Previous().Address(), gameID, paid)
}

// TopUp adds the coins sent to a game's pot.
func TopUp(cur realm, gameID uint64) {
	paid := receivePayment(0, cur)
	live().TopUp(0, cur, cur.Previous().Address(), gameID, paid)
}

// TakeShot plays the player's kick for the current round against the chain's
// keeper: aim point on the goal plane (mm), contact offset on the ball
// (milli-radii) and power (per-mille). Returns the kick as JSON.
func TakeShot(cur realm, gameID uint64, aimX, aimY, contactX, contactY, power int64) string {
	assertFreeDirectCall(0, cur)
	shot := penalty.ShotInput{AimX: aimX, AimY: aimY, ContactX: contactX, ContactY: contactY, Power: power}
	return kickJSON(live().TakeShot(0, cur, cur.Previous().Address(), gameID, shot))
}

// SubmitKeeperPlan plays the player's keeper plan against the chain's kick
// for the current round: four uint16 (see penalty.DecodePlan). Returns the
// kick as JSON.
func SubmitKeeperPlan(cur realm, gameID uint64, direction, speed, jump, reaction uint16) string {
	assertFreeDirectCall(0, cur)
	plan := penalty.KeeperPlan{Direction: direction, Speed: speed, Jump: jump, Reaction: reaction}
	return kickJSON(live().SubmitKeeperPlan(0, cur, cur.Previous().Address(), gameID, plan))
}

// Forfeit ends the current shootout as a loss: the player may resign at any
// time, anyone else once the player has been idle for the game's timeout.
func Forfeit(cur realm, gameID uint64) {
	assertFreeDirectCall(0, cur)
	live().Forfeit(0, cur, cur.Previous().Address(), gameID)
}

// CancelGame refunds the pot to the creator of a game nobody has played yet.
func CancelGame(cur realm, gameID uint64) {
	assertFreeDirectCall(0, cur)
	live().CancelGame(0, cur, cur.Previous().Address(), gameID)
}

// ---------------------------------------------------------------- reading

// SimulateShot runs the live outcome function on ten inputs, without touching
// any state: the taker's aim, contact, power and 48-hex-char mishit seed, and
// the keeper's four uint16, under config ("" for the defaults). Returns JSON.
func SimulateShot(aimX, aimY, contactX, contactY, power int64, mishitHex string,
	direction, speed, jump, reaction uint16, config string) string {
	cfg, err := penalty.ParseConfig(config)
	if err != nil {
		panic(err)
	}
	m, ok := penalty.ParseMishitHex(mishitHex)
	if !ok {
		panic("shots: mishit seed must be 48 hex characters")
	}
	shot := penalty.ShotInput{AimX: aimX, AimY: aimY, ContactX: contactX, ContactY: contactY, Power: power}.WithMishit(m)
	plan := penalty.KeeperPlan{Direction: direction, Speed: speed, Jump: jump, Reaction: reaction}
	return resultJSON(live().SimulateShot(shot, plan, cfg))
}

// GameJSON returns game id as JSON ("" if it does not exist).
func GameJSON(gameID uint64) string {
	g, ok := getGame(gameID)
	if !ok {
		return ""
	}
	return gameJSON(g)
}

// SessionJSON returns session no of a game, kicks included, as JSON.
func SessionJSON(gameID uint64, no int) string {
	s, ok := getSession(gameID, no)
	if !ok {
		return ""
	}
	return sessionJSON(s)
}

// ListGames returns up to limit games as a JSON array, newest first,
// optionally filtered by status ("open", "playing", "won", "cancelled"; ""
// for all).
func ListGames(status string, offset, limit int) string {
	if limit <= 0 || limit > 100 {
		limit = 100
	}
	out := []string{}
	skipped := 0
	games.ReverseIterate("", "", func(_ string, v any) bool {
		g := v.(*shootout.Game)
		if status != "" && g.Status.String() != status {
			return false
		}
		if skipped < offset {
			skipped++
			return false
		}
		out = append(out, gameJSON(*g))
		return len(out) >= limit
	})
	return "[" + strings.Join(out, ",") + "]"
}

// VerifySession re-runs every recorded kick of a shootout through the live
// outcome function and reports whether all of them reproduce, so anyone can
// check a result from the ten recorded inputs alone.
func VerifySession(gameID uint64, no int) bool {
	g, ok := getGame(gameID)
	if !ok {
		return false
	}
	s, ok := getSession(gameID, no)
	if !ok {
		return false
	}
	im := live()
	for _, k := range s.Kicks {
		if im.SimulateShot(k.Shot, k.Plan, g.Config) != k.Result {
			return false
		}
	}
	return true
}

// GameCount returns how many games have been created.
func GameCount() uint64 { return lastID }

// ---------------------------------------------------------------- guards

// receivePayment returns the ugnot sent with a direct user call. The coin
// envelope is credited to this realm only when this realm is the message's
// target, so a payment from any other call shape is refused rather than
// trusted.
func receivePayment(_ int, rlm realm) int64 {
	assertDirect(0, rlm)
	var amount int64
	for _, c := range unsafe.OriginSend() {
		if c.Denom != Denom {
			panic("shots: only " + Denom + " is accepted, got " + c.Denom)
		}
		amount += c.Amount
	}
	return amount
}

// assertFreeDirectCall requires a direct user call that sends no coins.
func assertFreeDirectCall(_ int, rlm realm) {
	assertDirect(0, rlm)
	if len(unsafe.OriginSend()) > 0 {
		panic("shots: this call does not accept coins")
	}
}

func assertDirect(_ int, rlm realm) {
	if !rlm.IsCurrent() || !rlm.Previous().IsUserCall() {
		panic("shots: call this directly from an account (no run scripts or other realms)")
	}
}

// ---------------------------------------------------------------- upgrades

// Register records the calling realm as a candidate implementation; an
// implementation calls it from its own init. Nothing serves until Accept.
func Register(cur realm, impl Impl) { proxy.Propose(0, cur, impl) }

// Accept makes the candidate at pkgPath live. Authority only.
func Accept(cur realm, pkgPath string) { proxy.Accept(0, cur, pkgPath) }

// Withdraw drops a candidate. Authority only, or the candidate itself.
func Withdraw(cur realm, pkgPath string) { proxy.Withdraw(0, cur, pkgPath) }

// Rollback restores the previous implementation. Authority only.
func Rollback(cur realm) { proxy.Rollback(0, cur) }

// Forget drops the rollback history. Authority only.
func Forget(cur realm) { proxy.Forget(0, cur) }

// Freeze ends upgradeability permanently. Authority only.
func Freeze(cur realm) { proxy.Freeze(0, cur) }

// AddExtension lets another realm act as this one. Authority only.
func AddExtension(cur realm, pkgPath string) { proxy.AddExtension(0, cur, pkgPath) }

// DropExtension revokes one. Authority only.
func DropExtension(cur realm, pkgPath string) { proxy.DropExtension(0, cur, pkgPath) }

// TransferAuthority hands the power to upgrade to another address.
func TransferAuthority(cur realm, newOwner address) {
	proxy.TransferAuthority(0, cur, upgradeable.NewAddrAuthority(newOwner))
}

// TransferAuthorityToRealms hands it to governance realms (comma-separated).
func TransferAuthorityToRealms(cur realm, csvPaths string) {
	paths := []string{}
	for _, p := range strings.Split(csvPaths, ",") {
		paths = append(paths, strings.TrimSpace(p))
	}
	proxy.TransferAuthority(0, cur, upgradeable.NewRealmAuthority(paths...))
}

func LivePath() string     { return proxy.LivePath() }
func Frozen() bool         { return proxy.Frozen() }
func Authority() string    { return proxy.Authority().String() }
func Extensions() []string { return proxy.Extensions() }

func PendingPaths() []string {
	out := []string{}
	for _, r := range proxy.Pending() {
		out = append(out, r.PkgPath())
	}
	return out
}

func HistoryPaths() []string {
	out := []string{}
	for _, r := range proxy.History() {
		out = append(out, r.PkgPath())
	}
	return out
}

func live() Impl {
	v, ok := proxy.TryImpl()
	if !ok {
		panic("shots: no implementation has been accepted yet")
	}
	im, ok := v.(Impl)
	if !ok {
		panic("shots: live implementation does not satisfy Impl")
	}
	return im
}

func itoa(n int64) string { return strconv.FormatInt(n, 10) }

state.gno

package shots

import (
	"chain"
	"chain/banker"
	"strconv"

	"gno.land/p/g1lnkytfqcjwllws63gvf0mv9yt04aswy4y9amhm/shootout/v0"
	"gno.land/p/nt/avl/v0"
)

// The game state lives here, at the permanent path, so accepting a new
// implementation changes the rules engine without moving a single pot.
//
// Implementations never hold references into it. They read copies through
// StateRef and write whole values back, so every mutation is performed by
// code declared in this realm and persists here.

var (
	games    = avl.NewTree() // gameKey(id) -> *shootout.Game
	sessions = avl.NewTree() // sessionKey(id, no) -> *shootout.Session
	lastID   uint64
)

func gameKey(id uint64) string {
	s := strconv.FormatUint(id, 10)
	for len(s) < 20 {
		s = "0" + s
	}
	return s
}

func sessionKey(id uint64, no int) string {
	s := strconv.Itoa(no)
	for len(s) < 10 {
		s = "0" + s
	}
	return gameKey(id) + "/" + s
}

func getGame(id uint64) (shootout.Game, bool) {
	v := games.Get(gameKey(id))
	if v == nil {
		return shootout.Game{}, false
	}
	return *(v.(*shootout.Game)), true
}

func getSession(id uint64, no int) (shootout.Session, bool) {
	v := sessions.Get(sessionKey(id, no))
	if v == nil {
		return shootout.Session{}, false
	}
	s := *(v.(*shootout.Session))
	s.Kicks = append([]shootout.Kick(nil), s.Kicks...)
	return s, true
}

// StateRef is a permission to read and write the game state, handed to code
// running on this realm's cur. It carries the caller's realm value and
// re-checks it on every operation, so it cannot be stashed (the VM refuses to
// persist a realm value) or replayed after its frame returns.
type StateRef struct {
	rlm realm
}

// Store hands a StateRef to the live implementation, or to a registered
// extension. Any other realm presents its own cur and is refused.
func Store(_ int, rlm realm) *StateRef {
	assertStateAccess(0, rlm)
	return &StateRef{rlm: rlm}
}

// NewGameID allocates the next game id.
func (r *StateRef) NewGameID() uint64 {
	assertStateAccess(0, r.rlm)
	lastID++
	return lastID
}

// Game returns a copy of game id.
func (r *StateRef) Game(id uint64) (shootout.Game, bool) {
	assertStateAccess(0, r.rlm)
	return getGame(id)
}

// PutGame stores g (by value) under g.ID.
func (r *StateRef) PutGame(g shootout.Game) {
	assertStateAccess(0, r.rlm)
	if g.ID == 0 || g.ID > lastID {
		panic("shots: PutGame with an id that was never allocated")
	}
	c := g
	games.Set(gameKey(g.ID), &c)
}

// Session returns a copy of session no of game id, kicks included.
func (r *StateRef) Session(id uint64, no int) (shootout.Session, bool) {
	assertStateAccess(0, r.rlm)
	return getSession(id, no)
}

// PutSession stores s (by value, kicks copied).
func (r *StateRef) PutSession(s shootout.Session) {
	assertStateAccess(0, r.rlm)
	if _, ok := getGame(s.GameID); !ok || s.No <= 0 {
		panic("shots: PutSession for a game or session that does not exist")
	}
	c := s
	c.Kicks = append([]shootout.Kick(nil), s.Kicks...)
	sessions.Set(sessionKey(s.GameID, s.No), &c)
}

// Pay sends amount ugnot from this realm's balance to to.
func (r *StateRef) Pay(to address, amount int64) {
	assertStateAccess(0, r.rlm)
	if amount <= 0 {
		return
	}
	if !to.IsValid() {
		panic("shots: invalid payee address")
	}
	bk := banker.NewBanker(banker.BankerTypeRealmSend, r.rlm)
	bk.SendCoins(r.rlm.Address(), to, chain.NewCoins(chain.NewCoin(Denom, amount)))
}

// assertStateAccess panics unless rlm is a live cur belonging to this realm
// or to a registered extension.
func assertStateAccess(_ int, rlm realm) {
	if !rlm.IsCurrent() {
		panic("shots: realm value is not the caller's live cur")
	}
	if c := rlm.PkgPath(); c != selfPath && !proxy.IsExtension(c) {
		panic("shots: state is reachable only through " + selfPath +
			" or a registered extension, not from " + c)
	}
}

views.gno

package shots

import (
	"strconv"
	"strings"

	"gno.land/p/g1lnkytfqcjwllws63gvf0mv9yt04aswy4y9amhm/penalty/v0"
	"gno.land/p/g1lnkytfqcjwllws63gvf0mv9yt04aswy4y9amhm/shootout/v0"
)

// ---------------------------------------------------------------- JSON

func q(s string) string { return strconv.Quote(s) }

func kv(k, v string) string { return q(k) + ":" + v }

func obj(fields ...string) string { return "{" + strings.Join(fields, ",") + "}" }

func gameJSON(g shootout.Game) string {
	return obj(
		kv("id", strconv.FormatUint(g.ID, 10)),
		kv("creator", q(string(g.Creator))),
		kv("status", q(g.Status.String())),
		kv("pot", itoa(g.Pot)),
		kv("entryFee", itoa(g.EntryFee)),
		kv("timeoutBlocks", itoa(g.TimeoutBlocks)),
		kv("config", q(g.Config.String())),
		kv("sessions", strconv.Itoa(g.Sessions)),
		kv("winner", q(string(g.Winner))),
		kv("createdHeight", itoa(g.CreatedHeight)),
		kv("closedHeight", itoa(g.ClosedHeight)),
	)
}

func resultJSON(r penalty.Result) string {
	return obj(
		kv("outcome", q(r.Outcome.String())),
		kv("x", itoa(r.X)),
		kv("y", itoa(r.Y)),
		kv("arrivalMs", itoa(r.ArrivalMS)),
		kv("ballSpeed", itoa(r.BallSpeed)),
		kv("mishitX", itoa(r.MishitX)),
		kv("mishitY", itoa(r.MishitY)),
		kv("keeper", q(r.Keeper.String())),
	)
}

func shotJSON(s penalty.ShotInput) string {
	return obj(kv("aimX", itoa(s.AimX)), kv("aimY", itoa(s.AimY)), kv("contactX", itoa(s.ContactX)),
		kv("contactY", itoa(s.ContactY)), kv("power", itoa(s.Power)))
}

func planJSON(p penalty.KeeperPlan) string {
	return obj(kv("direction", strconv.Itoa(int(p.Direction))), kv("speed", strconv.Itoa(int(p.Speed))),
		kv("jump", strconv.Itoa(int(p.Jump))), kv("reaction", strconv.Itoa(int(p.Reaction))))
}

func kickJSON(k shootout.Kick) string {
	return obj(
		kv("round", strconv.Itoa(k.Round)),
		kv("kicker", q(k.Kicker.String())),
		kv("shot", shotJSON(k.Shot.Input())),
		kv("mishit", q(penalty.MishitHex(k.Shot.Mishit))),
		kv("plan", planJSON(k.Plan)),
		kv("seed", q(k.Seed.Hex())),
		kv("result", resultJSON(k.Result)),
		kv("height", itoa(k.Height)),
		kv("time", itoa(k.Time)),
	)
}

func sessionJSON(s shootout.Session) string {
	kicks := make([]string, len(s.Kicks))
	for i, k := range s.Kicks {
		kicks[i] = kickJSON(k)
	}
	sc := s.Score
	return obj(
		kv("gameId", strconv.FormatUint(s.GameID, 10)),
		kv("no", strconv.Itoa(s.No)),
		kv("player", q(string(s.Player))),
		kv("status", q(s.Status.String())),
		kv("paid", itoa(s.Paid)),
		kv("score", obj(kv("playerKicks", strconv.Itoa(sc.PlayerKicks)), kv("playerGoals", strconv.Itoa(sc.PlayerGoals)),
			kv("chainKicks", strconv.Itoa(sc.ChainKicks)), kv("chainGoals", strconv.Itoa(sc.ChainGoals)))),
		kv("next", q(s.Next())),
		kv("kicks", "["+strings.Join(kicks, ",")+"]"),
		kv("joinHeight", itoa(s.JoinHeight)),
		kv("lastActionHeight", itoa(s.LastActionHeight)),
		kv("endHeight", itoa(s.EndHeight)),
	)
}

// ---------------------------------------------------------------- Render

// Render shows the games list, one game ("game/<id>") or one shootout
// ("game/<id>/<session>").
func Render(path string) string {
	parts := strings.Split(strings.Trim(path, "/"), "/")
	if len(parts) >= 2 && parts[0] == "game" {
		id, err := strconv.ParseUint(parts[1], 10, 64)
		if err != nil {
			return "# Not found\n"
		}
		if len(parts) >= 3 {
			no, err := strconv.Atoi(parts[2])
			if err != nil {
				return "# Not found\n"
			}
			return renderSession(id, no)
		}
		return renderGame(id)
	}
	return renderHome()
}

func ugnot(n int64) string {
	whole := n / 1000000
	frac := n % 1000000
	if frac == 0 {
		return itoa(whole) + " GNOT"
	}
	f := strconv.FormatInt(frac+1000000, 10)[1:]
	return itoa(whole) + "." + strings.TrimRight(f, "0") + " GNOT"
}

func renderHome() string {
	var b strings.Builder
	b.WriteString("# Spot Kick\n\nA pay-to-play penalty shootout against the chain. ")
	b.WriteString("Join an open game by paying its entry fee, then take five kicks and keep five. ")
	b.WriteString("Beat the chain and the pot is yours.\n\n")
	b.WriteString("| Game | Status | Pot | Entry | Challengers |\n|---|---|---:|---:|---:|\n")
	n := 0
	games.ReverseIterate("", "", func(_ string, v any) bool {
		g := v.(*shootout.Game)
		id := strconv.FormatUint(g.ID, 10)
		b.WriteString("| [#" + id + "](:game/" + id + ") | " + g.Status.String() + " | " + ugnot(g.Pot) +
			" | " + ugnot(g.EntryFee) + " | " + strconv.Itoa(g.Sessions) + " |\n")
		n++
		return n >= 50
	})
	if n == 0 {
		b.WriteString("| _no games yet_ | | | | |\n")
	}
	b.WriteString("\nRules engine: ")
	if p := proxy.LivePath(); p != "" {
		b.WriteString("`" + p + "` — " + live().Describe() + "\n")
	} else {
		b.WriteString("_none accepted yet_\n")
	}
	return b.String()
}

func renderGame(id uint64) string {
	g, ok := getGame(id)
	if !ok {
		return "# Game not found\n"
	}
	sid := strconv.FormatUint(id, 10)
	var b strings.Builder
	b.WriteString("# Game #" + sid + "\n\n")
	b.WriteString("**" + g.Status.String() + "** · pot **" + ugnot(g.Pot) + "** · entry " + ugnot(g.EntryFee) +
		" · timeout " + itoa(g.TimeoutBlocks) + " blocks\n\n")
	b.WriteString("Created by `" + string(g.Creator) + "` at height " + itoa(g.CreatedHeight) + ".\n\n")
	if g.Status == shootout.GameWon {
		b.WriteString("Won by `" + string(g.Winner) + "` at height " + itoa(g.ClosedHeight) + ".\n\n")
	}
	b.WriteString("Constants: `" + g.Config.String() + "`\n\n")
	if g.Sessions > 0 {
		b.WriteString("## Challengers\n\n| # | Player | Status | Score |\n|---|---|---|---|\n")
		for no := g.Sessions; no >= 1 && no > g.Sessions-50; no-- {
			s, ok := getSession(id, no)
			if !ok {
				continue
			}
			sn := strconv.Itoa(no)
			b.WriteString("| [" + sn + "](:game/" + sid + "/" + sn + ") | `" + string(s.Player) + "` | " +
				s.Status.String() + " | " + score(s.Score) + " |\n")
		}
	}
	return b.String()
}

func score(s penalty.Shootout) string {
	return strconv.Itoa(s.PlayerGoals) + "/" + strconv.Itoa(s.PlayerKicks) + " – " +
		strconv.Itoa(s.ChainGoals) + "/" + strconv.Itoa(s.ChainKicks)
}

func renderSession(id uint64, no int) string {
	s, ok := getSession(id, no)
	if !ok {
		return "# Shootout not found\n"
	}
	var b strings.Builder
	b.WriteString("# Game #" + strconv.FormatUint(id, 10) + " · challenger " + strconv.Itoa(no) + "\n\n")
	b.WriteString("`" + string(s.Player) + "` · **" + s.Status.String() + "** · player " + score(s.Score) +
		" chain · next: " + s.Next() + "\n\n")
	b.WriteString("| Round | Kicker | Shot | Keeper plan | Outcome | At (mm) |\n|---|---|---|---|---|---|\n")
	for _, k := range s.Kicks {
		b.WriteString("| " + strconv.Itoa(k.Round) + " | " + k.Kicker.String() + " | " + k.Shot.Input().String() +
			" | " + k.Plan.String() + " (" + k.Result.Keeper.String() + ") | **" + k.Result.Outcome.String() +
			"** | " + itoa(k.Result.X) + ", " + itoa(k.Result.Y) + " |\n")
	}
	return b.String()
}