def test_mission1(gui):
    """Sample mission which requires multiple buildings to win."""

    # Move ship to coast
    ship = get_player_ship(gui.session)
    gui.select([ship])
    move_ship(gui, ship, (7, 3))

    # Build warehouse
    gui.select([ship])
    gui.trigger("overview_trade_ship/found_settlement")
    gui.cursor_click(10, 5, "left")
    assert_goal_reached(gui, "warehouse")

    # Build main square
    gui.trigger("mainhud/build")
    gui.trigger("tab/button_02")
    gui.cursor_click(9, 11, "left")
    assert_goal_reached(gui, "mainsquare")

    # Build fisher
    gui.trigger("tab/button_23")
    gui.cursor_click(7, 7, "left")

    assert_win(gui)
Example #2
0
def test_mission1(gui):
	"""Sample mission which requires multiple buildings to win."""

	# Move ship to coast
	ship = get_player_ship(gui.session)
	gui.select([ship])
	move_ship(gui, ship, (7, 3))

	# Build warehouse
	gui.select([ship])
	gui.trigger('overview_trade_ship', 'found_settlement')
	gui.cursor_click(10, 5, 'left')
	assert_goal_reached(gui, 'warehouse')

	# Build main square
	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_02')
	gui.cursor_click(9, 11, 'left')
	assert_goal_reached(gui, 'mainsquare')

	# Build fisher
	gui.trigger('tab', 'button_33')
	gui.cursor_click(7, 7, 'left')

	assert_win(gui)
def test_mission1(gui):
	"""Sample mission which requires multiple buildings to win."""

	# Move ship to coast
	ship = get_player_ship(gui.session)
	gui.select([ship])
	move_ship(gui, ship, (7, 3))

	# Build warehouse
	gui.select([ship])
	gui.trigger('overview_trade_ship', 'found_settlement')
	gui.cursor_click(10, 5, 'left')
	assert_goal_reached(gui, 'warehouse')

	# Build main square
	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_02')
	gui.cursor_click(9, 11, 'left')
	assert_goal_reached(gui, 'mainsquare')

	# Build fisher
	gui.trigger('tab', 'button_33')
	gui.cursor_click(7, 7, 'left')

	assert_win(gui)
