Created
March 17, 2024 12:32
-
-
Save ennorehling/35f7b5a952fbf30eec88c21b0eb95a98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function test_leave_harbour() | |
local f = faction.create('human') | |
local r1 = region.create(1, 0, 'ocean') | |
local r2 = region.create(-1, 0, 'ocean') | |
local r = region.create(0, 0, 'glacier') | |
local b = building.create(r, 'harbour', 25) | |
local sh = ship.create(r1, 'longboat') | |
local u = unit.create(f, r1, 1) | |
local u2 = unit.create(f, r, 1) | |
u2.building = b | |
u.name = 'Xolgrim' | |
u.ship = sh | |
u:set_skill('sailing', 10) | |
-- kein Hafenunterhalt, keine Einreise | |
u:set_orders('NACH W') | |
process_orders() | |
assert_false(b.working) | |
assert_equal(r1, sh.region) | |
-- Hafenunterhalt, Einreise erlaubt | |
u2:add_item('money', 250) | |
u:set_orders('NACH W') | |
process_orders() | |
assert_true(b.working) | |
assert_equal(r, sh.region) | |
assert_equal(0, u2:get_item('money')) | |
-- Kein Unterhalt, Abreise in "falsche" Richtung | |
u:set_orders('NACH W') | |
process_orders() | |
assert_false(b.working) | |
assert_equal(r2, sh.region) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment