public enum BattleshipControlImpl extends java.lang.Enum<BattleshipControlImpl> implements BattleshipControl
BattleshipControl.PlayerType, BattleshipControl.ViewerType
Enum Constant and Description |
---|
CONTROLLER |
Modifier and Type | Method and Description |
---|---|
FieldBound |
getBoundary()
Returns the actual boundary used.
|
java.util.List<java.util.List<java.lang.Character>> |
getFieldView(BattleshipControl.PlayerType playerType,
BattleshipControl.ViewerType viewerType)
Get the proper field view depending on the player who owns it and
who is actually accessing it.
|
java.lang.String |
getNextPlaceableShip()
Returns the name of the next placeable ship.
|
void |
initializeAi()
Initializes the Ai
|
boolean |
isAiFleetSunk()
Returns
true if the AI fleet is sunk. |
boolean |
isGameNotFinished()
Returns
true if the game is not finished yet. |
boolean |
isPlayerFleetNotPlaced()
Returns
true if the player fleet isn't placed yet. |
boolean |
isPlayerFleetSunk()
Returns
true if the player fleet is sunk. |
boolean |
isPointWithinBoundaryLimits(Point2d point)
Returns
true if the point is within the boundary limits ,
false otherwise. |
static void |
placeFleetDiagonally(Field field,
Fleet fleet)
Places a fleet in diagonal lines.
|
void |
placeNextPlaceableShip(Point2d startingPosition)
Tries to place the next placeable ship on the player
field.
|
void |
setUpAiLevelEasy()
Sets the AI level to easy
|
void |
setUpAiLevelSuperEasy()
Sets the AI level to super easy
|
void |
shootAiField(Point2d point)
Tries to shoot the current cell selected.
|
void |
shootPlayerField()
Tries to shoot the player field.
|
static BattleshipControlImpl |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static BattleshipControlImpl[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final BattleshipControlImpl CONTROLLER
public static BattleshipControlImpl[] values()
for (BattleshipControlImpl c : BattleshipControlImpl.values()) System.out.println(c);
public static BattleshipControlImpl valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic boolean isGameNotFinished()
BattleshipControl
true
if the game is not finished yet.isGameNotFinished
in interface BattleshipControl
true
if the game is not finished yet.public boolean isAiFleetSunk()
BattleshipControl
true
if the AI fleet is sunk.isAiFleetSunk
in interface BattleshipControl
true
if the AI fleet is sunk.public boolean isPlayerFleetSunk()
BattleshipControl
true
if the player fleet is sunk.isPlayerFleetSunk
in interface BattleshipControl
true
if the player fleet is sunk.public void initializeAi()
BattleshipControl
initializeAi
in interface BattleshipControl
public static void placeFleetDiagonally(Field field, Fleet fleet)
field
- the current field used.fleet
- the fleet that will be placed.public void shootAiField(Point2d point)
BattleshipControl
shootAiField
in interface BattleshipControl
point
- a valid pointpublic void shootPlayerField()
BattleshipControl
Point2d
.shootPlayerField
in interface BattleshipControl
public java.util.List<java.util.List<java.lang.Character>> getFieldView(BattleshipControl.PlayerType playerType, BattleshipControl.ViewerType viewerType)
BattleshipControl
getFieldView
in interface BattleshipControl
playerType
- the type of player who owns the field.viewerType
- who is accessing the field.public FieldBound getBoundary()
BattleshipControl
getBoundary
in interface BattleshipControl
public java.lang.String getNextPlaceableShip()
BattleshipControl
getNextPlaceableShip
in interface BattleshipControl
public void placeNextPlaceableShip(Point2d startingPosition)
BattleshipControl
placeNextPlaceableShip
in interface BattleshipControl
startingPosition
- the position where the ship will start.public boolean isPlayerFleetNotPlaced()
BattleshipControl
true
if the player fleet isn't placed yet.isPlayerFleetNotPlaced
in interface BattleshipControl
true
if the player fleet isn't placed yet.public void setUpAiLevelSuperEasy()
BattleshipControl
setUpAiLevelSuperEasy
in interface BattleshipControl
public void setUpAiLevelEasy()
BattleshipControl
setUpAiLevelEasy
in interface BattleshipControl
public boolean isPointWithinBoundaryLimits(Point2d point)
BattleshipControl
true if the point is within the boundary limits
,
false otherwise.isPointWithinBoundaryLimits
in interface BattleshipControl
point
- the point to checktrue if the point is within the boundary limits
.