cleanup: optimize imports, remove unused code, fix warnings

This commit is contained in:
punchready 2021-06-01 19:26:29 +02:00
parent 4d467d6d95
commit e88476eb10
9 changed files with 33 additions and 27 deletions

View File

@ -12,9 +12,6 @@ import java.util.Objects;
@JsonDeserialize(using = EntityDeserializer.class)
@JsonSerialize(using = EntitySerializer.class)
public abstract class Entity {
/** Whether or not the entity is currently active in the game */
protected boolean active = true;
/** Whether or not the entity blocks movement */
protected boolean solid = false;
@ -43,10 +40,6 @@ public abstract class Entity {
*/
public abstract Entity clone();
public boolean isActive() {
return active;
}
public boolean blocksMovement() {
return solid;
}
@ -55,10 +48,6 @@ public abstract class Entity {
return opaque;
}
public void setActive(boolean active) {
this.active = active;
}
public IntVector2 getPosition() {
return position;
}
@ -72,12 +61,12 @@ public abstract class Entity {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Entity entity = (Entity) o;
return active == entity.active && Objects.equals(position, entity.position) && Objects.equals(id, entity.id);
return Objects.equals(position, entity.position) && Objects.equals(id, entity.id);
}
@Override
public int hashCode() {
return Objects.hash(active, position, id);
return Objects.hash(position, id);
}
}

View File

@ -1,8 +1,8 @@
package uulm.teamname.marvelous.gamelibrary.events;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import uulm.teamname.marvelous.gamelibrary.json.ingame.deserialize.EventDeserializer;
import uulm.teamname.marvelous.gamelibrary.json.basic.EventMessage;
import uulm.teamname.marvelous.gamelibrary.json.ingame.deserialize.EventDeserializer;
import java.util.Objects;

View File

@ -1,6 +1,6 @@
package uulm.teamname.marvelous.gamelibrary.events;
/** Represents a notification event for: {@link EventType#Ack}, {@link EventType#Nack}, {@link EventType#Req}. */
/** Represents a notification event for: {@link EventType#Ack}, {@link EventType#Nack}. */
public class NotificationEvent extends Event {
}

View File

@ -45,6 +45,8 @@ public class GameInstance {
result.addAll(result2);
result.add(GameLogic.buildGameStateEvent(_state));
return Optional.of(result);
}
@ -102,6 +104,10 @@ public class GameInstance {
manager.applyEvents(events);
}
protected GameState getState() {
return _state;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();

View File

@ -429,7 +429,7 @@ class GameLogic {
* Verifies that a {@link Character} is alive.
*/
private static void requireAlive(Character entity) throws InvalidRequestException {
if(!entity.isAlive() || !entity.isActive()) {
if(!entity.isAlive()) {
throw new InvalidRequestException();
}
}

View File

@ -1,7 +1,9 @@
package uulm.teamname.marvelous.gamelibrary.gamelogic;
import uulm.teamname.marvelous.gamelibrary.IntVector2;
import uulm.teamname.marvelous.gamelibrary.entities.*;
import uulm.teamname.marvelous.gamelibrary.entities.Entity;
import uulm.teamname.marvelous.gamelibrary.entities.EntityID;
import uulm.teamname.marvelous.gamelibrary.entities.StoneType;
import uulm.teamname.marvelous.gamelibrary.json.config.CharacterConfig;
import uulm.teamname.marvelous.gamelibrary.json.config.PartyConfig;
import uulm.teamname.marvelous.gamelibrary.json.config.ScenarioConfig;

View File

@ -12,7 +12,7 @@ class GameStateManager {
private final GameState state;
/** The queue of {@link Event}s to be applied during {@link Request} processing */
private final ArrayDeque<Event> queue = new ArrayDeque<Event>();
private final ArrayDeque<Event> queue = new ArrayDeque<>();
/**
* Constructs a new {@link GameStateManager}.

View File

@ -1,9 +0,0 @@
package uulm.teamname.marvelous.gamelibrary.gamelogic;
/** Specifies a participant type. */
public enum ParticipantType {
None,
Player1,
Player2,
Spectator
}

View File

@ -172,6 +172,24 @@ class GameLogicTest {
assertEquals(EventType.GamestateEvent, actual.type, "First event should be a GameStateEvent");
System.out.println(game.toString());
game.applyEvents(GameLogic.spawnThanos(game.getState()));
System.out.println(game.toString());
NPC thanos = (NPC)game.state.getEntities().findEntity(new EntityID(EntityType.NPC, 2));
game.applyEvents(GameLogic.handleThanos(game.getState(), thanos));
System.out.println(game.toString());
game.applyEvents(GameLogic.handleThanos(game.getState(), thanos));
System.out.println(game.toString());
game.applyEvents(GameLogic.handleThanos(game.getState(), thanos));
System.out.println(game.toString());
}