JSONSerialisable objects now have a debug function #156

This commit is contained in:
Simon
2018-06-04 17:07:20 -04:00
parent 92008e553a
commit 78f98c8227
8 changed files with 50 additions and 3 deletions

View File

@@ -75,6 +75,15 @@ public class HarvesterNPC extends NonPlayerCharacter {
return json;
}
@Override
public JSONObject debugJsonSerialise() {
JSONObject json = jsonSerialise();
json.put("taskCompleted", getTask().checkCompleted());
return json;
}
@Override
public Document mongoSerialise() {
Document dbObject = super.mongoSerialise();

View File

@@ -5,6 +5,8 @@ import net.simon987.server.game.objects.MessageReceiver;
import net.simon987.server.game.objects.Structure;
import net.simon987.server.game.objects.Updatable;
import org.bson.Document;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import java.util.ArrayList;
@@ -61,4 +63,18 @@ public class RadioTower extends Structure implements MessageReceiver, Updatable
return lastMessages;
}
@Override
public JSONObject debugJsonSerialise() {
JSONObject json = super.debugJsonSerialise();
JSONArray messages = new JSONArray();
for (char[] message : this.messages) {
messages.add(new String(message));
}
json.put("messages", messages);
return json;
}
}