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,8 +1,9 @@
 | 
			
		||||
<component name="ProjectRunConfigurationManager">
 | 
			
		||||
  <configuration default="false" name="BattleshipApp" type="Application" factoryName="Application" singleton="false"
 | 
			
		||||
                 nameIsGenerated="true">
 | 
			
		||||
  <configuration default="false" name="BattleshipApp" type="Application" factoryName="Application" singleton="false" nameIsGenerated="true">
 | 
			
		||||
    <option name="ALTERNATIVE_JRE_PATH" value="temurin-20" />
 | 
			
		||||
    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
 | 
			
		||||
    <option name="MAIN_CLASS_NAME" value="pp.battleship.client.BattleshipApp" />
 | 
			
		||||
    <module name="Projekte.battleship.client.main"/>
 | 
			
		||||
    <module name="Gruppe-01" />
 | 
			
		||||
    <option name="VM_PARAMETERS" value="-Djava.util.logging.config.file=logging.properties" />
 | 
			
		||||
    <option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
 | 
			
		||||
    <extension name="coverage">
 | 
			
		||||
 
 | 
			
		||||
@@ -60,7 +60,7 @@ public void receivedEffect(EffectMessage msg) {
 | 
			
		||||
        if (destroyedOpponentShip(msg))
 | 
			
		||||
            logic.getOpponentMap().add(msg.getDestroyedShip());
 | 
			
		||||
        if (msg.isGameOver()) {
 | 
			
		||||
            msg.getRemainingOpponentShips().forEach(logic.getOwnMap()::add);
 | 
			
		||||
            msg.getRemainingOpponentShips().forEach(logic.getOpponentMap()::add);
 | 
			
		||||
            logic.setState(new GameOverState(logic));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@
 | 
			
		||||
import pp.battleship.notification.GameEvent;
 | 
			
		||||
import pp.battleship.notification.GameEventBroker;
 | 
			
		||||
import pp.battleship.notification.ItemAddedEvent;
 | 
			
		||||
import pp.battleship.notification.ItemRemovedEvent;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
@@ -97,7 +98,7 @@ public void add(Shot shot) {
 | 
			
		||||
     */
 | 
			
		||||
    public void remove(Item item) {
 | 
			
		||||
        items.remove(item);
 | 
			
		||||
        notifyListeners(new ItemAddedEvent(item, this));
 | 
			
		||||
        notifyListeners(new ItemRemovedEvent(item, this));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user