note
	description: "[
		A {VITP_COMMAND} that changes the `position' of a unit.
		]"
	author: "Jimmy J. Johnson"

class
	REPOSITION_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}
--			unit := Default_ship
--			create old_position.set_xy (0, 0)
--			create position.set_xy (0, 0)
--		end

	make (a_unit: like unit; a_position: like position)
			-- Initialize a command that can reposition `a_unit' to `a_position'
		require
			unit_exists: a_unit /= Void
			location_exists: a_position /= Void
		do
			default_create
			unit := a_unit
--			unit.set_position (a_position)
			create old_position.set_xy (0, 0)
			create position.set_xy (a_position.longitude, a_position.latitude)
		end

feature -- Access

	text: STRING
			-- Description of the command
		do
			Result := "COMMAND:  Reposition -- "+ unit.name + " from " + old_position.out
			Result := Result + " to " + position.out
		end

	unit: ATTACK_UNIT
			-- The unit to be moved

	position: VITP_POSITION
			-- The position to which `unit' is to be moved

	old_position: VITP_POSITION
			-- The position from which `unit' was moved

feature -- Basic operations

	execute
			-- Perform the action
		local
			i: INTEGER
		do
			Precursor {VITP_COMMAND}
			old_position := unit.position
			if unit.is_task_force then
				from i := 1
				until i > unit.task_force.count
				loop
					unit.task_force.i_th (i).set_position (position)
					i := i + 1
				end
			else
				unit.set_position (position)
			end
		end

	undo
			-- Reverse the effects of executing the command
		do
			Precursor {VITP_COMMAND}
			unit.set_position (old_position)
		end

feature -- Status report

end
