diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/EventObserver.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/EventObserver.java index 0686e25..be3d96f 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/EventObserver.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/EventObserver.java @@ -14,9 +14,9 @@ public class EventObserver implements Observer { /** * Gets called with incoming {@link Event}s. Override this method to handle events. - * @param event The events that got emitted + * @param events The events that got emitted */ - protected void handle(Event[] event) { + protected void handle(Event[] events) { } } diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java index 6a668b3..f111a5b 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java @@ -556,6 +556,8 @@ class GameLogic { public static ArrayList startGame(GameState state, ArrayList selectedCharacters1, ArrayList selectedCharacters2) { ArrayList result = new ArrayList<>(); + ArrayList free = new ArrayList<>(); + int rockIndex = 0; for(int x = 0; x < state.mapSize.getX(); x++) { for(int y = 0; y < state.mapSize.getY(); y++) { @@ -563,12 +565,12 @@ class GameLogic { result.add(new EventBuilder(EventType.SpawnEntityEvent) .withEntity(new Rock(new EntityID(EntityType.Rocks, rockIndex++), new IntVector2(x, y), 100)) .buildEntityEvent()); + }else { + free.add(new IntVector2(x, y)); } } } - ArrayList free = getFreeFields(state); - int p1 = selectedCharacters1.size(); int all = selectedCharacters1.size() + selectedCharacters2.size(); @@ -847,7 +849,28 @@ class GameLogic { public static ArrayList handleThanos(GameState state, NPC thanos) { ArrayList result = new ArrayList<>(); + if(thanos.inventory.getFreeSlots() > 0) { + IntVector2 picked = null; + float lowestDistance = Integer.MAX_VALUE; + for(int x = 0; x < state.mapSize.getX(); x++) { + for(int y = 0; y < state.mapSize.getY(); y++) { + IntVector2 pos = new IntVector2(x, y); + for(Entity e: state.entities.findByPosition(pos)) { + if(e instanceof InfinityStone || (e instanceof Character && ((Character)e).inventory.getSize() > 0)) { + float distance = thanos.getPosition().distanceChebyshev(pos); + if(distance < lowestDistance) { + picked = pos; + lowestDistance = distance; + break; + } + } + } + } + } + // + + } return result; }