Skip to content

Instantly share code, notes, and snippets.

@ennorehling
Last active November 19, 2024 08:50
Show Gist options
  • Save ennorehling/d9a4d8b29ae09d1206fa6aa59142a1f1 to your computer and use it in GitHub Desktop.
Save ennorehling/d9a4d8b29ae09d1206fa6aa59142a1f1 to your computer and use it in GitHub Desktop.
function test_give_person_first()
local r = region.create(0, 0, "plain")
local f = faction.create('human')
local u1 = unit.create(f, r, 1)
local u2 = unit.create(f, r, 1)
local u3 = unit.create(f, r, 1)
u3:add_item('sword', 10)
u3:add_order("GIB " .. itoa36(u2.id) .. " ALLES PERSON")
u3:add_order("GIB " .. itoa36(u2.id) .. " ALLES")
process_orders()
assert_equal(2, u2.number)
assert_equal(0, u1:get_item('sword'))
assert_equal(10, u2:get_item('sword'))
end
function test_give_person_last()
local r = region.create(0, 0, "plain")
local f = faction.create('human')
local u1 = unit.create(f, r, 1)
local u2 = unit.create(f, r, 1)
local u3 = unit.create(f, r, 1)
u3:add_item('sword', 10)
u3:add_order("GIB " .. itoa36(u2.id) .. " ALLES")
u3:add_order("GIB " .. itoa36(u2.id) .. " ALLES PERSON")
process_orders()
assert_equal(2, u2.number)
assert_equal(0, u1:get_item('sword'))
assert_equal(10, u2:get_item('sword'))
end
function test_give_person_catchall()
local r = region.create(0, 0, "plain")
local u = unit.create(faction.create('human'), r, 1)
local f = faction.create('human')
local u1 = unit.create(f, r, 1)
local u2 = unit.create(f, r, 1)
local u3 = unit.create(f, r, 1)
u3:add_item('sword', 10)
u3:add_order("GIB 0 ALLES PERSON")
process_orders()
assert_equal(10, u1:get_item('sword'))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment