Skip to content

Instantly share code, notes, and snippets.

@ennorehling
Created September 15, 2019 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ennorehling/82c5bef1713c21177519f1abeb2abe5d to your computer and use it in GitHub Desktop.
Save ennorehling/82c5bef1713c21177519f1abeb2abe5d to your computer and use it in GitHub Desktop.
function test_trolls_ride_carts()
local r0 = region.create(0, 0, "plain")
local r1 = region.create(1, 0, "plain")
local r2 = region.create(2, 0, "plain")
local r3 = region.create(3, 0, "plain")
local r4 = region.create(4, 0, "plain")
local f = faction.create("troll")
-- 1. 20 trolls can pull 5 loaded carts:
local u1 = unit.create(f, r0, 20)
u1:add_item("cart", 5)
-- but with 10 or more horses, they should ride in the cart:
u1:set_skill("riding", 1, true)
u1:add_item("horse", 10)
-- trolls weigh 20 GE, horses carry 20, carts carry 100 GE:
u1:add_item("money", 100 * (10 * 20 + 5 * 100 - u1.number * 20))
u1:add_order("NACH O O O")
process_orders()
assert_equal(r2, u1.region)
u1:add_item("money", 1) -- just one wafer thin mint
process_orders()
assert_equal(r3, u1.region) -- can still walk
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment