diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/json/basic/BasicAnswer.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/json/basic/BasicAnswer.java new file mode 100644 index 0000000..41e45af --- /dev/null +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/json/basic/BasicAnswer.java @@ -0,0 +1,10 @@ +package uulm.teamname.marvelous.gamelibrary.json.basic; + +import uulm.teamname.marvelous.gamelibrary.json.MessageType; + +/** Basic answer to a message. It contains */ +public class BasicAnswer { + String userID; + MessageType messageType; + boolean optionals; +} diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/json/ingame/MessageStructure.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/json/ingame/MessageStructure.java index e63f8f3..e742668 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/json/ingame/MessageStructure.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/json/ingame/MessageStructure.java @@ -1,6 +1,5 @@ package uulm.teamname.marvelous.gamelibrary.json.ingame; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import uulm.teamname.marvelous.gamelibrary.events.Event; import uulm.teamname.marvelous.gamelibrary.json.MessageType; diff --git a/src/test/java/uulm/teamname/marvelous/gamelibrary/json/JSONTest.java b/src/test/java/uulm/teamname/marvelous/gamelibrary/json/JSONTest.java index 78c456e..e824afa 100644 --- a/src/test/java/uulm/teamname/marvelous/gamelibrary/json/JSONTest.java +++ b/src/test/java/uulm/teamname/marvelous/gamelibrary/json/JSONTest.java @@ -30,31 +30,31 @@ class JSONTest { @BeforeEach void setUp() { messageStructureStart = """ -{ -"messages":[ -"""; + { + "messages":[ + """; messageStructureEnd = new String[] { -""" -], -"messageType": "REQUESTS", -"customContentType": "TestCustomContent", -"customContent": { - "customKey" = "customResult", - "customNumber" = 15, - "customProperty" = true -} -""", -""" -], -"messageType": "EVENTS", -"customContentType": "TestCustomContent", -"customContent": { - "customKey": "customResult", - "customNumber": 15, - "customProperty": true - } -} -""", + """ + ], + "messageType": "REQUESTS", + "customContentType": "TestCustomContent", + "customContent": { + "customKey" = "customResult", + "customNumber" = 15, + "customProperty" = true + } + """, + """ + ], + "messageType": "EVENTS", + "customContentType": "TestCustomContent", + "customContent": { + "customKey": "customResult", + "customNumber": 15, + "customProperty": true + } + } + """, }; target = new MessageStructure(); target.customContentType = "TestCustomContent"; @@ -76,9 +76,9 @@ class JSONTest { }; String eventRepresentation = """ -{"eventType": "Ack"}, -{"eventType": "Nack"} -"""; + {"eventType": "Ack"}, + {"eventType": "Nack"} + """; String completeMessageStructure = messageStructureStart + eventRepresentation + messageStructureEnd[1]; target.messageType = MessageType.EVENTS; @@ -91,19 +91,19 @@ class JSONTest { @Test void parseMoreComplicatedEvents() { String eventRepresentation = """ -{ - "eventType": "GamestateEvent", - "activeCharacter": {"entityID": "P2", "ID": 4}, - "turnOrder": [ - {"entityID": "P2", "ID": 4}, - {"entityID": "P2", "ID": 2}, - {"entityID": "P1", "ID": 3}, - {"entityID": "NPC", "ID": 1}, - {"entityID": "InfinityStones", "ID": 5}, - {"entityID": "Rocks", "ID": 0} - ] -} -"""; + { + "eventType": "GamestateEvent", + "activeCharacter": {"entityID": "P2", "ID": 4}, + "turnOrder": [ + {"entityID": "P2", "ID": 4}, + {"entityID": "P2", "ID": 2}, + {"entityID": "P1", "ID": 3}, + {"entityID": "NPC", "ID": 1}, + {"entityID": "InfinityStones", "ID": 5}, + {"entityID": "Rocks", "ID": 0} + ] + } + """; String completeMessageStructure = messageStructureStart + eventRepresentation + messageStructureEnd[1]; System.out.println(JSON.parse(completeMessageStructure)); @@ -113,11 +113,11 @@ class JSONTest { @Disabled void simpleInDevTest() throws JsonProcessingException { String simpleEntity = """ -{ - "entityID": "P2", - "ID": 4 -} -"""; + { + "entityID": "P2", + "ID": 4 + } + """; System.out.println(new ObjectMapper().readValue(simpleEntity, EntityID.class)); }