예제 #1
0
    def execute(self, command, env=None):
        unit = command.arguments['unit']
        delay = command.time + Duration(0, 2)
        moment = get_moment(delay.turn, delay.impulse, 'emergency-deceleration')
        cmd = Command(command, emergency_deceleration, moment, {'unit' : System})
	cmd.insert_into_queue(command.queue, env)

        actions = [command.create_action('emergency-deceleration', unit, '{0} announces emergency deceleration'.format(unit.id))]
	return actions
예제 #2
0
    def execute(self, command, env=None):
        unit = command.arguments['unit']
        speed_plot = command.arguments['speed-plot']
	unit.properties['speed-plot'] = speed_plot
	actions = [command.create_action('property-change', unit, '{0} changes speed plot'.format(unit.id), {'speed-plot': speed_plot}, True)]
        actions.extend(super(ShuttleDetermineInitialSpeed, self).execute(command, env))
	registry = import_object(settings.REGISTRY)
	move = registry.get('move')
	for impulse in speed_plot:
	    time = get_moment(command.time.turn, impulse, move.step)
	    cmd = Command(command.owner, move, time, {'unit': unit})
	    cmd.insert_into_queue(command.queue)
	    actions.append(command.create_action('queue-command', unit, "{0} queued 'Move' command at {1}".format(unit.id, time), {'command': cmd}, True))
	return actions
예제 #3
0
    def execute(self, command, env=None):
        game = command.arguments['game']
        # insert mandatory commands for this turn
        for unit in game.units:
            for c in unit.exposed_commands:
                if not c.required: 
		    continue
                base_moment = game.sequence_of_play.get_moment(c.step) + Duration(command.time.turn)
                arguments = {'unit' : unit}
                if base_moment.impulse is None:
                    cmd = Command(self, c, base_moment, arguments)
                    cmd.insert_into_queue(command.queue, env)
                else:
                    for i in range(IMPULSES_PER_TURN):
                        moment = base_moment + Duration(0, i)
                        cmd = Command(self, c, moment, arguments)
                        cmd.insert_into_queue(command.queue, env)
 
        # insert next turn-setup command for next turn
        moment = command.time + Duration(1)
        cmd = Command(self, self, moment, command.arguments)
        cmd.insert_into_queue(command.queue)

	return [command.create_action('turn-setup', game, 'Turn setup')]