Exemplo n.º 1
0
	def run(self, seconds=0):
		"""Provide a nice way to run the game for some time.

		Despite its name, this method will run the *game simulation* for X seconds.
		When the game is paused, the timer continues once the game unpauses.
		"""

		if not seconds:
			cooperative.schedule()
		else:
			# little hack because we don't have Python3's nonlocal
			class Flag(object):
				running = True

			def stop():
				Flag.running = False

			# Scheduler only exists inside games, use ExtScheduler in the mainmenu
			if Scheduler():
				ticks = Scheduler().get_ticks(seconds)
				Scheduler().add_new_object(stop, None, run_in=ticks)
			else:
				ExtScheduler().add_new_object(stop, None, run_in=seconds)

			while Flag.running:
				cooperative.schedule()
Exemplo n.º 2
0
def move_ship(gui, ship, coords):
	"""Move ship to coordinates and wait until it arrives."""
	x, y = coords
	gui.cursor_click(x, y, 'right')

	while (ship.position.x, ship.position.y) != (x, y):
		cooperative.schedule()
Exemplo n.º 3
0
def move_ship(gui, ship, coords):
	"""Move ship to coordinates and wait until it arrives."""
	x, y = coords
	gui.cursor_click(x, y, 'right')

	while (ship.position.x, ship.position.y) != (x, y):
		cooperative.schedule()
Exemplo n.º 4
0
	def _tick(self):
		"""Continue test execution.

		This function will be called by the engine's mainloop each frame.
		"""
		try:
			cooperative.schedule()
		except Exception:
			traceback.print_exc()
			sys.exit(1)
	def _tick(self):
		"""Continue test execution.

		This function will be called by the engine's mainloop each frame.
		"""
		try:
			cooperative.schedule()
		except Exception:
			traceback.print_exc()
			sys.exit(1)
Exemplo n.º 6
0
	def _tick(self):
		"""Continue test execution.

		This function will be called by the engine's mainloop each frame.
		"""
		cooperative.schedule()
Exemplo n.º 7
0

def get_player_ship(session):
	"""Returns the first ship of a player."""
	for ship in session.world.ships:
		if ship.owner == session.world.player:
			return ship
	raise Exception('Player ship not found')


def move_ship(gui, ship, (x, y)):
	"""Move ship to coordinates and wait until it arrives."""
	gui.cursor_click(x, y, 'right')

	while (ship.position.x, ship.position.y) != (x, y):
		cooperative.schedule()


def found_settlement(gui, ship_pos, (x, y)):
	"""Move ship to coordinates and build a warehouse."""
	ship = get_player_ship(gui.session)
	gui.select([ship])
	move_ship(gui, ship, ship_pos)

	# Found a settlement
	gui.trigger('overview_trade_ship', 'found_settlement')
	assert isinstance(gui.cursor, BuildingTool)
	gui.cursor_click(x, y, 'left')
	assert isinstance(gui.cursor, CursorTool)

Exemplo n.º 8
0
    def _tick(self):
        """Continue test execution.

		This function will be called by the engine's mainloop each frame.
		"""
        cooperative.schedule()