Example #4
0
def test_tutorial(gui):
    """Test the tutorial scenario."""

    # FIXME disable disasters (this should be an option for a scenario)
    gui.session.world.disaster_manager.disabled = True

    def assert_progress(progress):
        wait_and_close_logbook(gui)
        assert var_eq(gui.session, 'tutorial_progress', progress)

    # Tutorial start
    assert_progress(16)

    # Goal: Build warehouse
    ship = get_player_ship(gui.session)
    gui.select([ship])
    move_ship(gui, ship, (11, 1))

    # Save and reload scenario (1/3)
    saveload(gui)

    gui.trigger('overview_trade_ship/found_settlement')
    gui.cursor_click(11, 6, 'left')

    # Goal: Build a lumberjack
    assert_progress(19)

    # lumberjack (2)
    gui.trigger('mainhud/build')
    gui.trigger('tab/button_03')
    gui.cursor_click(8, 10, 'left', shift=True)
    gui.cursor_click(13, 10, 'left')
    gui.cursor_click(13, 10, 'right')

    # plant some extra trees around the lumberjacks
    gui.trigger('tab/button_13')
    gui.cursor_drag((6, 13), (15, 8), 'left')

    # roads (no dragging to trigger the 'you can drag roads' hint)
    gui.trigger('tab/button_21')
    gui.cursor_multi_click((10, 8), (10, 9), (10, 10), (11, 10))

    # Goal: Build hunter and fisher
    assert_progress(22)

    # fisher
    gui.trigger('tab/button_23')
    gui.cursor_click(13, 6, 'left')

    # hunter
    gui.trigger('tab/button_13')
    gui.cursor_click(8, 8, 'left')

    # Goal: Mainsquare
    assert_progress(25)

    gui.trigger('tab/button_02')
    gui.cursor_click(15, 18, 'left')

    # Goal: first tent
    assert_progress(28)

    # roads
    gui.trigger('tab/button_21')
    gui.cursor_drag((13, 15), (20, 15), 'left')
    gui.cursor_click(20, 15, 'right')

    # tent
    gui.trigger('tab/button_01')
    gui.cursor_click(13, 13, 'left')

    # Goal: 4 tents
    assert_progress(31)

    gui.trigger('tab/button_01')
    gui.cursor_multi_click((15, 13), (17, 13), (19, 13))

    # Goal: Build a signal fire
    assert_progress(34)

    # Save and reload scenario (2/3)
    saveload(gui)

    # Open build menu again (it is not reloaded, unlike selected instances)
    gui.trigger('mainhud/build')
    gui.trigger('tab_base/0')

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 5):
        gui.run()

    gui.trigger('tab/button_22')
    gui.cursor_click(9, 5, 'left')

    # Goal: Trading
    assert_progress(37)

    # Buy tools from the trader (put the resource on the buy list)
    gui.cursor_click(11, 6, 'left')
    gui.trigger('tab_base/2')
    gui.trigger('slot_0/button', mouse='left')
    gui.trigger('select_trade_resource/resource_%d' % RES.TOOLS)
    gui.find('slot_0/slider').slide(30)

    # Goal: Pavilion
    assert_progress(40)

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 5):
        gui.run()

    gui.trigger('mainhud/build')
    gui.trigger('tab/button_12')
    gui.cursor_click(19, 16, 'left')

    # Goal: Next tier
    assert_progress(43)

    # Adjust settler taxes (using mainsquare)
    gui.cursor_click(16, 18, 'left')
    gui.trigger('tab_base/1')
    gui.find('tax_slider').slide(0)
    gui.trigger('mainhud/build')

    # wait until settlers upgraded
    while not settler_level_greater(gui.session, TIER.SAILORS):
        gui.run()

    # Goal: Farm
    assert_progress(46)

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 10):
        gui.run()

    gui.trigger('tab_base/1')  # FIXME this sometimes fails
    gui.trigger('tab/button_02')
    gui.cursor_click(25, 12, 'left')

    # Goal: Fields
    assert_progress(49)

    gui.trigger('tab_base/1')

    # potato
    gui.trigger('tab/button_12')
    gui.cursor_click(23, 11, 'left')

    # Save and reload scenario (3/3)
    saveload(gui)

    # Open build menu again
    gui.trigger('mainhud/build')
    gui.trigger('tab_base/1')

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 3):
        gui.run()

    # pasture
    gui.trigger('tab/button_22')
    gui.cursor_click(24, 8, 'left')

    # Goal: Storage
    assert_progress(52)

    # remove a tree to connect to farm
    gui.trigger('mainhud/destroy_tool')
    gui.cursor_click(21, 15, 'left')

    # roads
    gui.trigger('mainhud/build')
    gui.trigger('tab_base/0')
    gui.trigger('tab/button_21')
    gui.cursor_drag((21, 15), (24, 14), 'left')
    gui.cursor_click(24, 14, 'right')
    # back of mainsquare
    gui.trigger('tab/button_21')
    gui.cursor_drag((13, 22), (20, 22), 'left')
    gui.cursor_click(20, 22, 'right')

    # storage tent
    gui.trigger('tab/button_11')
    gui.cursor_click(21, 16, 'left')

    # Goal: Weaver
    assert_progress(55)

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 10):
        gui.run()

    gui.trigger('tab_base/1')
    gui.trigger('tab/button_21')
    gui.cursor_click(25, 14, 'left')

    # Goal: 50 inhabitants, positive balance
    assert_progress(58)

    # more potato fields
    gui.trigger('tab_base/1')
    gui.trigger('tab/button_12')
    gui.cursor_multi_click((24, 9), (27, 8), (27, 11))

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 39):
        gui.run()

    # tents
    gui.trigger('tab_base/0')
    gui.trigger('tab/button_01')
    gui.cursor_multi_click((11, 14), (11, 15), (12, 17), (11, 20), (11, 22),
                           (13, 23), (15, 23), (17, 23), (19, 23), (19, 20),
                           (22, 15), (19, 18), (20, 21))

    # Goal: Won
    assert_progress(61)

    assert_win(gui)
