note
	description: "[
		Class incapsulating each {PORT} in VITP and responsible for
		the creation of those attributes.  Decomposed into this class
		so that {VITP_GAME} would not be such a large file.
		
		These attributes are used as pseudo-constants.  I elected
		not to use once features becasue the order of calls to 
		once featues may not work for persistence.
		]"
	author: "Jimmy J. Johnson"
	date: "$Date$"
	revision: "$Revision$"

deferred class
	PORT_ATTRIBUTES

feature -- Access

	game: VITP_GAME
			-- The game in which this item belongs.
		deferred
		end

	default_port: DEFAULT_PORT attribute create Result.make (game) end
			-- A {PORT} for use where no other applies.

feature -- Access (major ports)

	australia: AUSTRALIA attribute create Result.make (game) end
	ceylon: CEYLON attribute create Result.make (game) end
	pearl_harbor: PEARL_HARBOR attribute create Result.make (game) end
	saigon: SAIGON attribute create Result.make (game) end
	samoa: SAMOA attribute create Result.make (game) end
	singapore: SINGAPORE attribute create Result.make (game) end
	truk: TRUK attribute create Result.make (game) end
	yokosuka_navy_yard: YOKOSUKA_NAVY_YARD attribute create Result.make (game) end

feature -- Access (minor ports)

	andaman_islands: ANDAMAN_ISLANDS attribute create Result.make (game) end
	attu: ATTU attribute create Result.make (game) end
	dutch_harbor: DUTCH_HARBOR attribute create Result.make (game) end
	johnston_island: JOHNSTON_ISLAND attribute create Result.make (game) end
	guadalcanal: GUADALCANAL attribute create Result.make (game) end
	kwajalein: KWAJALEIN attribute create Result.make (game) end
	lae: LAE attribute create Result.make (game) end
	maloelap: MALOELAP attribute create Result.make (game) end
	midway: MIDWAY attribute create Result.make (game) end
	new_hebrides: NEW_HEBRIDES attribute create Result.make (game) end
	okinawa: OKINAWA attribute create Result.make (game) end
	philippines: PHILIPPINES attribute create Result.make (game) end
	port_moresby: PORT_MORESBY attribute create Result.make (game) end
	saipan: SAIPAN attribute create Result.make (game) end

feature -- Access (port groups)

	ports: VITP_TABLE [PORT]
			-- Convenience feature containing all the major (red) pots on the board
		attribute
			create Result.make (major_ports.count + minor_ports.count)
			Result.merge (major_ports)
			Result.merge (minor_ports)
		end

	major_ports: VITP_TABLE [RED_PORT]
			-- Convenience feature containing all the major (red) pots on the board
		attribute
			create Result.make (8)
			Result.extend (Australia, Australia.name)
			Result.extend (Ceylon, Ceylon.name)
			Result.extend (Pearl_harbor, Pearl_harbor.name)
			Result.extend (Saigon, Saigon.name)
			Result.extend (Samoa, Samoa.name)
			Result.extend (Singapore, Singapore.name)
			Result.extend (Truk, Truk.name)
			Result.extend (Yokosuka_navy_yard, Yokosuka_navy_yard.name)
		end

	minor_ports: VITP_TABLE [GREEN_PORT]
			-- Convenience feature containing all the minor (green) ports on the board
		attribute
			create Result.make (14)
			Result.extend (Andaman_islands, Andaman_islands.name)
			Result.extend (Attu, Attu.name)
			Result.extend (Dutch_harbor, Dutch_harbor.name)
			Result.extend (Johnston_island, Johnston_island.name)
			Result.extend (Guadalcanal, Guadalcanal.name)
			Result.extend (Kwajalein, Kwajalein.name)
			Result.extend (Lae, Lae.name)
			Result.extend (Maloelap, Maloelap.name)
			Result.extend (Midway, Midway.name)
			Result.extend (New_hebrides, New_hebrides.name)
			Result.extend (Okinawa, Okinawa.name)
			Result.extend (Philippines, Philippines.name)
			Result.extend (Port_moresby, Port_moresby.name)
			Result.extend (Saipan, Saipan.name)
		end

	island_ports: VITP_TABLE [PORT]
			-- Convenience feature containig all the island ports
		attribute
			create Result.make (15)
			Result.extend (Andaman_islands, Andaman_islands.name)
			Result.extend (Attu, Attu.name)
			Result.extend (Ceylon, Ceylon.name)
			Result.extend (Dutch_harbor, Dutch_harbor.name)
			Result.extend (Johnston_island, Johnston_island.name)
			Result.extend (Guadalcanal, Guadalcanal.name)
			Result.extend (Kwajalein, Kwajalein.name)
			Result.extend (Maloelap, Maloelap.name)
			Result.extend (Midway, Midway.name)
			Result.extend (New_hebrides, New_hebrides.name)
			Result.extend (Okinawa, Okinawa.name)
			Result.extend (Pearl_harbor, Pearl_harbor.name)
			Result.extend (Saipan, Saipan.name)
			Result.extend (Samoa, Samoa.name)
			Result.extend (Truk, Truk.name)
		end
feature -- Query

	friendly_ports (a_nationality: like {NATIONALITY_CONSTANTS}.japanese): VITP_TABLE [PORT]
			-- All ports and island bases controlled by `a_nationality'
		local
			p: PORT
		do
			create Result.make (ports.count)
			from ports.start
			until ports.after
			loop
				p := ports.item_for_iteration
				if p.nationality = a_nationality then
					Result.extend (p, p.name)
				end
				ports.forth
			end
		end

invariant

	port_count_correct: ports.count = 22
	major_port_count_correct: major_ports.count = 8
	minor_port_count_correct: minor_ports.count = 14
	island_port_count_correct: island_ports.count = 15

end
