note
	description: "[
		A {VITP_COMMAND} that removes a unit from its current task
		force and changes the unit's position and location.
	]"
	author: "Jimmy J. Johnson"

class
	LEAVE_TASK_FORCE_AND_MOVE_COMMAND

inherit

	VITP_COMMAND
		redefine
--			default_create,
			text,
			execute,
			undo
		end

create
--	default_create,
	make

feature {NONE} -- Initialization

--	default_create
--			-- Create an instance
--		do
--			Precursor {VITP_COMMAND}
--			create leave_command
--			create reposition_command
--			create move_command
--		end

	make (a_unit: like unit; a_position: like position; a_location: LOCATION)
			-- Initialize a command that can reposition `a_unit' to `a_position'
			-- and move it to `a_location'.
		require
			unit_exists: a_unit /= Void
			position_exists: a_position /= Void
			location_exists: a_location /= Void
		do
			default_create
			create leave_command.make (a_unit)
			create reposition_command.make (a_unit, a_position)
			create move_command.make (a_unit, a_location)
		end

feature -- Access

	text: STRING
			-- Description of the command
		do
			Result := "COMMAND:  Leave Task Force & Move -- "+ unit.name + " from " + old_location.name
			Result := Result + " to " + location.name
		end

	unit: ATTACK_UNIT
			-- The unit that this command operates on
		do
			Result := leave_command.unit
		end

	position: VITP_POSITION
			-- The position to which `unit' is to be moved
		do
			Result := reposition_command.position
		end

	location: LOCATION
			-- The location to which `unit' is to be moved
		do
			Result := move_command.location
		end

	old_position: VITP_POSITION
			-- The position from which `unit' was moved
		do
			Result := reposition_command.old_position
		end

	old_location: LOCATION
			-- The locatiopn from which `unit' was moved
		do
			Result := move_command.old_location
		end

feature -- Basic operations

	execute
			-- Perform the action
		do
			Precursor {VITP_COMMAND}
			leave_command.execute
			move_command.execute
			reposition_command.execute
		end

	undo
			-- Reverse the effects of executing the command
		do
			Precursor {VITP_COMMAND}
			reposition_command.undo
			move_command.undo
			leave_command.undo
		end

feature {NONE} -- Implementation

	leave_command: LEAVE_TASK_FORCE_COMMAND
			-- Command whose execution removes the unit from its task force

	reposition_command: REPOSITION_COMMAND
			-- Command whose execution changes the unit's `position'

	move_command: MOVE_COMMAND
			-- Command whose execution changes the unit's `location'.

end
