corrected the code for nr. 8 +10
now the backgroundmusic-settings will be stored correctly and when a invalid map is submitted,the error will be displayed correctly
This commit is contained in:
@@ -242,7 +242,7 @@ public void loadMap(File file) throws IOException {
|
||||
if (!dto.fits(logic.getDetails()))
|
||||
throw new IOException(lookup("map.doesnt.fit"));
|
||||
if (!verifyMap(dto)) {
|
||||
throw new IOException(lookup("map is not valid"));
|
||||
throw new IOException(lookup("player.submitted.invalid.map"));
|
||||
}
|
||||
ownMap().clear();
|
||||
dto.getShips().forEach(ownMap()::add);
|
||||
@@ -284,29 +284,15 @@ private boolean verifyBounds(ShipMapDTO dto) {
|
||||
* @return true, if no ships overlap
|
||||
*/
|
||||
private boolean verifyOverlap(ShipMapDTO dto) {
|
||||
List<Battleship> battleshipList = dto.getShips();
|
||||
for (int i = 0; i < battleshipList.size(); i++) {
|
||||
Battleship ship1 = battleshipList.get(i);
|
||||
for (int j = i + 1; j < battleshipList.size(); j++) {
|
||||
Battleship ship2 = battleshipList.get(j);
|
||||
if (ship1.collidesWith(ship2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
/*
|
||||
List<Battleship> ships = dto.getShips();
|
||||
for (Battleship ship : ships) {
|
||||
for (Battleship compareShip : ships) {
|
||||
if (ships != compareShip) {
|
||||
if (!ship.equals(compareShip)) {
|
||||
if (ship.collidesWith(compareShip)) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -184,29 +184,15 @@ private boolean verifyBounds(MapMessage msg, int playerID) {
|
||||
* @return true, if no ships overlap
|
||||
*/
|
||||
private boolean verifyOverlap(MapMessage msg) {
|
||||
List<Battleship> battleshipList = msg.getShips();
|
||||
for (int i = 0; i < battleshipList.size(); i++) {
|
||||
Battleship ship1 = battleshipList.get(i);
|
||||
for (int j = i + 1; j < battleshipList.size(); j++) {
|
||||
Battleship ship2 = battleshipList.get(j);
|
||||
if (ship1.collidesWith(ship2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
/*
|
||||
List<Battleship> ships = msg.getShips();
|
||||
for (Battleship ship : ships) {
|
||||
for (Battleship compareShip : ships) {
|
||||
if (ship != compareShip) {
|
||||
if (!ship.equals(compareShip)) {
|
||||
if (ship.collidesWith(compareShip)) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,3 +39,4 @@ port.must.be.integer=Port must be an integer number
|
||||
map.doesnt.fit=The map doesn't fit to this game
|
||||
background.music.checkbox= Background music on/off
|
||||
background.music.volume= Background volume
|
||||
player.submitted.invalid.map= invalid map submitted
|
||||
|
||||
@@ -39,4 +39,5 @@ port.must.be.integer=Der Port muss eine ganze Zahl sein
|
||||
map.doesnt.fit=Diese Karte passt nicht zu diesem Spiel
|
||||
background.music.checkbox= Musik an/aus
|
||||
background.music.volume= Musiklautstärke
|
||||
player.submitted.invalid.map= Invalide karte gegeben
|
||||
|
||||
|
||||
Reference in New Issue
Block a user