note
	description: "[
		Command used to move widgets in VITP
		]"
	author: "Jimmy J. Johnson"

class
	MOVE_COMMAND

inherit

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

--	LOCATION_CONSTANTS
--		undefine
--			default_create
--		end

--	ATTACK_UNIT_CONSTANTS
--		undefine
--			default_create
--		end

create
--	default_create,
	make

feature {NONE} -- Initialization

--	default_create
--			-- Create an instance
--		do
--			Precursor {VITP_COMMAND}
--			unit := Default_ship
--			location := Still_in_box
--			old_location := Still_in_box
--		end

	make (a_unit: like unit; a_location: like location)
			-- Initialize a command that can move `a_unit' to `a_to_location'
		require
			unit_exists: a_unit /= Void
			location_exists: a_location /= Void
		do
			default_create
			unit := a_unit
			location := a_location
			old_location := a_unit.game.still_in_box
			affected_objects.extend (unit)
		end

feature -- Access

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

	unit: ATTACK_UNIT
			-- The unit to be moved

	location: LOCATION
			-- The location to which `unit' is to be moved

	old_location: LOCATION
			-- The location from which `unit' was moved

feature -- Basic operations

	execute
			-- Perform the action
		do
			Precursor {VITP_COMMAND}
			old_location := unit.location
			unit.set_location (location)
		end

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

feature -- Status report

end
