Aufgabe 7.
fix: in class ShipMap function remove hierbei wurde nach dem entfernen eines Items dass Event ItemAddedEvent ausgelöst hierbei sollte aber logischerweiße dass Event ItemRemovedEvent ausgelöst werden. fix: in class BattleState function receivedEffect hierbei wurde die eigene map für die Bedingung isGameOver verglichen wobei man für isGameOver die OpponentMap auf remainingShips untersuchen muss.
This commit is contained in:
@@ -1,18 +1,19 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="BattleshipApp" type="Application" factoryName="Application" singleton="false"
|
<configuration default="false" name="BattleshipApp" type="Application" factoryName="Application" singleton="false" nameIsGenerated="true">
|
||||||
nameIsGenerated="true">
|
<option name="ALTERNATIVE_JRE_PATH" value="temurin-20" />
|
||||||
<option name="MAIN_CLASS_NAME" value="pp.battleship.client.BattleshipApp"/>
|
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
|
||||||
<module name="Projekte.battleship.client.main"/>
|
<option name="MAIN_CLASS_NAME" value="pp.battleship.client.BattleshipApp" />
|
||||||
<option name="VM_PARAMETERS" value="-Djava.util.logging.config.file=logging.properties"/>
|
<module name="Gruppe-01" />
|
||||||
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$"/>
|
<option name="VM_PARAMETERS" value="-Djava.util.logging.config.file=logging.properties" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
|
||||||
<extension name="coverage">
|
<extension name="coverage">
|
||||||
<pattern>
|
<pattern>
|
||||||
<option name="PATTERN" value="pp.battleship.client.*"/>
|
<option name="PATTERN" value="pp.battleship.client.*" />
|
||||||
<option name="ENABLED" value="true"/>
|
<option name="ENABLED" value="true" />
|
||||||
</pattern>
|
</pattern>
|
||||||
</extension>
|
</extension>
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Make" enabled="true"/>
|
<option name="Make" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
@@ -60,7 +60,7 @@ public void receivedEffect(EffectMessage msg) {
|
|||||||
if (destroyedOpponentShip(msg))
|
if (destroyedOpponentShip(msg))
|
||||||
logic.getOpponentMap().add(msg.getDestroyedShip());
|
logic.getOpponentMap().add(msg.getDestroyedShip());
|
||||||
if (msg.isGameOver()) {
|
if (msg.isGameOver()) {
|
||||||
msg.getRemainingOpponentShips().forEach(logic.getOwnMap()::add);
|
msg.getRemainingOpponentShips().forEach(logic.getOpponentMap()::add);
|
||||||
logic.setState(new GameOverState(logic));
|
logic.setState(new GameOverState(logic));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
import pp.battleship.notification.GameEvent;
|
import pp.battleship.notification.GameEvent;
|
||||||
import pp.battleship.notification.GameEventBroker;
|
import pp.battleship.notification.GameEventBroker;
|
||||||
import pp.battleship.notification.ItemAddedEvent;
|
import pp.battleship.notification.ItemAddedEvent;
|
||||||
|
import pp.battleship.notification.ItemRemovedEvent;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -97,7 +98,7 @@ public void add(Shot shot) {
|
|||||||
*/
|
*/
|
||||||
public void remove(Item item) {
|
public void remove(Item item) {
|
||||||
items.remove(item);
|
items.remove(item);
|
||||||
notifyListeners(new ItemAddedEvent(item, this));
|
notifyListeners(new ItemRemovedEvent(item, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user