fix: fixed several bugs in EventSerializer
This commit is contained in:
parent
34dcc75400
commit
fa8d8fcd00
@ -59,6 +59,7 @@ public class EventSerializer extends StdSerializer<Event> {
|
||||
for (EntityID id : value.turnOrder) {
|
||||
gen.writeObject(id);
|
||||
}
|
||||
gen.writeEndArray();
|
||||
|
||||
gen.writeObjectField("activeCharacter", value.activeCharacter);
|
||||
|
||||
@ -101,7 +102,7 @@ public class EventSerializer extends StdSerializer<Event> {
|
||||
gen.writeObjectField("targetField", value.targetField);
|
||||
|
||||
if (value.type == EventType.UseInfinityStoneEvent || value.type == EventType.ExchangeInfinityStoneEvent) {
|
||||
gen.writeObject(new EntityID(EntityType.InfinityStones, value.stoneType.getID()));
|
||||
gen.writeObjectField("stoneType", new EntityID(EntityType.InfinityStones, value.stoneType.getID()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,6 +115,7 @@ public class EventSerializer extends StdSerializer<Event> {
|
||||
case RoundSetupEvent -> {
|
||||
gen.writeNumberField("roundCount", value.roundCount);
|
||||
gen.writeFieldName("characterOrder");
|
||||
gen.writeStartArray();
|
||||
for (EntityID id : value.characterOrder) {
|
||||
gen.writeObject(id);
|
||||
}
|
||||
|
@ -147,9 +147,9 @@ public class EventSerializerTest {
|
||||
|
||||
CharacterEvent ce = new CharacterEvent();
|
||||
ce.type = EventType.MeleeAttackEvent;
|
||||
ce.targetEntity = new EntityID(EntityType.P1,5);
|
||||
ce.targetField = new IntVector2(1,1);
|
||||
ce.originEntity = new EntityID(EntityType.P2,7);
|
||||
ce.targetEntity = new EntityID(EntityType.P1,5);
|
||||
ce.originField = new IntVector2(1,2);
|
||||
ce.targetField = new IntVector2(2,2);
|
||||
|
||||
var jsonRepresentingEE = """
|
||||
@ -157,7 +157,7 @@ public class EventSerializerTest {
|
||||
"eventType":"MeleeAttackEvent",
|
||||
"originEntity":{"entityID":"P2","ID":7},
|
||||
"targetEntity":{"entityID":"P1","ID":5},
|
||||
"originField":null,"targetField":[2,2]
|
||||
"originField":[1,2],"targetField":[2,2]
|
||||
}""".replace("\n", "");
|
||||
|
||||
// System.out.println(mapper.writeValueAsString(ce));
|
||||
@ -166,9 +166,9 @@ public class EventSerializerTest {
|
||||
|
||||
CharacterEvent ce2 = new CharacterEvent();
|
||||
ce2.type = EventType.UseInfinityStoneEvent;
|
||||
ce2.targetEntity = new EntityID(EntityType.P1,5);
|
||||
ce2.targetField = new IntVector2(1,1);
|
||||
ce2.originEntity = new EntityID(EntityType.P2,7);
|
||||
ce2.targetEntity = new EntityID(EntityType.P1,5);
|
||||
ce2.originField = new IntVector2(1,1);
|
||||
ce2.targetField = new IntVector2(2,2);
|
||||
ce2.stoneType = StoneType.MindStone;
|
||||
|
||||
@ -177,7 +177,9 @@ public class EventSerializerTest {
|
||||
"eventType":"UseInfinityStoneEvent",
|
||||
"originEntity":{"entityID":"P2","ID":7},
|
||||
"targetEntity":{"entityID":"P1","ID":5},
|
||||
"originField":null,"targetField":[2,2]
|
||||
"originField":[1,1],
|
||||
"targetField":[2,2],
|
||||
"stoneType":{"entityID":"InfinityStones","ID":1}
|
||||
}""".replace("\n", "");
|
||||
|
||||
System.out.println(mapper.writeValueAsString(ce2));
|
||||
@ -211,7 +213,7 @@ public class EventSerializerTest {
|
||||
"originField":null,"targetField":[2,2]
|
||||
}""".replace("\n", "");
|
||||
|
||||
System.out.println(mapper.writeValueAsString(ge));
|
||||
// System.out.println(mapper.writeValueAsString(ge));
|
||||
|
||||
// ERROR !!! "Current context not Array but Object" bei characterorder
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user