note description: "[ Represents one of the air force attack units in VITP. ]" author: "Jimmy J. Johnson" deferred class AIR_UNIT inherit ATTACK_UNIT redefine patrol_distance, raid_distance, arrival_location -- arrival_position end feature -- Access patrol_distance: INTEGER = 1000 -- How may sea areas can Current move through as patroller? -- Just set to a very large number. raid_distance: INTEGER = 1000 -- How may sea areas can Current move through as raider? -- Just set to a very large number. arrival_location: LOCATION -- The port or sea area at which this unit may enter the game do if is_returning_unit then if nationality = game.japanese then Result := game.uncommitted_japanese_location else Result := game.uncommitted_allied_location end else Result := Precursor end end -- arrival_position: like position -- -- The location (latitude/longitude-like coordinates) where Current -- -- will enter the game -- local -- sop: VITP_SEQUENCE_OF_PLAY -- do -- sop := game.sequence_of_play -- if nationality = game.japanese then -- Result := [250, 50] -- else -- if sop.turn = 1 and Current = game.eleventh_af then -- Result := [700, 300] -- elseif sop.turn = 1 and Current = game.fifth_af then -- Result := [130, 320] -- else -- Result := [700, 560] -- end -- end -- end feature -- Status report is_sunk: BOOLEAN -- Has the unit been sunk this turn? do Result := damage >= defense_factor end is_patrollable: BOOLEAN = True -- Can this unit be a patroller for area control purposes? is_raidable: BOOLEAN = False -- Can this unit be a raider? is_patrolling: BOOLEAN = False -- Is this unit a patroller (as opposed to a raider)? -- Air units a `is_patrollable' but don't move as patrollers. is_raiding: BOOLEAN = False -- Is this unit a raider? feature -- Basic operations return_to_port (a_port: PORT) require -- is_return_allowed: is_at_sea and then a_port.controller = nationality and then -- (location.adjoins (a_port) or else a_port.is_major) do location := a_port end repair -- Do repairs on the ship require -- is_in_port: location.is_port port_has_repair_capability: do end -- join_force (a_other: ATTACK_UNIT) -- -- Join forces with `a_other' as a single `task_force' -- do -- check -- do_not_call: false then -- -- Because inapplicable to {AIR_UNIT} -- end -- end -- leave_force -- -- Remove Current from the `task_force' to which it belongs, but only -- -- if there are other ships in the force, and put it in its own. -- do -- check -- do_not_call: false then -- -- Because inapplicable to {AIR_UNIT} -- end -- end feature -- Query is_incompatible_position (a_position: VITP_POSITION): BOOLEAN -- Is `a_position' located on a unit with which Current is NOT -- allowed to `join_force' (e.g. on a submarine or an enemy)? local u_list: VITP_TABLE [ATTACK_UNIT] au: ATTACK_UNIT do if not is_in_game then Result := false else u_list := game.all_attack_units from u_list.start until u_list.after or else Result loop au := u_list.item_for_iteration Result := au.contains_position (a_position) u_list.forth end end -- Temp for testing Result := false end feature {NONE} -- Implementaion end