note description: "[ Root class for all entities in the VITP game. ]" author: "Jimmy J. Johnson" deferred class VITP_ITEM inherit IDENTIFIED HASHABLE undefine copy, is_equal end feature {NONE} -- Initialization make (a_game: like game) -- Initialize Current do game := a_game nationality := {NATIONALITY_CONSTANTS}.nobody end feature -- Access game: VITP_GAME -- The game in which this item belongs. name: STRING_8 -- The displayed name for this widget deferred end nationality: like game.japanese -- Nation to which this game piece belongs hash_code: INTEGER -- Code based on `name' and the `uuid' of the `vitp' game. -- See `make'. do -- Result := (vitp.uuid.out + name).hash_code Result := object_id end feature -- Element change set_nationality (a_nationality: like nationality) -- Change the `nationality' of Current. do nationality := a_nationality end feature -- Status report is_japanese: BOOLEAN -- Is the location controled by the japanese? do Result := nationality = game.japanese end is_allied: BOOLEAN -- Is the entity controled by the allies? do Result := game.is_allied_nationality (nationality) end is_uncontrolled: BOOLEAN -- Is the entity uncontroled? do Result := not (is_allied or is_japanese) end feature -- Query -- is_equal (other: like Current): BOOLEAN -- -- Is `other' attached to an object considered -- -- equal to current object? -- -- There should only be one widget for each named VITP_ITEM, so -- -- this and descendant can use the `name' to determine equality. -- do -- Result := vitp = other.vitp and name ~ other.name -- end is_opposed (other: VITP_ITEM): BOOLEAN -- Is Current and other on different sides (e.g. Allies or Japanese)? do Result := (is_allied and not other.is_allied) or (not is_allied and other.is_allied) end end