v0 source realm
7
11
func BestOf
ActionBestOf returns the best score a player ever reached.
func BestOfKey
ActionBestOfKey is BestOf for a raw address string.
func HasMove
ActionHasMove reports whether any move is still possible.
func Itoa
ActionItoa is a dependency-free int->string for realm Render.
func Move
crossing ActionMove slides the signer's board once: dir is up, down, left or right (or u, d, l, r). A move that changes nothing is not counted.
func NewGame
crossing ActionNewGame starts a fresh board for the signer, replacing any current game. The best score ever reached is kept for the leaderboard.
func Play
crossing ActionPlay applies a sequence of moves in a single transaction, e.g. "lldrul" (u=up, d=down, l=left, r=right; spaces and commas are ignored). It stops early when the game is over. At most MaxPlayMoves moves per call.
func Render
Render serves the tavern home (path "") or a player's board (path = g1...).
func ScoreOf
ActionScoreOf returns the current score of a player (0 if no game).
func NewBoard
ActionNewBoard returns a fresh board with the two starting tiles.
func NewBoardSeeded
ActionNewBoardSeeded returns a fresh board whose two starting tiles are placed from seed, so every game starts differently but reproducibly.
2
type Board
structBoard is one 4x4 game. Zero is an empty cell.
Methods on Board
func Move
method on BoardMove applies a direction (0=up,1=right,2=down,3=left) to the board, awards merge points and spawns one new tile from the block-height seed. spawnSeed makes the spawn reproducible: pass blockheight() on chain. Returns the updated board and a human-readable outcome.
type Game
structGame is one player's current game.