Example #5
0
def test_win(gui):
	"""Simple test that detects a win in a game."""

	assert_win(gui)
def test_tutorial(gui):
    """Test the tutorial scenario."""

    # FIXME disable disasters (this should be an option for a scenario)
    gui.session.world.disaster_manager.disabled = True

    def assert_progress(progress):
        wait_and_close_logbook(gui)
        assert var_eq(gui.session, "tutorial_progress", progress)

        # Tutorial start

    assert_progress(16)

    # Goal: Build warehouse
    ship = get_player_ship(gui.session)
    move_ship(ship, (11, 1))

    gui.select([ship])
    gui.trigger("overview_trade_ship", "found_settlement")
    gui.cursor_click(11, 6, "left")

    # Goal: Build a lumberjack
    assert_progress(19)

    # lumberjack
    gui.trigger("mainhud", "build")
    gui.trigger("tab", "button_03")
    gui.cursor_click(8, 10, "left")

    # roads
    gui.trigger("tab", "button_21")
    gui.cursor_multi_click((10, 8), (10, 9), (10, 10))

    # Goal: Build hunter and fisher
    assert_progress(22)

    # fisher
    gui.trigger("tab", "button_33")
    gui.cursor_click(13, 6, "left")

    # hunter
    gui.trigger("tab", "button_23")
    gui.cursor_click(8, 8, "left")

    # Goal: Mainsquare
    assert_progress(25)

    gui.trigger("tab", "button_02")
    gui.cursor_click(15, 18, "left")

    # Goal: first tent
    assert_progress(28)

    # roads
    gui.trigger("tab", "button_21")
    gui.cursor_multi_click((13, 15), (14, 15), (16, 15), (17, 15), (18, 15), (19, 15), (20, 15))

    # tent
    gui.trigger("tab", "button_01")
    gui.cursor_click(13, 13, "left")

    # Goal: 4 tents
    assert_progress(31)

    gui.trigger("tab", "button_01")
    gui.cursor_multi_click((15, 13), (17, 13), (19, 13))

    # Goal: Build a signal fire
    assert_progress(34)

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 5):
        gui.run()

    gui.trigger("tab", "button_22")
    gui.cursor_click(9, 5, "left")

    # Goal: Trading
    assert_progress(37)

    # TODO do this with the gui (needs named buttons and a way to control the slider)
    player = gui.session.world.player
    tradepost = player.settlements[0].get_component(TradePostComponent)
    AddToBuyList(tradepost, RES.TOOLS, 30)(player)

    # Goal: Pavilion
    assert_progress(40)

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 5):
        gui.run()

    gui.trigger("tab", "button_12")
    gui.cursor_click(19, 16, "left")

    # Goal: Next tier
    assert_progress(43)

    # TODO adjust settler taxes

    # wait until settlers upgraded
    while not settler_level_greater(gui.session, TIER.SAILORS):
        gui.run()

        # Goal: Farm
    assert_progress(46)

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 10):
        gui.run()

    gui.trigger("tab_base", "1")  # FIXME this sometimes fails
    gui.trigger("tab", "button_02")
    gui.cursor_click(25, 12, "left")

    # Goal: Fields
    assert_progress(49)

    gui.trigger("tab_base", "1")

    # potato
    gui.trigger("tab", "button_12")
    gui.cursor_click(23, 11, "left")

    # pasture
    gui.trigger("tab", "button_22")
    gui.cursor_click(21, 10, "left")

    # Goal: Storage
    assert_progress(52)

    # remove a tree to connect to farm
    gui.trigger("mainhud", "destroy_tool")
    gui.cursor_click(21, 15, "left")

    # roads
    gui.trigger("mainhud", "build")
    gui.trigger("tab_base", "0")
    gui.trigger("tab", "button_21")
    gui.cursor_multi_click((21, 15), (22, 15), (23, 15), (24, 15), (24, 14))

    # storage tent
    gui.trigger("tab", "button_11")
    gui.cursor_click(21, 16, "left")

    # Goal: Weaver
    assert_progress(55)

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 10):
        gui.run()

    gui.trigger("tab_base", "1")
    gui.trigger("tab", "button_21")
    gui.cursor_click(25, 14, "left")

    # Goal: 50 inhabitants, positive balance
    assert_progress(58)

    # more potatoe fields
    gui.trigger("tab_base", "1")
    gui.trigger("tab", "button_12")
    gui.cursor_multi_click((24, 9), (27, 8), (27, 11))

    # lumberjack (more wood for upgrades)
    gui.trigger("tab_base", "0")
    gui.trigger("tab", "button_03")
    gui.cursor_click(19, 18, "left")

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 39):
        gui.run()

        # tents
    gui.trigger("tab", "button_01")
    gui.cursor_multi_click(
        (11, 14), (11, 15), (12, 17), (11, 20), (12, 22), (14, 22), (16, 22), (18, 22), (19, 20), (22, 15)
    )

    # Goal: Won
    assert_progress(61)

    assert_win(gui)
