Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Quentin DRUAULT-AUBIN
lo23-project
Commits
e374b140
Commit
e374b140
authored
Dec 06, 2017
by
Quentin DRUAULT-AUBIN
Browse files
[Ship] Feedback on the grid
parent
7d1f4a1e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Battleship/src/main/java/com/utclo23/ihmtable/IHMTableFacade.java
View file @
e374b140
...
...
@@ -10,6 +10,7 @@ import com.utclo23.data.structure.StatGame;
import
com.utclo23.data.facade.IDataIHMTable
;
import
com.utclo23.data.structure.Game
;
import
com.utclo23.data.structure.LightPublicUser
;
import
com.utclo23.data.structure.Ship
;
import
com.utclo23.ihmmain.controller.AbstractController
;
import
com.utclo23.ihmmain.facade.IHMMainToIhmTable
;
import
com.utclo23.ihmtable.controller.InGameGUIController
;
...
...
@@ -193,10 +194,12 @@ public class IHMTableFacade implements IIHMTableToIHMMain, IIHMTableToData {
/**
* Show on the board if the shot has hit or not a ship.
* @param coord : the coordinates of the hit.
* @param bool : true if a ship is hit.
* @param touched : true if a ship is hit.
* @param destroyedShip : destroyed ship or null.
*/
@Override
public
void
feedBack
(
Coordinate
coord
,
boolean
bool
)
{
public
void
feedBack
(
Coordinate
coord
,
boolean
touched
,
Ship
destroyedShip
)
{
controller
.
displayOpponentAttack
(
coord
,
touched
,
destroyedShip
);
controller
.
timeToAttack
();
}
...
...
Battleship/src/main/java/com/utclo23/ihmtable/IIHMTableToData.java
View file @
e374b140
...
...
@@ -6,6 +6,7 @@
package
com.utclo23.ihmtable
;
import
com.utclo23.data.structure.Coordinate
;
import
com.utclo23.data.structure.Ship
;
import
com.utclo23.data.structure.StatGame
;
/**
...
...
@@ -15,7 +16,7 @@ import com.utclo23.data.structure.StatGame;
public
interface
IIHMTableToData
{
public
void
notifyGameReady
();
public
void
printMessage
(
String
message
);
public
void
feedBack
(
Coordinate
coord
,
boolean
bool
);
public
void
feedBack
(
Coordinate
coord
,
boolean
bool
,
Ship
destroyedShip
);
public
void
finishGame
(
StatGame
stGame
);
public
void
opponentHasLeftGame
();
public
void
connectionLostWithOpponent
();
...
...
Battleship/src/main/java/com/utclo23/ihmtable/controller/InGameGUIController.java
View file @
e374b140
...
...
@@ -1017,4 +1017,35 @@ public class InGameGUIController {
}
}
}
/**
* Display the opponent attack on the player grid.
* @param coord : attacked cell
* @param touched : true if touched
* @param destroyedShip : the destroyed ship or null.
*/
public
void
displayOpponentAttack
(
Coordinate
coord
,
boolean
touched
,
Ship
destroyedShip
)
{
// Get the cell.
Node
cell
=
getNodeByRowColumnIndex
(
coord
.
getX
(),
coord
.
getY
(),
playerGrid
);
// The opponent has touched my ship.
if
(
touched
)
{
// Add the CSS class.
cell
.
getStyleClass
().
add
(
"inGameGUI_touched_cell"
);
}
else
{
// The opponent has missed.
cell
.
getStyleClass
().
add
(
"inGameGUI_missed_cell"
);
}
// Ship destroyed.
if
(
destroyedShip
!=
null
)
{
// Change the opacity.
listOfShipsOnTheGrid
.
get
(
destroyedShip
).
setOpacity
(
0.5
);
// Change the CSS class of the cells.
for
(
Coordinate
coordinate
:
destroyedShip
.
getListCoord
())
{
Node
node
=
getNodeByRowColumnIndex
(
coordinate
.
getY
(),
coordinate
.
getX
(),
playerGrid
);
node
.
getStyleClass
().
removeAll
(
"inGameGUI_touched_cell"
);
node
.
getStyleClass
().
add
(
"inGameGUI_destroyed_cell"
);
}
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment