From abd70a0d0589fa89494a4c456625a02b3371e76e Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Sun, 2 May 2021 00:05:55 +0200 Subject: [PATCH 1/3] fix: deleted duplicate equals --- .../gamelibrary/entities/EntityID.java | 11 --- .../gamelibrary/events/EventBuilderTest.java | 77 +++++++++++++++++++ 2 files changed, 77 insertions(+), 11 deletions(-) create mode 100644 src/test/java/uulm/teamname/marvelous/gamelibrary/events/EventBuilderTest.java diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/EntityID.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/EntityID.java index e1b38ca..a855563 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/EntityID.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/EntityID.java @@ -29,17 +29,6 @@ public class EntityID { return type == other; } - @Override - public boolean equals(Object obj){ - if(this == obj) return true; - - if(!(obj instanceof EntityID)) return false; - - EntityID other = (EntityID)obj; - - return this.id == other.id && this.type == other.type; - } - /** * Clones this entity id. * @return The cloned {@link EntityID} diff --git a/src/test/java/uulm/teamname/marvelous/gamelibrary/events/EventBuilderTest.java b/src/test/java/uulm/teamname/marvelous/gamelibrary/events/EventBuilderTest.java new file mode 100644 index 0000000..f138822 --- /dev/null +++ b/src/test/java/uulm/teamname/marvelous/gamelibrary/events/EventBuilderTest.java @@ -0,0 +1,77 @@ +package uulm.teamname.marvelous.gamelibrary.events; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.*; +import uulm.teamname.marvelous.gamelibrary.IntVector2; +import uulm.teamname.marvelous.gamelibrary.entities.*; + +import java.util.HashMap; + +import static org.mockito.Mockito.*; +import static org.junit.jupiter.api.Assertions.*; + +class EventBuilderTest { + + @BeforeEach + void setUp() { + EventBuilder builder = new EventBuilder() + .withType(EventType.CustomEvent) + .withTargetEntity(new EntityID(EntityType.P1, 1)) + .withTargetField(new IntVector2(11, 13)) + .withAmount(15) + .withOriginEntity(new EntityID(EntityType.P2, 4)) + .withOriginField(new IntVector2(15, 3)) + .withStoneType(StoneType.MindStone) + .withRoundCount(3) + .withTurnCount(4) + .withCharacterOrder(new EntityID[] { + new EntityID(EntityType.P1, 4), + new EntityID(EntityType.P1, 1), + new EntityID(EntityType.P2, 2), + new EntityID(EntityType.P2, 4), + new EntityID(EntityType.P1, 3), + new EntityID(EntityType.P2, 5),}) + .withNextCharacter(new EntityID(EntityType.P2, 2)) + .withPlayerWon(2) + .withMessage("Some message") + .withTimeLeft(11) + .withEntities(new Entity[] {}) + .withTurnOrder(new EntityID[] { + new EntityID(EntityType.P1, 4), + new EntityID(EntityType.P1, 1), + new EntityID(EntityType.P2, 2), + new EntityID(EntityType.P2, 4), + new EntityID(EntityType.P1, 3), + new EntityID(EntityType.P2, 5),}) + .withActiveCharacter(new EntityID(EntityType.P1, 1)) + .withWinCondition(false) + .withTeamIdentifier("Team25") + .withCustomContent(new HashMap<>()); + } + + @Test + void buildGameEvent() { + var gameEvent = new EventBuilder() + .withType(EventType.DisconnectEvent) + .buildEntityEvent(); + + assertThat(gameEvent).isEqualTo() + } + + @Test + void buildEntityEvent() { + } + + @Test + void buildCharacterEvent() { + } + + @Test + void buildGamestateEvent() { + } + + @Test + void buildCustomEvent() { + } +} \ No newline at end of file From c8de7e25c89e60b5066e090977315338c7da3752 Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Sun, 2 May 2021 00:12:42 +0200 Subject: [PATCH 2/3] fix: changed language level --- .idea/misc.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 9a2ce5e..d683bfb 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file From 21fccee0df73dd9bbc1b3d554146ce58dc60886c Mon Sep 17 00:00:00 2001 From: punchready Date: Sun, 2 May 2021 00:19:01 +0200 Subject: [PATCH 3/3] fix: fix formatting --- .../gamelibrary/entities/EntityID.java | 1 - .../gamelibrary/events/EventBuilder.java | 24 ++++++++----------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/EntityID.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/EntityID.java index a855563..a06fbe4 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/EntityID.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/EntityID.java @@ -45,7 +45,6 @@ public class EntityID { return "["+type.toString()+":"+id+"]"; } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/events/EventBuilder.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/events/EventBuilder.java index fff5c60..e4c629f 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/events/EventBuilder.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/events/EventBuilder.java @@ -8,13 +8,10 @@ import uulm.teamname.marvelous.gamelibrary.entities.StoneType; import java.util.HashMap; /** - * A class made for building all sorts of {@link Event}s as nicely as possible. It works by taking - * .with[KEY]() functions and then building a specific event at the end + * A class made for building all sorts of {@link Event}s as nicely as possible. + * It works by taking .with[KEY]() functions and then building a specific event at the end. */ public class EventBuilder { - - // variable definitions (as in all possible keys) - /** The type of event that is being built */ private EventType type; // Keys used primarily in EntityEvents, but also in others @@ -38,7 +35,7 @@ public class EventBuilder { private String message; private int timeLeft; - // Keys used primarily in GamestateEvents + // Keys used primarily in GameStateEvents private Entity[] entities; private EntityID[] turnOrder; private EntityID activeCharacter; @@ -49,14 +46,13 @@ public class EventBuilder { private HashMap customContent; /** - * Creates an empty {@link EventBuilder} used for building {@link Event}s + * Creates a new {@link EventBuilder} used for building {@link Event}s */ public EventBuilder () { } - - // With for builder pattern style things + // with for builder pattern style things public EventBuilder withType(EventType type) { this.type = type; @@ -189,11 +185,11 @@ public class EventBuilder { /** * Builds an {@link EntityEvent} from the values given to the builder. - *
    - *
  • type is the {@link EventType} of the EntityEvent
  • - *
  • targetEntity is the target {@link Entity}
  • - *
  • targetField is the target field in the form of an {@link IntVector2}
  • - *
  • amount is the amount of something, like damage. It's an int.
  • + *
      + *
    • type is the {@link EventType} of the EntityEvent
    • + *
    • targetEntity is the target {@link Entity}
    • + *
    • targetField is the target field in the form of an {@link IntVector2}
    • + *
    • amount is the amount of something, like damage. It's an int.
    • *
    * @return a {@link EntityEvent} based on the builder. Caution: non-given fields are null! */