Example #7
0
def test_tutorial(gui):
    """Test the tutorial scenario."""

    # FIXME disable disasters (this should be an option for a scenario)
    gui.session.world.disaster_manager.disabled = True

    def assert_progress(progress):
        wait_and_close_logbook(gui)
        assert var_eq(gui.session, 'tutorial_progress', progress)

    # Tutorial start
    assert_progress(16)

    # Goal: Build warehouse
    ship = get_player_ship(gui.session)
    move_ship(ship, (11, 1))

    gui.select([ship])
    gui.trigger('overview_trade_ship', 'found_settlement')
    gui.cursor_click(11, 6, 'left')

    # Goal: Build a lumberjack
    assert_progress(19)

    # lumberjack (2)
    gui.trigger('mainhud', 'build')
    gui.trigger('tab', 'button_03')
    gui.cursor_click(8, 10, 'left', shift=True)
    gui.cursor_click(13, 10, 'left')
    gui.cursor_click(13, 10, 'right')

    # roads
    gui.trigger('tab', 'button_21')
    gui.cursor_multi_click((10, 8), (10, 9), (10, 10), (11, 10))

    # Goal: Build hunter and fisher
    assert_progress(22)

    # fisher
    gui.trigger('tab', 'button_33')
    gui.cursor_click(13, 6, 'left')

    # hunter
    gui.trigger('tab', 'button_23')
    gui.cursor_click(8, 8, 'left')

    # Goal: Mainsquare
    assert_progress(25)

    gui.trigger('tab', 'button_02')
    gui.cursor_click(15, 18, 'left')

    # Goal: first tent
    assert_progress(28)

    # roads
    gui.trigger('tab', 'button_21')
    gui.cursor_multi_click((13, 15), (14, 15), (16, 15), (17, 15), (18, 15),
                           (19, 15), (20, 15))

    # tent
    gui.trigger('tab', 'button_01')
    gui.cursor_click(13, 13, 'left')

    # Goal: 4 tents
    assert_progress(31)

    gui.trigger('tab', 'button_01')
    gui.cursor_multi_click((15, 13), (17, 13), (19, 13))

    # Goal: Build a signal fire
    assert_progress(34)

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 5):
        gui.run()

    gui.trigger('tab', 'button_22')
    gui.cursor_click(9, 5, 'left')

    # Goal: Trading
    assert_progress(37)

    # TODO do this with the gui (needs named buttons and a way to control the slider)
    player = gui.session.world.player
    tradepost = player.settlements[0].get_component(TradePostComponent)
    SetTradeSlot(tradepost, 0, RES.TOOLS, False, 30)(player)

    # Goal: Pavilion
    assert_progress(40)

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 5):
        gui.run()

    gui.trigger('tab', 'button_12')
    gui.cursor_click(19, 16, 'left')

    # Goal: Next tier
    assert_progress(43)

    # TODO adjust settler taxes

    # wait until settlers upgraded
    while not settler_level_greater(gui.session, TIER.SAILORS):
        gui.run()

    # Goal: Farm
    assert_progress(46)

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 10):
        gui.run()

    gui.trigger('tab_base', '1')  # FIXME this sometimes fails
    gui.trigger('tab', 'button_02')
    gui.cursor_click(25, 12, 'left')

    # Goal: Fields
    assert_progress(49)

    gui.trigger('tab_base', '1')

    # potato
    gui.trigger('tab', 'button_12')
    gui.cursor_click(23, 11, 'left')

    # pasture
    gui.trigger('tab', 'button_22')
    gui.cursor_click(21, 10, 'left')

    # Goal: Storage
    assert_progress(52)

    # remove a tree to connect to farm
    gui.trigger('mainhud', 'destroy_tool')
    gui.cursor_click(21, 15, 'left')

    # roads
    gui.trigger('mainhud', 'build')
    gui.trigger('tab_base', '0')
    gui.trigger('tab', 'button_21')
    gui.cursor_multi_click((21, 15), (22, 15), (23, 15), (24, 15), (24, 14))

    # storage tent
    gui.trigger('tab', 'button_11')
    gui.cursor_click(21, 16, 'left')

    # Goal: Weaver
    assert_progress(55)

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 10):
        gui.run()

    gui.trigger('tab_base', '1')
    gui.trigger('tab', 'button_21')
    gui.cursor_click(25, 14, 'left')

    # Goal: 50 inhabitants, positive balance
    assert_progress(58)

    # more potatoe fields
    gui.trigger('tab_base', '1')
    gui.trigger('tab', 'button_12')
    gui.cursor_multi_click((24, 9), (27, 8), (27, 11))

    # lumberjack (more wood for upgrades)
    gui.trigger('tab_base', '0')
    gui.trigger('tab', 'button_03')
    gui.cursor_click(19, 18, 'left')

    # wait until we have enough boards
    while not settlement_res_stored_greater(gui.session, RES.BOARDS, 39):
        gui.run()

    # tents
    gui.trigger('tab', 'button_01')
    gui.cursor_multi_click((11, 14), (11, 15), (12, 17), (11, 20), (12, 22),
                           (14, 22), (16, 22), (18, 22), (19, 20), (22, 15))

    # Goal: Won
    assert_progress(61)

    assert_win(gui)
