170 lines
3.2 KiB
Plaintext
170 lines
3.2 KiB
Plaintext
note
|
|
description: "[
|
|
A Victory in the Pacific game.
|
|
This class provides access to the game constants and game
|
|
logic (i.e. is a particular action allowed for a unit?)
|
|
]"
|
|
author: "Jimmy J. Johnson"
|
|
|
|
class
|
|
VITP_GAME
|
|
|
|
inherit
|
|
|
|
POSITION_CONSTANTS
|
|
undefine
|
|
copy,
|
|
is_equal
|
|
redefine
|
|
default_create
|
|
end
|
|
|
|
NATIONALITY_CONSTANTS
|
|
undefine
|
|
copy,
|
|
is_equal
|
|
redefine
|
|
default_create
|
|
end
|
|
|
|
ATTACK_UNIT_ATTRIBUTES
|
|
undefine
|
|
copy,
|
|
is_equal
|
|
redefine
|
|
default_create
|
|
end
|
|
|
|
PORT_ATTRIBUTES
|
|
undefine
|
|
copy,
|
|
is_equal
|
|
redefine
|
|
default_create
|
|
end
|
|
|
|
SEA_AREA_ATTRIBUTES
|
|
undefine
|
|
copy,
|
|
is_equal
|
|
redefine
|
|
default_create
|
|
end
|
|
|
|
OTHER_ATTRIBUTES
|
|
undefine
|
|
copy,
|
|
is_equal
|
|
redefine
|
|
default_create
|
|
end
|
|
|
|
VITP_ITEM
|
|
redefine
|
|
default_create
|
|
end
|
|
|
|
create
|
|
default_create
|
|
|
|
feature {NONE} -- Initialization
|
|
|
|
default_create
|
|
-- Initialize Current
|
|
local
|
|
i, j: INTEGER
|
|
c: VITP_CELL
|
|
do
|
|
create command_manager
|
|
uuid := (create {UUID_GENERATOR}).generate_uuid
|
|
name := uuid.out
|
|
create c.make (0,0)
|
|
create grid.make_filled (c, cell_row_count, cell_column_count)
|
|
from i := 1
|
|
until i >= cell_row_count
|
|
loop
|
|
from j := 1
|
|
until j > cell_column_count
|
|
loop
|
|
create c.make ([i, j])
|
|
grid.put (c, i, j)
|
|
j := j + 1
|
|
end
|
|
i := i + 1
|
|
end
|
|
game := Current
|
|
end
|
|
|
|
feature -- Access
|
|
|
|
command_manager: COMMAND_MANAGER
|
|
-- Keeps track of actions for undo/redo functionality
|
|
|
|
name: STRING_8
|
|
-- The displayed name for this widget
|
|
|
|
uuid: UUID
|
|
-- Identifier for Current
|
|
|
|
sequence_of_play: VITP_SEQUENCE_OF_PLAY
|
|
-- Sequence of play for this game defining the order
|
|
-- of actions.
|
|
attribute
|
|
create Result.make (Current)
|
|
end
|
|
|
|
locations: VITP_TABLE [LOCATION]
|
|
-- Convenience feature containing all the board locations.
|
|
-- Defined as attibute so all locations can be persisted.
|
|
attribute
|
|
create Result.make (100)
|
|
Result.merge (sea_areas)
|
|
Result.merge (major_ports)
|
|
Result.merge (minor_ports)
|
|
end
|
|
|
|
feature -- Basic operations
|
|
|
|
|
|
feature -- Query
|
|
|
|
can_patrol (a_unit: ATTACK_UNIT): BOOLEAN
|
|
-- Can `a_unit' be moved as a patroller?
|
|
-- ... or can `a_unit' become a raider?
|
|
do
|
|
io.put_string (generating_type.name + ".can_patrol: fix me! %N")
|
|
-- Result := phase = Movement_phase and
|
|
-- stage = Patrolling and
|
|
-- ((player = Japanese_player and then a_unit.nationality = Japanese) or else
|
|
-- (player = Allied_player and then is_allied_nationality (a_unit.nationality)))
|
|
-- if Result and turn = 1 and player = Allied_player then
|
|
-- Result := a_unit = De_ruyter or
|
|
-- a_unit = Exeter or
|
|
-- a_unit = Houston or
|
|
-- a_unit = Australia or
|
|
-- a_unit = Canberra
|
|
-- end
|
|
end
|
|
|
|
feature -- Query
|
|
|
|
cell (a_x, a_y: INTEGER_32): VITP_CELL
|
|
-- The cell indexed by `a_x' and `a_y' into which a
|
|
-- unit may be placed
|
|
require
|
|
x_big_enough: a_x >= 1
|
|
x_small_enough: a_x <= cell_row_count
|
|
y_big_enough: a_y >= 1
|
|
y_small_enough: a_y <= cell_column_count
|
|
do
|
|
Result := grid.item (a_x, a_y)
|
|
end
|
|
|
|
feature {NONE} -- Implementation
|
|
|
|
grid: ARRAY2 [VITP_CELL]
|
|
-- A two-dimensional array of coordinate-position cells
|
|
-- which can possibly hold one {ATTACK_UNIT}
|
|
|
|
end
|