feat: implemented EntityDeserializer and EntityDeserializerTest
This commit is contained in:
@ -10,7 +10,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import uulm.teamname.marvelous.gamelibrary.IntVector2;
|
||||
import uulm.teamname.marvelous.gamelibrary.entities.*;
|
||||
import uulm.teamname.marvelous.gamelibrary.entities.Character;
|
||||
import uulm.teamname.marvelous.gamelibrary.json.JSON;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@ -18,7 +17,7 @@ public class EntityDeserializer extends JsonDeserializer<Entity> {
|
||||
|
||||
private enum DeserializedEntityType {
|
||||
Character,
|
||||
Stone,
|
||||
InfinityStone,
|
||||
Rock
|
||||
}
|
||||
|
||||
@ -49,8 +48,12 @@ public class EntityDeserializer extends JsonDeserializer<Entity> {
|
||||
-1,
|
||||
-1
|
||||
);
|
||||
|
||||
for (var i: mapper.readValue(node.get("stones").toString(), Integer[].class)) {
|
||||
((Character) result).inventory.addStone(StoneType.valueOf(i));
|
||||
}
|
||||
}
|
||||
case Stone -> {
|
||||
case InfinityStone -> {
|
||||
result = new InfinityStone(
|
||||
new EntityID(EntityType.InfinityStones, node.get("ID").asInt()),
|
||||
mapper.readValue(node.get("position").toString(), IntVector2.class),
|
||||
|
Reference in New Issue
Block a user