Sturdy little horses that graze the paddock. Hold an apple or carrots and they come to you, and Interact to feed one from your hand. Feed one three times and it trusts you: then Interact with a saddle in hand and it's yours to ride. Steer it with your movement, and it steps up anything a block high. Make a saddle at a workbench from leather and an iron ingot.
| 1 | --!strict |
| 2 | -- Ponies' own tests: `potluck-server --test=ponies`. |
| 3 | local test = require("@potluck/test@0.9") |
| 4 | local world = require("@potluck/world@0.25") |
| 5 | local store = require("@potluck/store") |
| 6 | |
| 7 | local function ponies(): { number } |
| 8 | return world.creatures(test.kind("Pony")) |
| 9 | end |
| 10 | |
| 11 | test.case("feed one three times, saddle it and ride", function() |
| 12 | local p = test.player("Ada", { survival = true, carrying = { Apple = 3, Saddle = 1 } }) |
| 13 | test.wait(1) |
| 14 | test.same(#ponies(), 3, "a herd in the paddock") |
| 15 | local pony = test.creature(ponies()[1]) |
| 16 | test.move(p, pony.position + vector.create(1.5, 0, 0)) |
| 17 | test.hold(p, "Saddle") |
| 18 | test.use(p, pony) |
| 19 | test.same(pony.kind, "Pony", "it won't take a saddle from a stranger") |
| 20 | test.same(world.has(p, "Saddle"), 1, "the saddle's still Ada's") |
| 21 | test.hold(p, "Apple") |
| 22 | for _ = 1, 3 do |
| 23 | test.use(p, pony) |
| 24 | end |
| 25 | test.same(world.has(p, "Apple"), 0, "it ate the apples") |
| 26 | test.hold(p, "Saddle") |
| 27 | test.use(p, pony) |
| 28 | test.same(pony.kind, "Saddled pony", "saddled") |
| 29 | test.same(world.has(p, "Saddle"), 0, "the saddle's on it") |
| 30 | test.ride(p, pony) |
| 31 | test.check(pony.rider ~= nil, "Ada's riding") |
| 32 | test.wait(1.5) |
| 33 | test.same(store.get("saddled"), 1, "kept with the world") |
| 34 | end) |
| 35 | |
| 36 | test.case("bopped, a pony shies away and gives nothing", function() |
| 37 | local p = test.player("Ada", { survival = true }) |
| 38 | test.wait(1) |
| 39 | local pony = test.creature(ponies()[1]) |
| 40 | test.move(p, pony.position + vector.create(1.5, 0, 0)) |
| 41 | test.hit(p, pony) |
| 42 | test.wait(2) |
| 43 | test.check(vector.magnitude(pony.position - p.position) > 3, "it shied away") |
| 44 | local n = 0 |
| 45 | for _ in world.pockets(p) or {} do |
| 46 | n += 1 |
| 47 | end |
| 48 | test.same(n, 0, "and gave nothing") |
| 49 | end) |