
#import "Commander.h"
#import "Tracker.h"
#import "XWShip.h"

@implementation Commander

- init
{
	ships = [[List alloc] init];
	targets = [[List alloc] init];
	return self;
}

- free
{
	[ships free];
	[targets free];
	return [super free];
}


- addShip:ship
{
	[ships addObject:ship];
	alliance = [ship alliance];
	return self;
}

- addTarget:target
{
	[targets addObject:target];
	return self;
}

- transferTo:commander
{
	int n = [ships count];
	while (n--)
		[commander addShip:[ships objectAt:n]];
	[ships empty];

	n = [targets count];
	while (n--)
		[commander addTarget:[targets objectAt:n]];
	[targets empty];

	 return self;
}

- oneStep:sender
{
	return self;
}

- reset
{
	int n = [ships count];
	while (n--)
		[self resetShip:[ships objectAt:n]];
	 return self;
}

- resetShip:ship
{
	return ship;
}

@end
