z1_publish_filetest.gno
2.44 Kb · 52 lines
1// PKGPATH: gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/z1
2
3// Publish two moves and read them back.
4package z1
5
6import "gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/moves/v3"
7
8func main(cur realm) {
9 println(moves.Check("Blink Thief/60/D82S11"))
10 println(moves.Check("Blink Thief/84/D82S11"))
11 a := moves.Publish(cross(cur), "Blink Thief/84/D82S11")
12 b := moves.Publish(cross(cur), "Long Pull/24/P15")
13 println(a, b, moves.Count())
14 println(moves.Recipe(b))
15 println(moves.List(0, 10))
16 println(moves.ByAuthor(moves.Author(a)))
17 println(moves.Render(""))
18 println(moves.Render("move/1"))
19}
20
21// Output:
22// recipe: these effects need a cooldown of at least 84
23// ok 84
24// 1 2 2
25// Long Pull/24/P15
26// [{"id":2,"author":"g1uaj9za4jkmc4e49h2a2n0cru7jfv60lgcxcjf4","recipe":"Long Pull/24/P15","name":"Long Pull","cd":24,"cost":24},{"id":1,"author":"g1uaj9za4jkmc4e49h2a2n0cru7jfv60lgcxcjf4","recipe":"Blink Thief/84/D82S11","name":"Blink Thief","cd":84,"cost":84}]
27// [{"id":1,"author":"g1uaj9za4jkmc4e49h2a2n0cru7jfv60lgcxcjf4","recipe":"Blink Thief/84/D82S11","name":"Blink Thief","cd":84,"cost":84},{"id":2,"author":"g1uaj9za4jkmc4e49h2a2n0cru7jfv60lgcxcjf4","recipe":"Long Pull/24/P15","name":"Long Pull","cd":24,"cost":24}]
28// # Move recipes
29//
30// Special moves anyone can design, written as data. Equip one in the brawler to use it in place of your class special; the chain runs it with the same rules as the browser.
31//
32// A recipe is `name/cooldown/effects`, for example `Blink Thief/84/D82S11`: dash 4 squares to the nearest gold, then steal 1 gold in melee. Stronger effects need longer cooldowns. Check one with `Check(recipe)` and publish it with `Publish(recipe)`.
33//
34// ## Newest
35//
36// | # | Move | Recharge | What it does | Author |
37// |---|---|---|---|---|
38// | [#2](:move/2) | Long Pull | 2.4s | pull the nearest coin within 5 squares | [g1uaj9…cjf4](:by/g1uaj9za4jkmc4e49h2a2n0cru7jfv60lgcxcjf4) |
39// | [#1](:move/1) | Blink Thief | 8.4s | dash 4 squares to the nearest gold, then steal 1 gold within 1.45 squares | [g1uaj9…cjf4](:by/g1uaj9za4jkmc4e49h2a2n0cru7jfv60lgcxcjf4) |
40//
41// 2 moves published.
42//
43// Need testnet GNOT to play? Get it free at [faucet.gno.land](https://faucet.gno.land).
44//
45// # Blink Thief
46//
47// Move #1 by [g1uaj9…cjf4](:by/g1uaj9za4jkmc4e49h2a2n0cru7jfv60lgcxcjf4). Recharges in 8.4s (its effects need at least 8.4s).
48//
49// - dash 4 squares to the nearest gold
50// - steal 1 gold within 1.45 squares
51//
52// Recipe: `Blink Thief/84/D82S11`