note
	description: "[
		One of the classes that decompose the numourous VITP widgets 
		into more managable groups.  This class models the widgets
		that contain the ports.
		]"
	author:    "Jimmy J. Johnson"
	date:      "5/15/24"
	copyright: "Copyright (c) 2024, Jimmy J. Johnson"
	license:   "Eiffel Forum v2 (http://www.eiffel.com/licensing/forum.txt)"

class
	PORT_WIDGET_FACTORY

inherit

	WIDGET_FACTORY
		redefine
			make_widgets,
			extend_widgets,
			pair_widgets,
			fill_widgets
		end

create
	make

feature {NONE} -- Initialization

	make_widgets
			-- Create widgets for the corresponding game item
		do
			Precursor {WIDGET_FACTORY}
			create port_widgets.make (100)
				-- Create widgets
			create andaman_islands_widget.make (game.andaman_islands)
			create attu_widget.make (game.attu)
			create australia_widget.make (game.australia)
			create ceylon_widget.make (game.ceylon)
			create dutch_harbor_widget.make (game.dutch_harbor)
			create guadalcanal_widget.make (game.guadalcanal)
			create johnston_island_widget.make (game.johnston_island)
			create kwajalein_widget.make (game.kwajalein)
			create lae_widget.make (game.lae)
			create maloelap_widget.make (game.maloelap)
			create midway_widget.make (game.midway)
			create new_hebrides_widget.make (game.new_hebrides)
			create okinawa_widget.make (game.okinawa)
			create pearl_harbor_widget.make (game.pearl_harbor)
			create philippines_widget.make (game.philippines)
			create port_moresby_widget.make (game.port_moresby)
			create saigon_widget.make (game.saigon)
			create saipan_widget.make (game.saipan)
			create samoa_widget.make (game.samoa)
			create singapore_widget.make (game.singapore)
			create truk_widget.make (game.truk)
			create yokosuka_navy_yard_widget.make (game.yokosuka_navy_yard)
		end

feature -- Access (tables)

	port_widgets: VITP_WIDGET_TABLE [PORT_WIDGET, PORT]
			-- Keeps track of widgets

feature -- Access (ports)

	Andaman_islands_widget: ANDAMAN_ISLANDS_WIDGET
	Attu_widget: ATTU_WIDGET
	Australia_widget: AUSTRALIA_WIDGET
	Ceylon_widget: CEYLON_WIDGET
	Dutch_harbor_widget: DUTCH_HARBOR_WIDGET
	Guadalcanal_widget: GUADALCANAL_WIDGET
	Johnston_island_widget: JOHNSTON_ISLAND_WIDGET
	Kwajalein_widget: KWAJALEIN_WIDGET
	Lae_widget: LAE_WIDGET
	Maloelap_widget: MALOELAP_WIDGET
	Midway_widget: MIDWAY_WIDGET
	New_hebrides_widget: NEW_HEBRIDES_WIDGET
	Okinawa_widget: OKINAWA_WIDGET
	Pearl_harbor_widget: PEARL_HARBOR_WIDGET
	Philippines_widget: PHILIPPINES_WIDGET
	Port_moresby_widget: PORT_MORESBY_WIDGET
	Saigon_widget: SAIGON_WIDGET
	Saipan_widget: SAIPAN_WIDGET
	Samoa_widget: SAMOA_WIDGET
	Singapore_widget: SINGAPORE_WIDGET
	Truk_widget: TRUK_WIDGET
	Yokosuka_navy_yard_widget: YOKOSUKA_NAVY_YARD_WIDGET

