fix: added missing name field to EntitySerializer

This commit is contained in:
Yannik Bretschneider 2021-06-02 16:29:24 +02:00
parent c07c141c6e
commit e54ce32626

View File

@ -25,10 +25,8 @@ public class EntitySerializer extends StdSerializer<Entity> {
gen.writeObjectField("entityType", SerializedEntityType.valueOf(value.id.type)); gen.writeObjectField("entityType", SerializedEntityType.valueOf(value.id.type));
if (value instanceof NPC) { if (value instanceof NPC) {
System.out.println("instanceof NPC");
serializeNPC((NPC) value, gen, provider); serializeNPC((NPC) value, gen, provider);
} else if (value instanceof Character) { } else if (value instanceof Character) {
System.out.println("instanceof Chara");
serializeCharacter((Character) value, gen, provider); serializeCharacter((Character) value, gen, provider);
} else if (value instanceof Rock) { } else if (value instanceof Rock) {
serializeRock((Rock) value, gen, provider); serializeRock((Rock) value, gen, provider);
@ -50,6 +48,7 @@ public class EntitySerializer extends StdSerializer<Entity> {
private void serializeCharacter(Character value, JsonGenerator gen, SerializerProvider provider) private void serializeCharacter(Character value, JsonGenerator gen, SerializerProvider provider)
throws IOException { throws IOException {
gen.writeStringField("name", value.name);
gen.writeNumberField("PID", value.id.type == EntityType.P1 ? 1 : 2); gen.writeNumberField("PID", value.id.type == EntityType.P1 ? 1 : 2);
gen.writeNumberField("ID", value.id.id); gen.writeNumberField("ID", value.id.id);
gen.writeNumberField("HP", value.hp.getValue()); gen.writeNumberField("HP", value.hp.getValue());