reformat code

This commit is contained in:
Daniel Langbein 2024-11-09 21:40:31 +01:00
parent 6e9a53dd72
commit aa3bdfde55
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002
44 changed files with 2337 additions and 2332 deletions

View File

@ -7,7 +7,7 @@ import javax.swing.*;
/** /**
* Game * Game
* * <p>
* Spawns the game. * Spawns the game.
* *
* @author Valerian Saliou <valerian@valeriansaliou.name> * @author Valerian Saliou <valerian@valeriansaliou.name>

View File

@ -8,7 +8,7 @@ import javazoom.jl.player.FactoryRegistry;
/** /**
* SoundJLayerBridge * SoundJLayerBridge
* * <p>
* Sound bridge to the JLayer library. * Sound bridge to the JLayer library.
* *
* @author Valerian Saliou <valerian@valeriansaliou.name> * @author Valerian Saliou <valerian@valeriansaliou.name>

View File

@ -7,7 +7,7 @@ import fr.enssat.BoulderDash.helpers.AudioLoadHelper;
/** /**
* ElementPositionUpdateHelper * ElementPositionUpdateHelper
* * <p>
* Updates position of all elements displayed on the map, according to their * Updates position of all elements displayed on the map, according to their
* next potential position. Each object has a weight, which is used to compare * next potential position. Each object has a weight, which is used to compare
* their power to destroy in the food chain. Sorry for that Darwinism. * their power to destroy in the food chain. Sorry for that Darwinism.
@ -39,7 +39,7 @@ public class BoulderAndDiamondController implements Runnable {
*/ */
public void run() { public void run() {
while (this.levelModel.isGameRunning()) { while (this.levelModel.isGameRunning()) {
if(!this.levelModel.getGamePaused()){ if (!this.levelModel.getGamePaused()) {
this.manageFallingObject(); this.manageFallingObject();
} }
try { try {
@ -61,7 +61,7 @@ public class BoulderAndDiamondController implements Runnable {
// Gets the spriteName of actual DisplayableElementModel object scanned // Gets the spriteName of actual DisplayableElementModel object scanned
DisplayableElementModel elementModel = this.levelModel.getGroundLevelModel()[x][y]; DisplayableElementModel elementModel = this.levelModel.getGroundLevelModel()[x][y];
if(elementModel == null) { if (elementModel == null) {
elementModel = new DirtModel(); elementModel = new DirtModel();
} }
@ -70,8 +70,8 @@ public class BoulderAndDiamondController implements Runnable {
// If it is a boulder or a diamond... // If it is a boulder or a diamond...
if (spriteName == "boulder" || spriteName == "diamond") { if (spriteName == "boulder" || spriteName == "diamond") {
this.manageFall(x, y); this.manageFall(x, y);
} else if(spriteName == "expandingwall"){ } else if (spriteName == "expandingwall") {
if(this.expandWall(x,y).equals("left")){ if (this.expandWall(x, y).equals("left")) {
x -= 1; x -= 1;
} }
} }
@ -92,12 +92,12 @@ public class BoulderAndDiamondController implements Runnable {
String spriteNameRight = elementRight.getSpriteName(); String spriteNameRight = elementRight.getSpriteName();
String way = ""; String way = "";
if(spriteNameLeft == "black"){ if (spriteNameLeft == "black") {
this.levelModel.expandThisWallToLeft(x,y); this.levelModel.expandThisWallToLeft(x, y);
way = "left"; way = "left";
} }
if(spriteNameRight == "black"){ if (spriteNameRight == "black") {
this.levelModel.expandThisWallToRight(x,y); this.levelModel.expandThisWallToRight(x, y);
way = "right"; way = "right";
} }
return way; return way;
@ -143,9 +143,9 @@ public class BoulderAndDiamondController implements Runnable {
this.levelModel.setGameRunning(false); this.levelModel.setGameRunning(false);
} else if (spriteNameBelow == "magicwall") { } else if (spriteNameBelow == "magicwall") {
if (this.levelModel.getGroundLevelModel()[x][y].getSpriteName() == "boulder" if (this.levelModel.getGroundLevelModel()[x][y].getSpriteName() == "boulder"
&& (this.levelModel.getGroundLevelModel()[x][y+2].getSpriteName() == "dirt" || && (this.levelModel.getGroundLevelModel()[x][y + 2].getSpriteName() == "dirt" ||
this.levelModel.getGroundLevelModel()[x][y+2].getSpriteName() == "black")) { this.levelModel.getGroundLevelModel()[x][y + 2].getSpriteName() == "black")) {
if(this.levelModel.getGroundLevelModel()[x][y].isConvertible()) { if (this.levelModel.getGroundLevelModel()[x][y].isConvertible()) {
this.levelModel.transformThisBoulderIntoADiamond(x, y); this.levelModel.transformThisBoulderIntoADiamond(x, y);
} else { } else {
this.levelModel.deleteThisBoulder(x, y); this.levelModel.deleteThisBoulder(x, y);

View File

@ -12,7 +12,7 @@ import java.awt.event.ActionListener;
/** /**
* GameController * GameController
* * <p>
* This system creates the view. * This system creates the view.
* The game loop is also handled there. * The game loop is also handled there.
* *
@ -53,11 +53,11 @@ public class GameController implements ActionListener {
* @param event Action event * @param event Action event
*/ */
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
switch(event.getActionCommand()) { switch (event.getActionCommand()) {
case "pause": case "pause":
if(this.firstClickOnPause) { if (this.firstClickOnPause) {
this.levelModel.setGamePaused(true); this.levelModel.setGamePaused(true);
} else if(!this.firstClickOnPause) { } else if (!this.firstClickOnPause) {
this.levelModel.setGamePaused(false); this.levelModel.setGamePaused(false);
} }
@ -85,7 +85,7 @@ public class GameController implements ActionListener {
private void resetGame(String source) { private void resetGame(String source) {
this.gameView.dispose(); this.gameView.dispose();
if(source.equals("restart")){ if (source.equals("restart")) {
this.levelModel = new LevelModel(this.navigationBetweenViewController.getPickedLevelIdentifier(), audioLoadHelper); this.levelModel = new LevelModel(this.navigationBetweenViewController.getPickedLevelIdentifier(), audioLoadHelper);
this.gameView = new GameView(this, levelModel); this.gameView = new GameView(this, levelModel);
this.gameView.setVisible(true); this.gameView.setVisible(true);
@ -103,6 +103,7 @@ public class GameController implements ActionListener {
/** /**
* Return the game view * Return the game view
*
* @return gameView * @return gameView
*/ */
public GameView getGameView() { public GameView getGameView() {
@ -111,6 +112,7 @@ public class GameController implements ActionListener {
/** /**
* Set the gameView * Set the gameView
*
* @param gameView * @param gameView
*/ */
public void setGameView(GameView gameView) { public void setGameView(GameView gameView) {

View File

@ -12,7 +12,7 @@ import java.awt.event.KeyListener;
/** /**
* GameKeyController * GameKeyController
* * <p>
* Manages the key events controller. * Manages the key events controller.
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>
@ -21,6 +21,7 @@ import java.awt.event.KeyListener;
public class GameKeyController implements KeyListener { public class GameKeyController implements KeyListener {
private LevelModel levelModel; private LevelModel levelModel;
private RockfordUpdateController updatePosRockford; private RockfordUpdateController updatePosRockford;
/** /**
* Class constructor * Class constructor
* *

View File

@ -15,7 +15,7 @@ import javax.swing.*;
/** /**
* LevelEditorController * LevelEditorController
* * <p>
* Manages the level editor controller. * Manages the level editor controller.
* *
* @author Valerian Saliou <valerian@valeriansaliou.name> * @author Valerian Saliou <valerian@valeriansaliou.name>
@ -50,7 +50,7 @@ public class LevelEditorController implements ActionListener {
* @param event Action event * @param event Action event
*/ */
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
switch(event.getActionCommand()) { switch (event.getActionCommand()) {
case "menu": case "menu":
this.levelEditorView.setVisible(false); this.levelEditorView.setVisible(false);
this.nav.setMenuView(); this.nav.setMenuView();
@ -67,7 +67,7 @@ public class LevelEditorController implements ActionListener {
String levelId = this.levelEditorView.getSelectedLevel(); String levelId = this.levelEditorView.getSelectedLevel();
LevelSaveHelper levelSave; LevelSaveHelper levelSave;
if(levelId == null || levelId.isEmpty()) { if (levelId == null || levelId.isEmpty()) {
// Create a new level // Create a new level
levelSave = new LevelSaveHelper(levelModel.getGroundLevelModel()); levelSave = new LevelSaveHelper(levelModel.getGroundLevelModel());
} else { } else {
@ -79,7 +79,7 @@ public class LevelEditorController implements ActionListener {
JOptionPane.showMessageDialog(frameDialog, "Level saved"); JOptionPane.showMessageDialog(frameDialog, "Level saved");
this.levelEditorView.openedLevelChange(levelSave.getLevelId()); this.levelEditorView.openedLevelChange(levelSave.getLevelId());
} catch(LevelConstraintNotRespectedException e) { } catch (LevelConstraintNotRespectedException e) {
JFrame frameDialog = new JFrame("Error"); JFrame frameDialog = new JFrame("Error");
JOptionPane.showMessageDialog(frameDialog, e.getMessage()); JOptionPane.showMessageDialog(frameDialog, e.getMessage());
} }
@ -90,7 +90,7 @@ public class LevelEditorController implements ActionListener {
String levelId = this.levelEditorView.getSelectedLevel(); String levelId = this.levelEditorView.getSelectedLevel();
JFrame frameDialog = new JFrame("Info"); JFrame frameDialog = new JFrame("Info");
if(levelId == null || levelId.isEmpty()) { if (levelId == null || levelId.isEmpty()) {
JOptionPane.showMessageDialog(frameDialog, "Level not yet saved, no need to delete it!"); JOptionPane.showMessageDialog(frameDialog, "Level not yet saved, no need to delete it!");
} else { } else {
new LevelRemoveHelper(levelId); new LevelRemoveHelper(levelId);

View File

@ -9,7 +9,7 @@ import java.awt.event.KeyListener;
/** /**
* LevelEditorKeyController * LevelEditorKeyController
* * <p>
* Manages the key events controller. * Manages the key events controller.
* *
* @author Valerian Saliou <valerian@valeriansaliou.name> * @author Valerian Saliou <valerian@valeriansaliou.name>
@ -72,7 +72,7 @@ public class LevelEditorKeyController implements KeyListener {
} }
// Hold block change (quick edit) // Hold block change (quick edit)
if(capLocks) { if (capLocks) {
this.levelModel.triggerBlockChange(this.levelEditorView.getPickedBlockValue()); this.levelModel.triggerBlockChange(this.levelEditorView.getPickedBlockValue());
} }
} }

View File

@ -13,7 +13,6 @@ import fr.enssat.BoulderDash.controllers.GameController;
* Controller to navigate between the different views * Controller to navigate between the different views
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>
*
*/ */
public class NavigationBetweenViewController implements ActionListener { public class NavigationBetweenViewController implements ActionListener {
private LevelEditorController levelEditorController; private LevelEditorController levelEditorController;

View File

@ -4,7 +4,7 @@ import fr.enssat.BoulderDash.models.LevelModel;
/** /**
* ElementPositionUpdateHelper * ElementPositionUpdateHelper
* * <p>
* Updates position of all elements displayed on the map, according to their * Updates position of all elements displayed on the map, according to their
* next potential position. Each object has a weight, which is used to compare * next potential position. Each object has a weight, which is used to compare
* their power to destroy in the food chain. Sorry for that Darwinism. * their power to destroy in the food chain. Sorry for that Darwinism.
@ -36,7 +36,7 @@ public class RockfordUpdateController implements Runnable {
*/ */
public void run() { public void run() {
while (this.levelModel.isGameRunning()) { while (this.levelModel.isGameRunning()) {
if(!this.levelModel.getGamePaused()){ if (!this.levelModel.getGamePaused()) {
if (this.rockfordHasMoved) { if (this.rockfordHasMoved) {
this.levelModel.setPositionOfRockford(rockfordPositionX, rockfordPositionY); this.levelModel.setPositionOfRockford(rockfordPositionX, rockfordPositionY);
this.rockfordHasMoved = false; this.rockfordHasMoved = false;

View File

@ -3,7 +3,7 @@ package fr.enssat.BoulderDash.exceptions;
/** /**
* LevelConstraintNotRespectedException * LevelConstraintNotRespectedException
* * <p>
* Raises an 'LevelConstraintNotRespectedException' exception. * Raises an 'LevelConstraintNotRespectedException' exception.
* Given the exception message. * Given the exception message.
* *

View File

@ -3,7 +3,7 @@ package fr.enssat.BoulderDash.exceptions;
/** /**
* ModelNotReadyException * ModelNotReadyException
* * <p>
* Raises an 'ModelNotReadyException' exception. * Raises an 'ModelNotReadyException' exception.
* Given the exception message. * Given the exception message.
* *

View File

@ -3,7 +3,7 @@ package fr.enssat.BoulderDash.exceptions;
/** /**
* UnknownModelException * UnknownModelException
* * <p>
* Raises an 'UnknownSpriteException' exception. * Raises an 'UnknownSpriteException' exception.
* Given the exception message. * Given the exception message.
* *

View File

@ -8,7 +8,7 @@ import java.util.HashMap;
/** /**
* AudioLoadHelper * AudioLoadHelper
* * <p>
* Manages audio * Manages audio
* *
* @author Valerian Saliou <valerian@valeriansaliou.name> * @author Valerian Saliou <valerian@valeriansaliou.name>
@ -43,7 +43,7 @@ public class AudioLoadHelper {
* @param musicId Music identifier * @param musicId Music identifier
*/ */
public void startMusic(String musicId) { public void startMusic(String musicId) {
if(this.musicToPlay != null) { if (this.musicToPlay != null) {
this.stopMusic(); this.stopMusic();
} }
@ -70,7 +70,7 @@ public class AudioLoadHelper {
// List sound files // List sound files
File soundsDir = new File(AudioLoadHelper.pathToAudioStore + "/sounds/"); File soundsDir = new File(AudioLoadHelper.pathToAudioStore + "/sounds/");
File [] soundFiles = soundsDir.listFiles(new FilenameFilter() { File[] soundFiles = soundsDir.listFiles(new FilenameFilter() {
@Override @Override
public boolean accept(File dir, String name) { public boolean accept(File dir, String name) {
return name.endsWith(".mp3"); return name.endsWith(".mp3");

View File

@ -36,7 +36,7 @@ import java.util.Locale;
/** /**
* LevelLoadHelper * LevelLoadHelper
* * <p>
* Proceeds level load routine * Proceeds level load routine
* Able to deserialize level data from storage, and format it to * Able to deserialize level data from storage, and format it to
* internal representation To be used as a data factory from level * internal representation To be used as a data factory from level
@ -225,11 +225,11 @@ public class LevelLoadHelper {
boolean currentSpriteConvertible = false; boolean currentSpriteConvertible = false;
// No name? Continue. // No name? Continue.
if(currentSpriteName == null || currentSpriteName.isEmpty()) { if (currentSpriteName == null || currentSpriteName.isEmpty()) {
continue; continue;
} }
if(currentSpriteConvertibleValue.equals("1")) { if (currentSpriteConvertibleValue.equals("1")) {
currentSpriteConvertible = true; currentSpriteConvertible = true;
} }
@ -459,6 +459,7 @@ public class LevelLoadHelper {
/** /**
* Gets the number of Diamonds to catch * Gets the number of Diamonds to catch
*
* @return number of Diamonds to catch * @return number of Diamonds to catch
*/ */
public int getDiamondsToCatch() { public int getDiamondsToCatch() {
@ -467,6 +468,7 @@ public class LevelLoadHelper {
/** /**
* Sets the number of Diamonds to catch * Sets the number of Diamonds to catch
*
* @param diamondsToCatch * @param diamondsToCatch
*/ */
public void setDiamondsToCatch(int diamondsToCatch) { public void setDiamondsToCatch(int diamondsToCatch) {

View File

@ -5,7 +5,7 @@ import java.io.File;
/** /**
* LevelRemoveHelper * LevelRemoveHelper
* * <p>
* Proceeds level save routine * Proceeds level save routine
* Able to iterate on internal representation of a map and serialize it to XML * Able to iterate on internal representation of a map and serialize it to XML
* *

View File

@ -23,7 +23,7 @@ import fr.enssat.BoulderDash.models.DirtModel;
/** /**
* LevelSaveHelper * LevelSaveHelper
* * <p>
* Proceeds level save routine * Proceeds level save routine
* Able to iterate on internal representation of a map and serialize it to XML * Able to iterate on internal representation of a map and serialize it to XML
* *
@ -93,13 +93,13 @@ public class LevelSaveHelper {
Pattern pattern = Pattern.compile("^level([0-9]+)\\.xml"); Pattern pattern = Pattern.compile("^level([0-9]+)\\.xml");
Matcher matcher; Matcher matcher;
for (File file : fileList){ for (File file : fileList) {
matcher = pattern.matcher(file.getName()); matcher = pattern.matcher(file.getName());
if (matcher.matches()) { if (matcher.matches()) {
matchedId = matcher.group(1); matchedId = matcher.group(1);
if(!matchedId.isEmpty()) { if (!matchedId.isEmpty()) {
tempLevelId = new Integer(matchedId); tempLevelId = new Integer(matchedId);
if (tempLevelId > electedLastLevelId) { if (tempLevelId > electedLastLevelId) {
@ -117,7 +117,7 @@ public class LevelSaveHelper {
electedLastLevelId += 1; electedLastLevelId += 1;
// Stringify // Stringify
if(electedLastLevelId < 10) { if (electedLastLevelId < 10) {
finalLevelId = "0" + electedLastLevelId.toString(); finalLevelId = "0" + electedLastLevelId.toString();
} else { } else {
finalLevelId = electedLastLevelId.toString(); finalLevelId = electedLastLevelId.toString();
@ -227,11 +227,11 @@ public class LevelSaveHelper {
widthValue = this.getGroundGrid().length - 2; widthValue = this.getGroundGrid().length - 2;
if(widthValue > 0) { if (widthValue > 0) {
heightValue = this.getGroundGrid()[0].length - 2; heightValue = this.getGroundGrid()[0].length - 2;
} }
if(heightValue < 0 || widthValue < 0) { if (heightValue < 0 || widthValue < 0) {
heightValue = 0; heightValue = 0;
widthValue = 0; widthValue = 0;
} }
@ -256,7 +256,7 @@ public class LevelSaveHelper {
gridElement.setAttribute("state", "initial"); gridElement.setAttribute("state", "initial");
// Iterate in MATRIX:{x} // Iterate in MATRIX:{x}
if(this.getGroundGrid().length > 2) { if (this.getGroundGrid().length > 2) {
// XML structure matrix is the inverse of the internal representation (hence the weird loop) // XML structure matrix is the inverse of the internal representation (hence the weird loop)
for (Integer curLineIndex = 1; curLineIndex < (this.getGroundGrid()[0].length - 1); curLineIndex++) { for (Integer curLineIndex = 1; curLineIndex < (this.getGroundGrid()[0].length - 1); curLineIndex++) {
gridElement.appendChild(this.gridLineNode(document, curLineIndex)); gridElement.appendChild(this.gridLineNode(document, curLineIndex));
@ -278,7 +278,7 @@ public class LevelSaveHelper {
gridLineElement.setAttribute("index", Integer.toString(curLineIndex - 1)); gridLineElement.setAttribute("index", Integer.toString(curLineIndex - 1));
// Iterate in MATRIX:X:{y} // Iterate in MATRIX:X:{y}
if(this.getGroundGrid().length > 2) { if (this.getGroundGrid().length > 2) {
// XML structure matrix is the inverse of the internal representation (hence the weird loop) // XML structure matrix is the inverse of the internal representation (hence the weird loop)
for (Integer curItemIndex = 1; curItemIndex < (this.getGroundGrid().length - 1); curItemIndex++) { for (Integer curItemIndex = 1; curItemIndex < (this.getGroundGrid().length - 1); curItemIndex++) {
gridLineElement.appendChild(this.gridLineItemNode(document, curLineIndex, curItemIndex)); gridLineElement.appendChild(this.gridLineItemNode(document, curLineIndex, curItemIndex));
@ -319,7 +319,7 @@ public class LevelSaveHelper {
DisplayableElementModel curGridElement = this.getGroundGrid()[curItemIndex][curLineIndex]; DisplayableElementModel curGridElement = this.getGroundGrid()[curItemIndex][curLineIndex];
// Null? // Null?
if(curGridElement == null) { if (curGridElement == null) {
curGridElement = new DirtModel(); curGridElement = new DirtModel();
} }
@ -341,7 +341,7 @@ public class LevelSaveHelper {
gridLineItemSpriteElement.setAttribute("name", nameValue); gridLineItemSpriteElement.setAttribute("name", nameValue);
gridLineItemSpriteElement.setAttribute("state", stateValue); gridLineItemSpriteElement.setAttribute("state", stateValue);
if("1".equals(convertibleValue)) { if ("1".equals(convertibleValue)) {
gridLineItemSpriteElement.setAttribute("convertible", convertibleValue); gridLineItemSpriteElement.setAttribute("convertible", convertibleValue);
} }

View File

@ -10,7 +10,7 @@ import java.util.List;
/** /**
* LevelSelectorHelper * LevelSelectorHelper
* * <p>
* Level selector helper * Level selector helper
* *
* @author Valerian Saliou <valerian@valeriansaliou.name> * @author Valerian Saliou <valerian@valeriansaliou.name>
@ -45,10 +45,11 @@ public class LevelSelectorHelper {
// Proceed available levels listing // Proceed available levels listing
MenuLevelSelector menuLevelList = new MenuLevelSelector(availableLevels, this.levelEditorView); MenuLevelSelector menuLevelList = new MenuLevelSelector(availableLevels, this.levelEditorView);
if(availableLevels.length > 0) { if (availableLevels.length > 0) {
menuLevelList.setChoiceValue(availableLevels[0]); menuLevelList.setChoiceValue(availableLevels[0]);
menuLevelList.setSelectedIndex(0); menuLevelList.setSelectedIndex(0);
}; }
;
menuLevelList.addActionListener(menuLevelList); menuLevelList.addActionListener(menuLevelList);
@ -69,18 +70,18 @@ public class LevelSelectorHelper {
int fileNameExtIndex; int fileNameExtIndex;
// Add empty element? // Add empty element?
if(this.hasEmptyElement) { if (this.hasEmptyElement) {
stockList.add(""); stockList.add("");
} }
for (File file : fileList){ for (File file : fileList) {
fileName = file.getName(); fileName = file.getName();
fileNameExtIndex = fileName.lastIndexOf('.'); fileNameExtIndex = fileName.lastIndexOf('.');
if (fileNameExtIndex > 0) { if (fileNameExtIndex > 0) {
fileNameExtValue = fileName.substring(fileNameExtIndex, fileName.length()); fileNameExtValue = fileName.substring(fileNameExtIndex, fileName.length());
if(fileNameExtValue.equals(".xml")) { if (fileNameExtValue.equals(".xml")) {
fileName = fileName.substring(0, fileNameExtIndex); fileName = fileName.substring(0, fileNameExtIndex);
stockList.add(fileName); stockList.add(fileName);
} }

View File

@ -16,7 +16,7 @@ import fr.enssat.BoulderDash.models.SteelWallModel;
/** /**
* ModelConvertHelper * ModelConvertHelper
* * <p>
* Provides model conversion services. * Provides model conversion services.
* *
* @author Valerian Saliou <valerian@valeriansaliou.name> * @author Valerian Saliou <valerian@valeriansaliou.name>

View File

@ -5,7 +5,7 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/** /**
* BoulderModel * BoulderModel
* * <p>
* Represents the boulders. * Represents the boulders.
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>

View File

@ -5,7 +5,7 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/** /**
* BrickWallModel * BrickWallModel
* * <p>
* Represents the brick wall in the game. * Represents the brick wall in the game.
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>

View File

@ -5,7 +5,7 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/** /**
* CursorModel * CursorModel
* * <p>
* Represents the field cursor pointer. * Represents the field cursor pointer.
* *
* @author Valerian Saliou <valerian@valeriansaliou.name> * @author Valerian Saliou <valerian@valeriansaliou.name>

View File

@ -8,7 +8,7 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/** /**
* DiamondModel * DiamondModel
* * <p>
* Represents a diamond in the game. * Represents a diamond in the game.
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>

View File

@ -5,7 +5,7 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/** /**
* DirtModel * DirtModel
* * <p>
* Represents the dirt in the game. * Represents the dirt in the game.
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>

View File

@ -8,7 +8,7 @@ import java.io.IOException;
/** /**
* DisplayableElementModel * DisplayableElementModel
* * <p>
* Represents a abstract displayable element * Represents a abstract displayable element
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>
@ -296,7 +296,9 @@ public abstract class DisplayableElementModel {
/** /**
* Function to update the sprites * Function to update the sprites
*
* @param currentTimeMillis Current time in milliseconds * @param currentTimeMillis Current time in milliseconds
*/ */
public void update(long currentTimeMillis) {} public void update(long currentTimeMillis) {
}
} }

View File

@ -5,7 +5,7 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/** /**
* DoorModel * DoorModel
* * <p>
* Represents escape door. * Represents escape door.
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>

View File

@ -5,7 +5,7 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/** /**
* EmptyModel * EmptyModel
* * <p>
* Represents "nothing". * Represents "nothing".
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>

View File

@ -5,7 +5,7 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/** /**
* ExpandingWallModel * ExpandingWallModel
* * <p>
* Represents a ExpandingWall in the game. * Represents a ExpandingWall in the game.
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>

View File

@ -9,7 +9,6 @@ import java.util.Observable;
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>
* @since 2015-06-19 * @since 2015-06-19
*
*/ */
public class GameInformationModel extends Observable { public class GameInformationModel extends Observable {
private int score; private int score;
@ -96,7 +95,7 @@ public class GameInformationModel extends Observable {
* Decrement of one the number total of remaining diamonds. * Decrement of one the number total of remaining diamonds.
*/ */
public void decrementRemainingsDiamonds() { public void decrementRemainingsDiamonds() {
if(remainingsDiamonds > 0){ if (remainingsDiamonds > 0) {
this.remainingsDiamonds -= 1; this.remainingsDiamonds -= 1;
this.myNotify(); this.myNotify();
} }

View File

@ -22,7 +22,7 @@ import java.util.Observable;
/** /**
* LevelModel * LevelModel
* * <p>
* Levels are loaded from XML file. The view knows the model, the controller is * Levels are loaded from XML file. The view knows the model, the controller is
* going to modify the model in function of the game panel. The model notifies * going to modify the model in function of the game panel. The model notifies
* the view when there are changes on it. * the view when there are changes on it.
@ -84,7 +84,7 @@ public class LevelModel extends Observable implements Runnable {
this.createLimits(); this.createLimits();
if(this.mode.equals("game")) { if (this.mode.equals("game")) {
this.initRockford(); this.initRockford();
this.initThreadAnimator(); this.initThreadAnimator();
} }
@ -274,12 +274,12 @@ public class LevelModel extends Observable implements Runnable {
*/ */
public void triggerBlockChange(String blockValue) { public void triggerBlockChange(String blockValue) {
// No block value? // No block value?
if(blockValue == null || blockValue.isEmpty()) { if (blockValue == null || blockValue.isEmpty()) {
return; return;
} }
// Cancel if Rockford is already in model // Cancel if Rockford is already in model
if((blockValue.equals("Rockford") || blockValue.equals("rockford")) && this.isRockfordInModel()) { if ((blockValue.equals("Rockford") || blockValue.equals("rockford")) && this.isRockfordInModel()) {
return; return;
} }
@ -343,7 +343,7 @@ public class LevelModel extends Observable implements Runnable {
public BufferedImage getImage(int x, int y) { public BufferedImage getImage(int x, int y) {
DisplayableElementModel elementModel = this.getDisplayableElement(x, y); DisplayableElementModel elementModel = this.getDisplayableElement(x, y);
if(elementModel == null) { if (elementModel == null) {
return new DirtModel().getSprite(); return new DirtModel().getSprite();
} }
@ -376,7 +376,7 @@ public class LevelModel extends Observable implements Runnable {
// Iterate and catch it! // Iterate and catch it!
for (int x = 0; x < this.getSizeWidth() && !isInModel; x++) { for (int x = 0; x < this.getSizeWidth() && !isInModel; x++) {
for (int y = 0; y < this.getSizeHeight() && !isInModel; y++) { for (int y = 0; y < this.getSizeHeight() && !isInModel; y++) {
if(this.groundGrid[x][y] != null && this.groundGrid[x][y].getSpriteName() == "rockford") { if (this.groundGrid[x][y] != null && this.groundGrid[x][y].getSpriteName() == "rockford") {
isInModel = true; isInModel = true;
} }
} }
@ -396,7 +396,7 @@ public class LevelModel extends Observable implements Runnable {
// Iterate and catch it! // Iterate and catch it!
for (int x = 0; x < this.getSizeWidth(); x++) { for (int x = 0; x < this.getSizeWidth(); x++) {
for (int y = 0; y < this.getSizeHeight(); y++) { for (int y = 0; y < this.getSizeHeight(); y++) {
if(this.groundGrid[x][y] != null && this.groundGrid[x][y].getSpriteName() == "diamond") { if (this.groundGrid[x][y] != null && this.groundGrid[x][y].getSpriteName() == "diamond") {
numberOfDiamonds += 1; numberOfDiamonds += 1;
} }
} }
@ -410,12 +410,12 @@ public class LevelModel extends Observable implements Runnable {
*/ */
public void checkConstraints() throws LevelConstraintNotRespectedException { public void checkConstraints() throws LevelConstraintNotRespectedException {
// Diamonds number? // Diamonds number?
if(this.countDiamonds() < 3) { if (this.countDiamonds() < 3) {
throw new LevelConstraintNotRespectedException("Add at least 3 diamonds!"); throw new LevelConstraintNotRespectedException("Add at least 3 diamonds!");
} }
// Rockford in model? // Rockford in model?
if(!this.isRockfordInModel()) { if (!this.isRockfordInModel()) {
throw new LevelConstraintNotRespectedException("Add Rockford on the map!"); throw new LevelConstraintNotRespectedException("Add Rockford on the map!");
} }
} }
@ -480,7 +480,7 @@ public class LevelModel extends Observable implements Runnable {
* @param y Sprite block vertical position * @param y Sprite block vertical position
*/ */
public void updateSprites(int x, int y) { public void updateSprites(int x, int y) {
if(groundGrid[x][y] == null) { if (groundGrid[x][y] == null) {
groundGrid[x][y] = new DirtModel(); groundGrid[x][y] = new DirtModel();
} }

View File

@ -8,7 +8,7 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/** /**
* MagicWallModel * MagicWallModel
* * <p>
* Represents the magic wall. * Represents the magic wall.
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>

View File

@ -8,7 +8,7 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/** /**
* RockfordModel * RockfordModel
* * <p>
* Represents the hero of the game. * Represents the hero of the game.
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>
@ -296,7 +296,7 @@ public class RockfordModel extends DisplayableElementModel {
* *
* @param hasExploded Whether Rockford has exploded or not * @param hasExploded Whether Rockford has exploded or not
*/ */
public void setHasExplosed(boolean hasExploded){ public void setHasExplosed(boolean hasExploded) {
this.hasExploded = hasExploded; this.hasExploded = hasExploded;
} }
} }

View File

@ -5,7 +5,7 @@ import fr.enssat.BoulderDash.models.DisplayableElementModel;
/** /**
* SteelWallModel * SteelWallModel
* * <p>
* Represents the steelWall * Represents the steelWall
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>

View File

@ -11,7 +11,7 @@ import fr.enssat.BoulderDash.views.LevelEditorView;
/** /**
* AssetsLevelEditorComponent * AssetsLevelEditorComponent
* * <p>
* Information panel element. * Information panel element.
* *
* @author Valerian Saliou <valerian@valeriansaliou.name> * @author Valerian Saliou <valerian@valeriansaliou.name>
@ -41,7 +41,7 @@ public class AssetsLevelEditorComponent extends JPanel implements ActionListener
String curListChoice; String curListChoice;
for(int i = 0; i < choiceList.size(); i++) { for (int i = 0; i < choiceList.size(); i++) {
curListChoice = choiceList.get(i); curListChoice = choiceList.get(i);
// Create radio buttons from list // Create radio buttons from list

View File

@ -11,7 +11,7 @@ import java.awt.*;
/** /**
* GameFieldView * GameFieldView
* * <p>
* Game field view for the game itself. * Game field view for the game itself.
* *
* @author Valerian Saliou <valerian@valeriansaliou.name> * @author Valerian Saliou <valerian@valeriansaliou.name>

View File

@ -14,7 +14,7 @@ import fr.enssat.BoulderDash.views.InformationPanel;
/** /**
* GameView * GameView
* * <p>
* Specifies the game view itself. * Specifies the game view itself.
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>

View File

@ -10,16 +10,15 @@ import java.util.Observer;
/** /**
* FieldView * FieldView
* * <p>
* FieldView, created by controller; we notice that we don't need to make * FieldView, created by controller; we notice that we don't need to make
* levelModel observable; Because of the sprites we have to refresh the game * levelModel observable; Because of the sprites we have to refresh the game
* windows very often so don't need of observers/observable mechanism * windows very often so don't need of observers/observable mechanism
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>
* @since 2015-06-19 * @since 2015-06-19
* * <p>
* This view is basically drawing into the Frame the levelModel. * This view is basically drawing into the Frame the levelModel.
*
*/ */
public abstract class GroundView extends JPanel implements Observer { public abstract class GroundView extends JPanel implements Observer {
protected LevelModel levelModel; protected LevelModel levelModel;
@ -50,8 +49,8 @@ public abstract class GroundView extends JPanel implements Observer {
} }
} }
if(!this.levelModel.isGameRunning()) { if (!this.levelModel.isGameRunning()) {
if(!this.levelModel.getRockford().getHasExplosed()) { if (!this.levelModel.getRockford().getHasExplosed()) {
this.displayWin(); this.displayWin();
} else { } else {
this.displayLose(); this.displayLose();

View File

@ -5,12 +5,12 @@ import java.awt.BorderLayout;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JTextArea; import javax.swing.JTextArea;
public class HelpView extends JFrame{ public class HelpView extends JFrame {
/** /**
* Generate the HelpView * Generate the HelpView
*/ */
public HelpView(){ public HelpView() {
this.initializeView(); this.initializeView();
this.createLayout(); this.createLayout();
} }

View File

@ -11,7 +11,7 @@ import fr.enssat.BoulderDash.models.LevelModel;
/** /**
* InformationPanel * InformationPanel
* * <p>
* Information panel element. * Information panel element.
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>

View File

@ -8,7 +8,7 @@ import fr.enssat.BoulderDash.models.LevelModel;
/** /**
* LevelEditorFieldView * LevelEditorFieldView
* * <p>
* Game field view for the level editor. * Game field view for the level editor.
* *
* @author Valerian Saliou <valerian@valeriansaliou.name> * @author Valerian Saliou <valerian@valeriansaliou.name>

View File

@ -16,7 +16,7 @@ import fr.enssat.BoulderDash.views.MenuLevelSelector;
/** /**
* LevelEditorView * LevelEditorView
* * <p>
* Specifies the level editor view. * Specifies the level editor view.
* *
* @author Colin Leverger <me@colinleverger.fr> * @author Colin Leverger <me@colinleverger.fr>
@ -167,7 +167,7 @@ public class LevelEditorView extends JFrame implements Observer {
public void openedLevelChange(String selectedLevelValue) { public void openedLevelChange(String selectedLevelValue) {
LevelModel pickedLevelModel; LevelModel pickedLevelModel;
if(selectedLevelValue != null && !selectedLevelValue.isEmpty()) { if (selectedLevelValue != null && !selectedLevelValue.isEmpty()) {
// Load existing model // Load existing model
pickedLevelModel = new LevelModel(selectedLevelValue, this.nav.getAudioLoadHelper(), "editor"); pickedLevelModel = new LevelModel(selectedLevelValue, this.nav.getAudioLoadHelper(), "editor");
} else { } else {
@ -201,7 +201,7 @@ public class LevelEditorView extends JFrame implements Observer {
String selectedLevelValue = changedSelector.getChoiceValue().toString(); String selectedLevelValue = changedSelector.getChoiceValue().toString();
// Value didn't change? // Value didn't change?
if(selectedLevelValue.equals(this.getSelectedLevel())) { if (selectedLevelValue.equals(this.getSelectedLevel())) {
return; return;
} }

View File

@ -10,7 +10,7 @@ import javax.swing.JPanel;
/** /**
* MenuImage * MenuImage
* * <p>
* Specifies the menu image * Specifies the menu image
* *
* @author Valerian Saliou <valerian@valeriansaliou.name> * @author Valerian Saliou <valerian@valeriansaliou.name>

View File

@ -8,7 +8,7 @@ import fr.enssat.BoulderDash.views.LevelEditorView;
/** /**
* MenuLevelSelector * MenuLevelSelector
* * <p>
* Specifies the menu level selector * Specifies the menu level selector
* *
* @author Valerian Saliou <valerian@valeriansaliou.name> * @author Valerian Saliou <valerian@valeriansaliou.name>
@ -39,7 +39,7 @@ public class MenuLevelSelector extends JComboBox {
JComboBox comboBoxSource = (JComboBox) e.getSource(); JComboBox comboBoxSource = (JComboBox) e.getSource();
this.choiceValue = (String) comboBoxSource.getSelectedItem(); this.choiceValue = (String) comboBoxSource.getSelectedItem();
if(this.levelEditorView != null) { if (this.levelEditorView != null) {
this.levelEditorView.menuLevelSelectorChanged(this); this.levelEditorView.menuLevelSelectorChanged(this);
} }
} }

View File

@ -12,7 +12,7 @@ import fr.enssat.BoulderDash.controllers.NavigationBetweenViewController;
/** /**
* MenuView * MenuView
* * <p>
* Menu view * Menu view
* *
* @author Valerian Saliou <valerian@valeriansaliou.name> * @author Valerian Saliou <valerian@valeriansaliou.name>

View File

@ -5,14 +5,14 @@ import java.awt.BorderLayout;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JTextArea; import javax.swing.JTextArea;
public class WinLoseView extends JFrame{ public class WinLoseView extends JFrame {
private String winOrLose; private String winOrLose;
/** /**
* Generate the HelpView * Generate the HelpView
*/ */
public WinLoseView(String winOrLose){ public WinLoseView(String winOrLose) {
this.winOrLose = winOrLose; this.winOrLose = winOrLose;
this.initializeView(); this.initializeView();
this.createLayout(); this.createLayout();
@ -39,7 +39,7 @@ public class WinLoseView extends JFrame{
private void createLayout() { private void createLayout() {
JTextArea help = new JTextArea(); JTextArea help = new JTextArea();
help.setEditable(false); help.setEditable(false);
if(winOrLose.equals("win")) if (winOrLose.equals("win"))
help.setText("YOU WIN THE GAME :-)"); help.setText("YOU WIN THE GAME :-)");
else else
help.setText("YOU LOSE THE GAME :-( TRY AGAIN!"); help.setText("YOU LOSE THE GAME :-( TRY AGAIN!");