def test_tutorial(gui):
	"""Test the tutorial scenario."""

	# FIXME disable disasters (this should be an option for a scenario)
	gui.session.world.disaster_manager.disabled = True

	def assert_progress(progress):
		wait_and_close_logbook(gui)
		assert var_eq(gui.session, 'tutorial_progress', progress)

	# Tutorial start
	assert_progress(16)

	# Goal: Build warehouse
	ship = get_player_ship(gui.session)
	gui.select([ship])
	move_ship(gui, ship, (11, 1))

	# Save and reload scenario (1/3)
	saveload(gui)

	gui.trigger('overview_trade_ship', 'found_settlement')
	gui.cursor_click(11, 6, 'left')

	# Goal: Build a lumberjack
	assert_progress(19)

	# lumberjack (2)
	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_03')
	gui.cursor_click(8, 10, 'left', shift=True)
	gui.cursor_click(13, 10, 'left')
	gui.cursor_click(13, 10, 'right')

	# plant some extra trees around the lumberjacks
	gui.trigger('tab', 'button_13')
	gui.cursor_drag((6, 13), (15, 8), 'left')

	# roads (no dragging to trigger the 'you can drag roads' hint)
	gui.trigger('tab', 'button_21')
	gui.cursor_multi_click((10, 8), (10, 9), (10, 10), (11, 10))

	# Goal: Build hunter and fisher
	assert_progress(22)

	# fisher
	gui.trigger('tab', 'button_33')
	gui.cursor_click(13, 6, 'left')

	# hunter
	gui.trigger('tab', 'button_23')
	gui.cursor_click(8, 8, 'left')

	# Goal: Mainsquare
	assert_progress(25)

	gui.trigger('tab', 'button_02')
	gui.cursor_click(15, 18, 'left')

	# Goal: first tent
	assert_progress(28)

	# roads
	gui.trigger('tab', 'button_21')
	gui.cursor_drag((13, 15), (20, 15), 'left')
	gui.cursor_click(20, 15, 'right')

	# tent
	gui.trigger('tab', 'button_01')
	gui.cursor_click(13, 13, 'left')

	# Goal: 4 tents
	assert_progress(31)

	gui.trigger('tab', 'button_01')
	gui.cursor_multi_click((15, 13), (17, 13), (19, 13))

	# Goal: Build a signal fire
	assert_progress(34)

	# Save and reload scenario (2/3)
	saveload(gui)

	# Open build menu again (it is not reloaded, unlike selected instances)
	gui.trigger('mainhud', 'build')
	gui.trigger('tab_base', '0')

	# wait until we have enough boards
	while not settlement_res_stored_greater(gui.session, RES.BOARDS, 5):
		gui.run()

	gui.trigger('tab', 'button_22')
	gui.cursor_click(9, 5, 'left')

	# Goal: Trading
	assert_progress(37)

	# Buy tools from the trader (put the resource on the buy list)
	gui.cursor_click(11, 6, 'left')
	gui.trigger('tab_base', '2')
	gui.trigger('buysellmenu/slot_0', 'button', mouse='left')
	gui.trigger('select_trade_resource', 'resource_%d' % RES.TOOLS)
	gui.find('buysellmenu/slot_0/slider').slide(30)

	# Goal: Pavilion
	assert_progress(40)

	# wait until we have enough boards
	while not settlement_res_stored_greater(gui.session, RES.BOARDS, 5):
		gui.run()

	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_12')
	gui.cursor_click(19, 16, 'left')

	# Goal: Next tier
	assert_progress(43)

	# Adjust settler taxes (using mainsquare)
	gui.cursor_click(16, 18, 'left')
	gui.trigger('tab_base', '1')
	gui.find('tax_slider').slide(0)
	gui.trigger('mainhud', 'build')

	# wait until settlers upgraded
	while not settler_level_greater(gui.session, TIER.SAILORS):
		gui.run()

	# Goal: Farm
	assert_progress(46)

	# wait until we have enough boards
	while not settlement_res_stored_greater(gui.session, RES.BOARDS, 10):
		gui.run()

	gui.trigger('tab_base', '1') # FIXME this sometimes fails
	gui.trigger('tab', 'button_02')
	gui.cursor_click(25, 12, 'left')

	# Goal: Fields
	assert_progress(49)

	gui.trigger('tab_base', '1')

	# potato
	gui.trigger('tab', 'button_12')
	gui.cursor_click(23, 11, 'left')

	# Save and reload scenario (3/3)
	saveload(gui)

	# Open build menu again
	gui.trigger('mainhud', 'build')
	gui.trigger('tab_base', '1')

	# pasture
	gui.trigger('tab', 'button_22')
	gui.cursor_click(21, 10, 'left')

	# Goal: Storage
	assert_progress(52)

	# remove a tree to connect to farm
	gui.trigger('mainhud', 'destroy_tool')
	gui.cursor_click(21, 15, 'left')

	# roads
	gui.trigger('mainhud', 'build')
	gui.trigger('tab_base', '0')
	gui.trigger('tab', 'button_21')
	gui.cursor_drag((21, 15), (24, 14), 'left')
	gui.cursor_click(24, 14, 'right')
	# back of mainsquare
	gui.trigger('tab', 'button_21')
	gui.cursor_drag((13, 22), (20, 22), 'left')
	gui.cursor_click(20, 22, 'right')

	# storage tent
	gui.trigger('tab', 'button_11')
	gui.cursor_click(21, 16, 'left')

	# Goal: Weaver
	assert_progress(55)

	# wait until we have enough boards
	while not settlement_res_stored_greater(gui.session, RES.BOARDS, 10):
		gui.run()

	gui.trigger('tab_base', '1')
	gui.trigger('tab', 'button_21')
	gui.cursor_click(25, 14, 'left')

	# Goal: 50 inhabitants, positive balance
	assert_progress(58)

	# more potato fields
	gui.trigger('tab_base', '1')
	gui.trigger('tab', 'button_12')
	gui.cursor_multi_click((24, 9), (27, 8), (27, 11))

	# wait until we have enough boards
	while not settlement_res_stored_greater(gui.session, RES.BOARDS, 39):
		gui.run()

	# tents
	gui.trigger('tab_base', '0')
	gui.trigger('tab', 'button_01')
	gui.cursor_multi_click(
		(11, 14), (11, 15), (12, 17), (11, 20), (11, 22),
		(13, 23), (15, 23), (17, 23), (19, 23),
		(19, 20), (22, 15), (19, 18), (20, 21)
	)

	# Goal: Won
	assert_progress(61)

	assert_win(gui)
