added documentation for GameBoardSynchronizer

This commit is contained in:
Yvonne Schmidt 2024-12-02 07:40:45 +01:00
parent c83f7de30c
commit 1f07affbef

View File

@ -26,9 +26,9 @@ import static pp.util.FloatMath.PI;
/** /**
* The {@code GameBoardSynchronizer} class is responsible for synchronizing the graphical * The {@code GameBoardSynchronizer} class is responsible for synchronizing the graphical
* representation of the ships and shots on the sea map with the underlying data model. * representation of the Game board and figures with the underlying data model.
* It extends the {@link BoardSynchronizer} to provide specific synchronization * It extends the {@link BoardSynchronizer} to provide specific synchronization
* logic for the sea map. * logic for the Game board.
*/ */
class GameBoardSynchronizer extends BoardSynchronizer { class GameBoardSynchronizer extends BoardSynchronizer {
private static final String UNSHADED = "Common/MatDefs/Misc/Unshaded.j3md"; //NON-NLS private static final String UNSHADED = "Common/MatDefs/Misc/Unshaded.j3md"; //NON-NLS
@ -42,9 +42,9 @@ class GameBoardSynchronizer extends BoardSynchronizer {
/** /**
* Constructs a {@code GameBoardSynchronizer} object with the specified application, root node, and ship map. * Constructs a {@code GameBoardSynchronizer} object with the specified application, root node, and ship map.
* *
* @param app the Battleship application * @param app the Monopoly application
* @param root the root node to which graphical elements will be attached * @param root the root node to which graphical elements will be attached
* @param map the ship map containing the ships and shots * @param map the Game Board containing fields and figures
*/ */
public GameBoardSynchronizer(MonopolyApp app, Node root, Board board) { public GameBoardSynchronizer(MonopolyApp app, Node root, Board board) {
super(board, root); super(board, root);
@ -54,17 +54,15 @@ class GameBoardSynchronizer extends BoardSynchronizer {
} }
/** /**
* Visits a {@link Battleship} and creates a graphical representation of it. * Visits a {@link Figure} and creates a graphical representation of it.
* The representation is either a 3D model or a simple box depending on the * The representation is a 3D model.
* type of battleship.
* *
* @param ship the battleship to be represented * @param figure the figure to be represented
* @return the node containing the graphical representation of the battleship * @return the node containing the graphical representation of the figure
*/ */
public Spatial visit(Figure figure) { public Spatial visit(Figure figure) {
final Node node = new Node(FIGURE); final Node node = new Node(FIGURE);
node.attachChild(createBox(figure)); node.attachChild(createBox(figure));
// compute the center of the ship in world coordinates
final float x = 1; final float x = 1;
final float z = 1; final float z = 1;
node.setLocalTranslation(x, 0f, z); node.setLocalTranslation(x, 0f, z);
@ -72,10 +70,10 @@ class GameBoardSynchronizer extends BoardSynchronizer {
} }
/** /**
* Creates a simple box to represent a battleship that is not of the "King George V" type. * Creates a representation of a figure
* *
* @param ship the battleship to be represented * @param figure the figure to be represented
* @return the geometry representing the battleship as a box * @return the geometry representing the figure
*/ */
private Spatial createBox(Figure figure) { private Spatial createBox(Figure figure) {
final Box box = new Box(0.5f * (figure.getMaxY() - figure.getMinY()) + 0.3f, final Box box = new Box(0.5f * (figure.getMaxY() - figure.getMinY()) + 0.3f,