#include "Command.h"
#include "List.h"

using namespace std;

Command *Command::loadCommand(List *command)
{
	Command *newCommand;

	if(command->firstString() == JumpCommand::id())
		newCommand = new JumpCommand(command);
	else if(command->firstString() == JumpResetCommand::id())
		newCommand = new JumpResetCommand(command);
	else if(command->firstString() == MoveCommand::id())
		newCommand = new MoveCommand(command);
	else if(command->firstString() == TurnCommand::id())
		newCommand = new TurnCommand(command);
	else if(command->firstString() == PlayMusicCommand::id())
		newCommand = new PlayMusicCommand(command);
	else if(command->firstString() == PlaySoundCommand::id())
		newCommand = new PlaySoundCommand(command);
	else if(command->firstString() == FollowPlayerCommand::id())
		newCommand = new FollowPlayerCommand(command);
	else if(command->firstString() == FollowPlayerInRangeCommand::id())
		newCommand = new FollowPlayerInRangeCommand(command);
	else if(command->firstString() == ShootCommand::id())
		newCommand = new ShootCommand(command);
	else if(command->firstString() == SecondaryShootCommand::id())
		newCommand = new SecondaryShootCommand(command);
	else if(command->firstString() == ShootInRangeCommand::id())
		newCommand = new ShootInRangeCommand(command);
	else if(command->firstString() == CutSceneTextCommand::id())
		newCommand = new CutSceneTextCommand(command);
	else if(command->firstString() == SetCameraCommand::id())
		newCommand = new SetCameraCommand(command);
	else if(command->firstString() == SetControlCommand::id())
		newCommand = new SetControlCommand(command);
	else if(command->firstString() == PlayScriptCommand::id())
		newCommand = new PlayScriptCommand(command);
	else if(command->firstString() == AimCommand::id())
		newCommand = new AimCommand(command);
	else if(command->firstString() == SetCutSceneCommand::id())
		newCommand = new SetCutSceneCommand(command);
	else if(command->firstString() == AddHealthCommand::id())
		newCommand = new AddHealthCommand(command);
	else if(command->firstString() == AddWeaponCommand::id())
		newCommand = new AddWeaponCommand(command);
	else if(command->firstString() == SetDoorLockCommand::id())
		newCommand = new SetDoorLockCommand(command);
	else if(command->firstString() == AddScoreCommand::id())
		newCommand = new AddScoreCommand(command);
	else if(command->firstString() == EndLevelCommand::id())
		newCommand = new EndLevelCommand(command);
	else if(command->firstString() == StopPersonCommand::id())
		newCommand = new StopPersonCommand(command);
	else if(command->firstString() == CrouchCommand::id())
		newCommand = new CrouchCommand(command);
	else if(command->firstString() == SaveCommand::id())
		newCommand = new SaveCommand(command);
	else if(command->firstString() == RestoreCommand::id())
		newCommand = new RestoreCommand(command);
	else if(command->firstString() == SetPositionCommand::id())
		newCommand = new SetPositionCommand(command);
	else if(command->firstString() == ActivateCutSceneCommand::id())
		newCommand = new ActivateCutSceneCommand(command);
	else if(command->firstString() == KillCommand::id())
		newCommand = new KillCommand(command);
	else if(command->firstString() == ActivateEnemyCommand::id())
		newCommand = new ActivateEnemyCommand(command);
	else if(command->firstString() == InvincibleCommand::id())
		newCommand = new InvincibleCommand(command);
	else if(command->firstString() == FlushCommand::id())
		newCommand = new FlushCommand(command);
	else if(command->firstString() == LiveCommand::id())
		newCommand = new LiveCommand(command);
	
	else
		cerr << "Unknown command type: " << command->firstString() << endl;

	return newCommand;
}