fix: naming and field occupation during game initialization
This commit is contained in:
parent
bfe7b10169
commit
787ba7d38e
@ -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) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -556,6 +556,8 @@ class GameLogic {
|
||||
public static ArrayList<Event> startGame(GameState state, ArrayList<Integer> selectedCharacters1, ArrayList<Integer> selectedCharacters2) {
|
||||
ArrayList<Event> result = new ArrayList<>();
|
||||
|
||||
ArrayList<IntVector2> 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<IntVector2> free = getFreeFields(state);
|
||||
|
||||
int p1 = selectedCharacters1.size();
|
||||
int all = selectedCharacters1.size() + selectedCharacters2.size();
|
||||
|
||||
@ -847,7 +849,28 @@ class GameLogic {
|
||||
public static ArrayList<Event> handleThanos(GameState state, NPC thanos) {
|
||||
ArrayList<Event> 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user