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

pingpong source realm

Package pingpong is a two-player game where the only move is to pass the turn. It exists to demonstrate gnotif: every...

Overview

Package pingpong is a two-player game where the only move is to pass the turn. It exists to demonstrate gnotif: every turn emits TurnPlayed, and the realm declares a verified gnotif trigger that tells the next player.

Functions 4

func DeclareTriggers

crossing Action
1func DeclareTriggers(cur realm)
source

DeclareTriggers declares the "your turn" trigger in the gnotif registry. The registry sees this realm as the caller, so the trigger is verified.

func NewGame

crossing Action
1func NewGame(cur realm, opponent address) string
source

NewGame opens a game against opponent and returns its id. The caller plays first.

func Play

crossing Action
1func Play(cur realm, game string)
source

Play takes the caller's turn in game and passes it to the other player.

func Render

1func Render(path string) string
source

Render lists the games with their players, turn and next player.

Types 1

type Game

struct
1type Game struct {
2	ID                  string
3	First, Second, Next address
4	Turn                int
5}
source

Game is a match between First and Second. First plays turn 1.

Dependencies

Source Files 2