note
	description: "[
		A step in the {SEQUENCE_OF_PLAY} in {VITP_GAME}
		in which the active player is placing his arriving units.
		]"
	author:    "Jimmy J. Johnson"
	date:      "11/11/23"
	copyright: "Copyright (c) 2023, Jimmy J. Johnson"
	license:   "Eiffel Forum v2 (http://www.eiffel.com/licensing/forum.txt)"

class
	PLACE_ARRIVING_UNITS_STEP

inherit

	GAME_STEP
		redefine
			make,
			is_completed
		end

create
	make

feature {NONE} -- Initialization

	make (a_game: VITP_GAME)
			-- Create an instance
		do
			create steps.make (0)
			game := a_game
				-- Just represents a single action at a time
			is_sequential := false
			is_alternating := true
		end

feature -- Access

	name: STRING
			-- Displayable name of Current step
		do
			Result := "Place Arriving Units"
		end

feature -- Status report

	is_completed: BOOLEAN
			-- Are all actions to be accomplished in this
			-- state finished, allowing `advance' to the
			-- next state?
		local
			sop: VITP_SEQUENCE_OF_PLAY
			p: like {NATIONALITY_CONSTANTS}.japanese
			i: INTEGER
			tab: VITP_TABLE [ATTACK_UNIT]
			u: ATTACK_UNIT
		do
			print (generating_type.out + ".is_completed:  fix m!! %N")
			Result := True

			sop := game.sequence_of_play
			p := sop.player
			i := sop.turn
			if p = {NATIONALITY_CONSTANTS}.japanese then
				tab := game.turn_x_units (i, game.japanese_ships)
			else
				tab := game.turn_x_units (i, game.allied_ships)
			end
			from tab.start
			until tab.after
			loop
				u := tab.item_for_iteration
				tab.forth
			end
		end

end
