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.

z2_pure_crash_filetest.gno

0.74 Kb · 22 lines
 1// PKGPATH: gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/z2
 2
 3// A function bot from a /p/ package that crashes is caught by the arena and
 4// loses by forfeit in the same transaction.
 5package z2
 6
 7import (
 8	"gno.land/p/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/testbots"
 9	"gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2"
10	_ "gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/bots/starter/v2"
11)
12
13func main(cur realm) {
14	arena.RegisterStrategy(cross(cur), "crasher", testbots.Crasher)
15	println(arena.Fight(cross(cur), "brawler", "crasher"))
16	info, _ := arena.GetBot("crasher")
17	println("losses:", info.Losses, "forfeits:", info.Forfeits)
18}
19
20// Output:
21// #1 brawler wins by forfeit: crasher crashed on turn 10
22// losses: 1 forfeits: 1