本文整理汇总了Python中tests.gui.helper.get_player_ship函数的典型用法代码示例。如果您正苦于以下问题:Python get_player_ship函数的具体用法?Python get_player_ship怎么用?Python get_player_ship使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_player_ship函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_change_name_empty_not_allowed
def test_change_name_empty_not_allowed(gui):
"""Make sure an object's name can't be changed to some empty string.
See issue #1978.
"""
ship = get_player_ship(gui.session)
old_name = ship.get_component(NamedComponent).name
gui.select([ship])
# try empty name
def rename_empty():
gui.find('new_name').write('')
gui.trigger('change_name_dialog_window', 'okButton')
with gui.handler(rename_empty):
gui.trigger('overview_trade_ship', 'name')
new_name = ship.get_component(NamedComponent).name
assert old_name == new_name
# try name with just spaces
def rename_spaces():
gui.find('new_name').write(' ')
gui.trigger('change_name_dialog_window', 'okButton')
with gui.handler(rename_spaces):
gui.trigger('overview_trade_ship', 'name')
new_name = ship.get_component(NamedComponent).name
assert old_name == new_name
开发者ID:ThePawnBreak,项目名称:unknown-horizons,代码行数:31,代码来源:test_dialogs.py
示例2: test_mission1
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)
开发者ID:unknown-horizons,项目名称:unknown-horizons,代码行数:25,代码来源:test_simple.py
示例3: test_traderoute
def test_traderoute(gui):
"""Check that a ship's route is configured correctly after setting it up using the GUI."""
ship = get_player_ship(gui.session)
gui.select([ship])
# Create the first settlement
found_settlement(gui, (36, 34), (38, 39))
# Give the resources back to the ship
# Click the trade button
gui.trigger('overview_trade_ship', 'trade')
# Get the default amount (50 t, which is more than all available) of everything
gui.trigger('buy_sell_goods', 'inventory_entry_0')
gui.trigger('buy_sell_goods', 'inventory_entry_1')
gui.trigger('buy_sell_goods', 'inventory_entry_2')
gui.trigger('buy_sell_goods', 'inventory_entry_3')
# Create the second settlement
found_settlement(gui, (27, 28), (28, 22))
# Open the configure trade route widget
gui.trigger('overview_trade_ship', 'configure_route')
# The trade route widget is visible
assert gui.find(name='configure_route')
route_widget = gui.session.ingame_gui._old_menu.current_tab.route_menu
assert not ship.route.wait_at_load
assert not ship.route.wait_at_unload
assert not ship.route.waypoints
# Select the first waypoint for the trade route
event = Mock()
event.getButton.return_value = fife.MouseEvent.LEFT
event.map_coords = 38, 39
route_widget.on_map_click(event, False)
# Select the other waypoint for the trade route
event = Mock()
event.getButton.return_value = fife.MouseEvent.LEFT
event.map_coords = 28, 22
route_widget.on_map_click(event, False)
# Set the resources to be loaded from settlement on the left and the amount
gui.trigger('configure_route/container_1/slot_0', 'button', mouse='left') # Select the second warehouse's first slot
gui.trigger('configure_route', 'resource_%d' % RES.FOOD)
gui.find('configure_route/container_1/slot_0/slider').slide(120)
# Check if the ship obeys the state of "Wait at load" and "Wait at unload"
gui.trigger('configure_route', 'wait_at_load')
gui.trigger('configure_route', 'wait_at_unload')
assert ship.route.wait_at_load
assert ship.route.wait_at_unload
assert len(ship.route.waypoints) == 2
assert Point(38, 39) in ship.route.waypoints[0]['warehouse'].position
assert Point(28, 22) in ship.route.waypoints[1]['warehouse'].position
assert ship.route.waypoints[1]['resource_list'] == {RES.FOOD: 120}
开发者ID:BenjaminHarper,项目名称:unknown-horizons,代码行数:60,代码来源:test_traderoute.py
示例4: test_ticket_1509
def test_ticket_1509(gui):
"""
Crash when quickly switching between tent tabs.
"""
yield
ship = get_player_ship(gui.session)
gui.select([ship])
gui.cursor_click(8, 2, 'right')
while (ship.position.x, ship.position.y) != (8, 2):
yield
# Found a settlement
gui.trigger('overview_trade_ship', 'found_settlement/action/default')
gui.cursor_click(10, 6, 'left')
# Build a tent
gui.trigger('mainhud', 'build/action/default')
gui.trigger('tab', 'button_01/action/default')
gui.cursor_click(7, 10, 'left')
# Select tent
gui.cursor_click(7, 10, 'left')
# quickly switch between tabs
gui.trigger('tab_base', '1/action/default')
yield
gui.trigger('tab_base', '0/action/default')
yield
gui.trigger('tab_base', '1/action/default')
yield TestFinished
开发者ID:DanielStephens,项目名称:unknown-horizons,代码行数:33,代码来源:test_bugs.py
示例5: test_ticket_1369
def test_ticket_1369(gui):
"""
Ship tab closed when moving away from another player's warehouse after trading.
"""
ship = get_player_ship(gui.session)
gui.select([ship])
# ally players so they can trade
world = gui.session.world
for player in world.players:
if player is not ship.owner:
world.diplomacy.add_ally_pair( ship.owner, player )
# move ship near foreign warehouse and wait for it to arrive
move_ship(gui, ship, (68, 23))
# click trade button
gui.trigger('overview_trade_ship', 'trade')
# trade widget visible
assert gui.find(name='buy_sell_goods')
# move ship away from warehouse
move_ship(gui, ship, (77, 17))
# trade widget should not be visible anymore
# For now, the trade widget will stay visible.
# assert gui.find(name='buy_sell_goods') is None
# but the ship overview should be
assert gui.find(name='buy_sell_goods')
开发者ID:BenjaminHarper,项目名称:unknown-horizons,代码行数:32,代码来源:test_bugs.py
示例6: test_mission1
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)
开发者ID:squiddy,项目名称:unknown-horizons,代码行数:25,代码来源:test_simple.py
示例7: test_ticket_1509
def test_ticket_1509(gui):
"""
Crash when quickly switching between tent tabs.
"""
yield
ship = get_player_ship(gui.session)
gui.select([ship])
gui.cursor_click(8, 2, "right")
while (ship.position.x, ship.position.y) != (8, 2):
yield
# Found a settlement
gui.trigger("overview_trade_ship", "found_settlement")
gui.cursor_click(10, 6, "left")
# Build a tent
gui.trigger("mainhud", "build")
gui.trigger("tab", "button_01")
gui.cursor_click(7, 10, "left")
# Select tent
gui.cursor_click(7, 10, "left")
# quickly switch between tabs
gui.trigger("tab_base", "1")
yield
gui.trigger("tab_base", "0")
yield
gui.trigger("tab_base", "1")
yield TestFinished
开发者ID:aedificium,项目名称:aedificium,代码行数:33,代码来源:test_bugs.py
示例8: test_ticket_1371
def test_ticket_1371(gui):
"""
Build related tab becomes invisible.
* use uninterrupted building (press shift)
* click on lumberjack
* click on the 'build related' tab
* click on the tree
* build a tree
=> tab itself is invisible, but buttons for choosing it aren't
"""
yield
ship = get_player_ship(gui.session)
gui.select([ship])
gui.cursor_click(59, 1, 'right')
while (ship.position.x, ship.position.y) != (59, 1):
yield
# Found settlement
gui.trigger('overview_trade_ship', 'found_settlement/action/default')
gui.cursor_click(56, 3, 'left')
gui.trigger('mainhud', 'build/action/default')
# Build lumberjack
gui.trigger('tab', 'button_5/action/default')
gui.cursor_click(52, 7, 'left')
# Select lumberjack
# TODO selecting should work when clicking on the map
settlement = gui.session.world.player.settlements[0]
lumberjack = settlement.get_buildings_by_id(BUILDINGS.LUMBERJACK_CLASS)[0]
gui.select([lumberjack])
# Open build related tab
gui.trigger('tab_base', '1/action/default')
# Select tree
gui.trigger('farm_overview_buildrelated', 'build17/action/default')
# Plant a tree (without uninterrupted building)
gui.cursor_click(49, 6, 'left')
assert gui.find(name='farm_overview_buildrelated')
# Select tree again and plant it with uninterrupted building
gui.trigger('farm_overview_buildrelated', 'build17/action/default')
gui.cursor_click(49, 7, 'left', shift=True)
# Tab should still be there
assert gui.find(name='farm_overview_buildrelated')
yield TestFinished
开发者ID:perher,项目名称:unknown-horizons,代码行数:56,代码来源:test_bugs.py
示例9: test_ticket_1371
def test_ticket_1371(gui):
"""
Build related tab becomes invisible.
* use uninterrupted building (press shift)
* click on lumberjack
* click on the 'build related' tab
* click on the tree
* build a tree
=> tab itself is invisible, but buttons for choosing it aren't
"""
yield
ship = get_player_ship(gui.session)
gui.select([ship])
gui.cursor_click(59, 1, "right")
while (ship.position.x, ship.position.y) != (59, 1):
yield
# Found settlement
gui.trigger("overview_trade_ship", "found_settlement")
gui.cursor_click(56, 3, "left")
gui.trigger("mainhud", "build")
# Build lumberjack
gui.trigger("tab", "button_03")
gui.cursor_click(52, 7, "left")
# Select lumberjack
gui.cursor_click(52, 7, "left")
# Open build related tab
gui.trigger("tab_base", "1")
# Select tree
gui.trigger("overview_buildrelated", "build17")
# Plant a tree (without uninterrupted building)
gui.cursor_click(49, 6, "left")
assert gui.find(name="overview_buildrelated")
# Select tree again and plant it with uninterrupted building
gui.trigger("overview_buildrelated", "build17")
gui.cursor_click(49, 7, "left", shift=True)
# Tab should still be there
assert gui.find(name="overview_buildrelated")
yield TestFinished
开发者ID:aedificium,项目名称:aedificium,代码行数:53,代码来源:test_bugs.py
示例10: test_selection_groups
def test_selection_groups(gui):
"""Check group selection using ctrl-NUM"""
# Starting a new game assigns player ship to group 1
ship = get_player_ship(gui.session)
assert gui.session.selected_instances == set([ship])
gui.select([ship])
# make first group
gui.press_key(gui.Key.NUM_2, ctrl=True)
gui.select( [] )
assert not gui.session.selected_instances
# check group
gui.press_key(gui.Key.NUM_2)
assert iter(gui.session.selected_instances).next() is ship
gui.cursor_click(59, 1, 'right')
while (ship.position.x, ship.position.y) != (59, 1):
gui.run()
# Found settlement
gui.trigger('overview_trade_ship', 'found_settlement')
gui.cursor_click(56, 3, 'left')
gui.trigger('mainhud', 'build')
wh = gui.session.world.player.settlements[0].warehouse
gui.select( [wh] )
gui.press_key(gui.Key.NUM_3, ctrl=True)
# check group again
gui.press_key(gui.Key.NUM_2)
assert len(gui.session.selected_instances) == 1 and \
iter(gui.session.selected_instances).next() is ship
# now other one
gui.press_key(gui.Key.NUM_3)
assert len(gui.session.selected_instances) == 1 and \
iter(gui.session.selected_instances).next() is wh
# check group still once again
gui.press_key(gui.Key.NUM_2)
assert len(gui.session.selected_instances) == 1 and \
iter(gui.session.selected_instances).next() is ship
# no group
gui.press_key(gui.Key.NUM_0)
assert not gui.session.selected_instances
开发者ID:JamesOravec,项目名称:unknown-horizons,代码行数:53,代码来源:test_selection.py
示例11: test_select_ship
def test_select_ship(gui):
"""
Select a ship.
"""
assert gui.find('tab_base') is None
# Find player's ship
player_ship = get_player_ship(gui.session)
gui.select([player_ship])
assert gui.find('overview_trade_ship')
开发者ID:STEVEOO6,项目名称:unknown-horizons,代码行数:12,代码来源:test_selection.py
示例12: test_ticket_1948
def test_ticket_1948(gui):
"""Triggers a crash that happens when building a storage tent on the border of the settlement"""
# Units cannot be selected right now, you need to do it this way. This is almost
# the same as selecting it with the mouse
ship = get_player_ship(gui.session)
gui.select([ship])
found_settlement(gui, (59, 1), (56, 3))
# Select storage tent
gui.trigger('mainhud', 'build')
gui.trigger('tab', 'button_11')
# Build storage at the border of the settlement
gui.cursor_click(37, 20, 'left')
开发者ID:BenjaminHarper,项目名称:unknown-horizons,代码行数:13,代码来源:test_bugs.py
示例13: test_selection_groups
def test_selection_groups(gui):
"""Check group selection using ctrl-NUM"""
ship = get_player_ship(gui.session)
gui.select([ship])
# make first group
gui.press_key(gui.Key.NUM_1, ctrl=True)
gui.select( [] )
assert len(gui.session.selected_instances) == 0
# check group
gui.press_key(gui.Key.NUM_1)
assert iter(gui.session.selected_instances).next() is ship
gui.cursor_click(59, 1, 'right')
while (ship.position.x, ship.position.y) != (59, 1):
yield
# Found settlement
gui.trigger('overview_trade_ship', 'found_settlement/action/default')
gui.cursor_click(56, 3, 'left')
gui.trigger('mainhud', 'build/action/default')
wh = gui.session.world.player.settlements[0].warehouse
gui.select( [wh] )
gui.press_key(gui.Key.NUM_2, ctrl=True)
# check group again
gui.press_key(gui.Key.NUM_1)
assert len(gui.session.selected_instances) == 1 and \
iter(gui.session.selected_instances).next() is ship
# now other one
gui.press_key(gui.Key.NUM_2)
assert len(gui.session.selected_instances) == 1 and \
iter(gui.session.selected_instances).next() is wh
# check group still once again
gui.press_key(gui.Key.NUM_1)
assert len(gui.session.selected_instances) == 1 and \
iter(gui.session.selected_instances).next() is ship
# no group
gui.press_key(gui.Key.NUM_3)
assert len(gui.session.selected_instances) == 0
yield TestFinished
开发者ID:skeet70,项目名称:unknown-horizons,代码行数:51,代码来源:test_selection.py
示例14: test_select_ship
def test_select_ship(gui):
"""
Select a ship.
"""
assert gui.find("overview_trade_ship")
gui.press_key(gui.Key.NUM_0)
assert gui.find("tab_base") is None
# Find player's ship
player_ship = get_player_ship(gui.session)
gui.select([player_ship])
assert gui.find("overview_trade_ship")
开发者ID:korchynskyi,项目名称:unknown-horizons,代码行数:15,代码来源:test_selection.py
示例15: test_select_ship
def test_select_ship(gui):
"""
Select a ship.
"""
yield # test needs to be a generator for now
assert gui.find('tab_base') is None
# Find player's ship
player_ship = get_player_ship(gui.session)
gui.select([player_ship])
assert gui.find('overview_trade_ship')
yield TestFinished
开发者ID:stefanbeller,项目名称:unknown-horizons,代码行数:15,代码来源:test_selection.py
示例16: test_ticket_1369
def test_ticket_1369(gui):
"""
Ship tab closed when moving away from another player's warehouse after trading.
"""
yield
ship = get_player_ship(gui.session)
gui.select([ship])
# ally players so they can trade
world = gui.session.world
for player in world.players:
if player is not ship.owner:
world.diplomacy.add_ally_pair( ship.owner, player )
# move ship near foreign warehouse and wait for it to arrive
gui.cursor_click(68, 23, 'right')
while (ship.position.x, ship.position.y) != (68, 23):
yield
# click trade button
gui.trigger('overview_trade_ship', 'trade/action/default')
# trade widget visible
assert gui.find(name='buy_sell_goods')
# move ship away from warehouse
gui.cursor_click(77, 17, 'right')
while (ship.position.x, ship.position.y) != (77, 17):
yield
# trade widget should not be visible anymore
# For now, the trade widget will stay visible.
# assert gui.find(name='buy_sell_goods') is None
# but the ship overview should be
assert gui.find(name='buy_sell_goods')
# assert gui.find(name='overview_trade_ship')
yield TestFinished
开发者ID:DanielStephens,项目名称:unknown-horizons,代码行数:40,代码来源:test_bugs.py
示例17: test_ticket_1520
def test_ticket_1520(gui):
"""
Crash when completing build after outlined/related buildings were removed.
"""
yield
ship = get_player_ship(gui.session)
gui.select([ship])
gui.cursor_click(8, 2, 'right')
while (ship.position.x, ship.position.y) != (8, 2):
yield
# Found a settlement
gui.trigger('overview_trade_ship', 'found_settlement/action/default')
gui.cursor_click(10, 6, 'left')
ground_map = gui.session.world.islands[0].ground_map
# Build a tent
gui.trigger('mainhud', 'build/action/default')
gui.trigger('tab', 'button_01/action/default')
gui.cursor_click(7, 9, 'left')
assert ground_map[(7, 9)].object.id == BUILDINGS.RESIDENTIAL
# Start building a mainsquare (not releasing left mouse button)
gui.trigger('tab', 'button_02/action/default')
gui.cursor_move(13, 11)
gui.cursor_press_button(13, 11, 'left')
# remove tent
Tear( ground_map[(7, 9)].object ).execute(gui.session)
# release mouse button, finish build
gui.cursor_release_button(13, 11, 'left')
yield TestFinished
开发者ID:DanielStephens,项目名称:unknown-horizons,代码行数:38,代码来源:test_bugs.py
示例18: test_pavilion_build_crash_built_via_settler_related_tab
def test_pavilion_build_crash_built_via_settler_related_tab(gui):
"""
"""
yield
ship = get_player_ship(gui.session)
gui.select([ship])
gui.cursor_click(59, 1, "right")
while (ship.position.x, ship.position.y) != (59, 1):
yield
# Found settlement
gui.trigger("overview_trade_ship", "found_settlement")
gui.cursor_click(56, 3, "left")
gui.trigger("mainhud", "build")
# Build settler
gui.trigger("tab", "button_01")
gui.cursor_click(52, 7, "left")
# Select settler
gui.cursor_click(52, 7, "left")
# Open build related tab
gui.trigger("tab_base", "1")
# Select pavilion
gui.trigger("overview_buildrelated", "build5")
# Plant it
gui.cursor_click(49, 6, "left")
# if we survive until here, the bug hasn't happened
yield TestFinished
开发者ID:aedificium,项目名称:aedificium,代码行数:37,代码来源:test_bugs.py
示例19: test_pavilion_build_crash_built_via_settler_related_tab
def test_pavilion_build_crash_built_via_settler_related_tab(gui):
"""
"""
yield
ship = get_player_ship(gui.session)
gui.select([ship])
gui.cursor_click(59, 1, 'right')
while (ship.position.x, ship.position.y) != (59, 1):
yield
# Found settlement
gui.trigger('overview_trade_ship', 'found_settlement/action/default')
gui.cursor_click(56, 3, 'left')
gui.trigger('mainhud', 'build/action/default')
# Build settler
gui.trigger('tab', 'button_01/action/default')
gui.cursor_click(52, 7, 'left')
# Select settler
gui.cursor_click(52, 7, 'left')
# Open build related tab
gui.trigger('tab_base', '1/action/default')
# Select pavilion
gui.trigger('overview_buildrelated', 'build5/action/default')
# Plant it
gui.cursor_click(49, 6, 'left')
# if we survive until here, the bug hasn't happened
yield TestFinished
开发者ID:DanielStephens,项目名称:unknown-horizons,代码行数:37,代码来源:test_bugs.py
示例20: test_ticket_2475
def test_ticket_2475(gui):
"""Game crashes when two resources are produced in the same tick and the production
finished icon is about to be shown."""
# speed up animation to trigger bug earlier
gui.session.ingame_gui.production_finished_icon_manager.animation_duration = 1
ship = get_player_ship(gui.session)
gui.select([ship])
settlement = found_settlement(gui, (13, 64), (17, 62))
# Place a lumberjack
gui.trigger('mainhud/build')
gui.trigger('tab/button_03')
gui.cursor_click(18, 57, 'left', shift=True)
lumberjack = settlement.buildings_by_id[BUILDINGS.LUMBERJACK][0]
storage = lumberjack.get_component(StorageComponent)
producer = lumberjack.get_component(Producer)
storage.inventory.alter(RES.BOARDS, 5)
producer.on_production_finished({RES.BOARDS: 1})
producer.on_production_finished({RES.BOARDS: 1})
开发者ID:MarkusHackspacher,项目名称:unknown-horizons,代码行数:24,代码来源:test_bugs.py
注:本文中的tests.gui.helper.get_player_ship函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论