def test_tutorial(gui):
	"""Test the tutorial scenario."""

	# FIXME disable disasters (this should be an option for a scenario)
	gui.session.world.disaster_manager.disabled = True

	def assert_progress(progress):
		wait_and_close_logbook(gui)
		assert var_eq(gui.session, 'tutorial_progress', progress)

	# Tutorial start
	assert_progress(16)

	# Goal: Build warehouse
	ship = get_player_ship(gui.session)
	move_ship(ship, (11, 1))

	gui.select([ship])
	gui.trigger('overview_trade_ship', 'found_settlement')
	gui.cursor_click(11, 6, 'left')

	# Goal: Build a lumberjack
	assert_progress(19)

	# lumberjack (2)
	gui.trigger('mainhud', 'build')
	gui.trigger('tab', 'button_03')
	gui.cursor_click(8, 10, 'left', shift=True)
	gui.cursor_click(13, 10, 'left')
	gui.cursor_click(13, 10, 'right')

	# add extra trees around the lumberjacks
	gui.trigger('tab', 'button_13')
	settlement = gui.session.world.islands[0].settlements[0]
	for lumberjack_coords in [(8, 10), (13, 10)]:
		building = settlement.ground_map[lumberjack_coords].object
		for coords in building.position.get_radius_coordinates(building.radius):
			if coords not in settlement.ground_map:
				continue
			tile = settlement.ground_map[coords]
			if tile.object is None and 'constructible' in tile.classes:
				gui.cursor_click(coords[0], coords[1], 'left', shift=True)
	gui.cursor_click(13, 10, 'right')

	# roads
	gui.trigger('tab', 'button_21')
	gui.cursor_multi_click((10, 8), (10, 9), (10, 10), (11, 10))

	# Goal: Build hunter and fisher
	assert_progress(22)

	# fisher
	gui.trigger('tab', 'button_33')
	gui.cursor_click(13, 6, 'left')

	# hunter
	gui.trigger('tab', 'button_23')
	gui.cursor_click(8, 8, 'left')
	
	# Goal: Mainsquare
	assert_progress(25)

	gui.trigger('tab', 'button_02')
	gui.cursor_click(15, 18, 'left')

	# Goal: first tent
	assert_progress(28)

	# roads
	gui.trigger('tab', 'button_21')
	gui.cursor_multi_click(
		(13, 15), (14, 15), (16, 15), (17, 15),
		(18, 15), (19, 15), (20, 15)
	)

	# tent
	gui.trigger('tab', 'button_01')
	gui.cursor_click(13, 13, 'left')

	# Goal: 4 tents
	assert_progress(31)

	gui.trigger('tab', 'button_01')
	gui.cursor_multi_click((15, 13), (17, 13), (19, 13))

	# Goal: Build a signal fire
	assert_progress(34)

	# wait until we have enough boards
	while not settlement_res_stored_greater(gui.session, RES.BOARDS, 5):
		gui.run()

	gui.trigger('tab', 'button_22')
	gui.cursor_click(9, 5, 'left')

	# Goal: Trading
	assert_progress(37)

	# TODO do this with the gui (needs named buttons and a way to control the slider)
	player = gui.session.world.player
	tradepost = player.settlements[0].get_component(TradePostComponent)
	SetTradeSlot(tradepost, 0, RES.TOOLS, False, 30)(player)

	# Goal: Pavilion
	assert_progress(40)

	# wait until we have enough boards
	while not settlement_res_stored_greater(gui.session, RES.BOARDS, 5):
		gui.run()

	gui.trigger('tab', 'button_12')
	gui.cursor_click(19, 16, 'left')

	# Goal: Next tier
	assert_progress(43)

	# TODO adjust settler taxes

	# wait until settlers upgraded
	while not settler_level_greater(gui.session, TIER.SAILORS):
		gui.run()

	# Goal: Farm
	assert_progress(46)

	# wait until we have enough boards
	while not settlement_res_stored_greater(gui.session, RES.BOARDS, 10):
		gui.run()

	gui.trigger('tab_base', '1') # FIXME this sometimes fails
	gui.trigger('tab', 'button_02')
	gui.cursor_click(25, 12, 'left')
	
	# Goal: Fields
	assert_progress(49)

	gui.trigger('tab_base', '1')

	# potato
	gui.trigger('tab', 'button_12')
	gui.cursor_click(23, 11, 'left')

	# pasture
	gui.trigger('tab', 'button_22')
	gui.cursor_click(21, 10, 'left')

	# Goal: Storage
	assert_progress(52)

	# remove a tree to connect to farm
	gui.trigger('mainhud', 'destroy_tool')
	gui.cursor_click(21, 15, 'left')

	# roads
	gui.trigger('mainhud', 'build')
	gui.trigger('tab_base', '0')
	gui.trigger('tab', 'button_21')
	gui.cursor_multi_click((21, 15), (22, 15), (23, 15), (24, 15), (24, 14))
	
	# storage tent
	gui.trigger('tab', 'button_11')
	gui.cursor_click(21, 16, 'left')

	# Goal: Weaver
	assert_progress(55)

	# wait until we have enough boards
	while not settlement_res_stored_greater(gui.session, RES.BOARDS, 10):
		gui.run()

	gui.trigger('tab_base', '1')
	gui.trigger('tab', 'button_21')
	gui.cursor_click(25, 14, 'left')

	# Goal: 50 inhabitants, positive balance
	assert_progress(58)
	
	# more potatoe fields
	gui.trigger('tab_base', '1')
	gui.trigger('tab', 'button_12')
	gui.cursor_multi_click((24, 9), (27, 8), (27, 11))

	# lumberjack (more wood for upgrades)
	gui.trigger('tab_base', '0')
	gui.trigger('tab', 'button_03')
	gui.cursor_click(19, 18, 'left')

	# wait until we have enough boards
	while not settlement_res_stored_greater(gui.session, RES.BOARDS, 39):
		gui.run()

	# tents
	gui.trigger('tab', 'button_01')
	gui.cursor_multi_click(
		(11, 14), (11, 15), (12, 17), (11, 20),
		(12, 22), (14, 22), (16, 22), (18, 22),
		(19, 20), (22, 15)
	)

	# Goal: Won
	assert_progress(61)

	assert_win(gui)
def test_win(gui):
	"""Simple test that detects a win in a game."""

	assert_win(gui)