feature {NONE} -- Implementation

	extend_widgets
			-- Put each widget {ATTACK_UNIT_WIDGET} into `world'.
		do
			port_widgets.extend (Andaman_islands_widget, game.Andaman_islands)
			port_widgets.extend (Attu_widget, game.Attu)
			port_widgets.extend (Australia_widget, game.Australia)
			port_widgets.extend (Ceylon_widget, game.Ceylon)
			port_widgets.extend (Dutch_harbor_widget, game.Dutch_harbor)
			port_widgets.extend (Guadalcanal_widget, game.Guadalcanal)
			port_widgets.extend (Johnston_island_widget, game.Johnston_island)
			port_widgets.extend (Kwajalein_widget, game.Kwajalein)
			port_widgets.extend (Lae_widget, game.Lae)
			port_widgets.extend (Maloelap_widget, game.Maloelap)
			port_widgets.extend (Midway_widget, game.Midway)
			port_widgets.extend (New_hebrides_widget, game.New_hebrides)
			port_widgets.extend (Okinawa_widget, game.Okinawa)
			port_widgets.extend (Pearl_harbor_widget, game.Pearl_harbor)
			port_widgets.extend (Philippines_widget, game.Philippines)
			port_widgets.extend (Port_moresby_widget, game.Port_moresby)
			port_widgets.extend (Saigon_widget, game.Saigon)
			port_widgets.extend (Saipan_widget, game.Saipan)
			port_widgets.extend (Samoa_widget, game.Samoa)
			port_widgets.extend (Singapore_widget, game.Singapore)
			port_widgets.extend (Truk_widget, game.Truk)
			port_widgets.extend (Yokosuka_navy_yard_widget, game.Yokosuka_navy_yard)
			widgets.merge (port_widgets)
		end

	pair_widgets
			-- Associate each widget with a unit
		do
			port_widgets.force (Andaman_islands_widget, game.Andaman_islands)
			port_widgets.force (Attu_widget, game.Attu)
			port_widgets.force (Australia_widget, game.Australia)
			port_widgets.force (Ceylon_widget, game.Ceylon)
			port_widgets.force (Dutch_harbor_widget, game.Dutch_harbor)
			port_widgets.force (Guadalcanal_widget, game.Guadalcanal)
			port_widgets.force (Johnston_island_widget, game.Johnston_island)
			port_widgets.force (Kwajalein_widget, game.Kwajalein)
			port_widgets.force (Lae_widget, game.Lae)
			port_widgets.force (Maloelap_widget, game.Maloelap)
			port_widgets.force (Midway_widget, game.Midway)
			port_widgets.force (New_hebrides_widget, game.New_hebrides)
			port_widgets.force (Okinawa_widget, game.Okinawa)
			port_widgets.force (Pearl_harbor_widget, game.Pearl_harbor)
			port_widgets.force (Philippines_widget, game.Philippines)
			port_widgets.force (Port_moresby_widget, game.Port_moresby)
			port_widgets.force (Saigon_widget, game.Saigon)
			port_widgets.force (Saipan_widget, game.Saipan)
			port_widgets.force (Samoa_widget, game.Samoa)
			port_widgets.force (Singapore_widget, game.Singapore)
			port_widgets.force (Truk_widget, game.Truk)
			port_widgets.force (Yokosuka_navy_yard_widget, game.Yokosuka_navy_yard)
		ensure then
			port_count_correct: port_widgets.count = 22
--			ports_paired: across port_widgets as pw all pw.item.vitp = vitp end
		end

	fill_widgets
			-- Call `set_target' to give each widget a target.
		do
			Andaman_islands_widget.set_target (game.andaman_islands)
			Attu_widget.set_target (game.attu)
			Australia_widget.set_target (game.australia)
			Ceylon_widget.set_target (game.ceylon)
			Dutch_harbor_widget.set_target (game.dutch_harbor)
			Guadalcanal_widget.set_target (game.guadalcanal)
			Johnston_island_widget.set_target (game.johnston_island)
			Kwajalein_widget.set_target (game.kwajalein)
			Lae_widget.set_target (game.lae)
			Maloelap_widget.set_target (game.maloelap)
			Midway_widget.set_target (game.midway)
			New_hebrides_widget.set_target (game.new_hebrides)
			Okinawa_widget.set_target (game.okinawa)
			Pearl_harbor_widget.set_target (game.pearl_harbor)
			Philippines_widget.set_target (game.philippines)
			Port_moresby_widget.set_target (game.port_moresby)
			Saigon_widget.set_target (game.saigon)
			Saipan_widget.set_target (game.saipan)
			Samoa_widget.set_target (game.samoa)
			Singapore_widget.set_target (game.singapore)
			Truk_widget.set_target (game.truk)
			Yokosuka_navy_yard_widget.set_target (game.yokosuka_navy_yard)
		end

end
